Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit 233dc5f

Browse files
committed
flake reorg, nix integration testing
1 parent 1a83803 commit 233dc5f

20 files changed

+3565
-3723
lines changed

.github/workflows/ci.yaml

Lines changed: 17 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -1,209 +1,32 @@
1-
on: [push, pull_request]
2-
3-
name: CI
1+
name: "CI"
2+
on:
3+
pull_request:
4+
push:
45

56
jobs:
6-
php-cs-fixer:
7-
name: PHP-CS-Fixer
8-
runs-on: ubuntu-22.04
9-
steps:
10-
- uses: actions/checkout@master
11-
- name: Setup PHP
12-
uses: shivammathur/setup-php@v2
13-
with:
14-
php-version: '8.2'
15-
extensions: apcu
16-
- name: PHP-CS-Fixer
17-
uses: OskarStark/php-cs-fixer-ga@3.25.0
18-
with:
19-
args: --diff --dry-run --allow-risky yes --stop-on-violation --using-cache=no --path-mode=intersection
20-
21-
phpstan:
22-
name: PHPStan Static Analysis
23-
runs-on: ubuntu-22.04
24-
25-
steps:
26-
- uses: actions/checkout@v4
27-
- name: Setup PHP
28-
uses: shivammathur/setup-php@v2
29-
with:
30-
php-version: '8.2'
31-
extensions: apcu
32-
- name: Composer
33-
run: composer install
34-
- name: phpstan
35-
run: |
36-
./vendor/bin/phpstan analyse --level 6 src
37-
38-
phpunit:
39-
runs-on: ubuntu-22.04
40-
name: Unit tests
41-
42-
services:
43-
db:
44-
image: demostf/db
45-
env:
46-
POSTGRES_PASSWORD: test
47-
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
48-
ports:
49-
- 5432:5432
50-
51-
steps:
52-
- uses: actions/checkout@v4
53-
- name: Setup PHP
54-
uses: shivammathur/setup-php@v2
55-
with:
56-
php-version: '8.2'
57-
extensions: apcu
58-
- name: Composer
59-
run: composer install
60-
- name: PHPUnit Tests
61-
env:
62-
DB_PORT: 5432
63-
DB_TYPE: pgsql
64-
DB_HOST: localhost
65-
DB_USERNAME: postgres
66-
DB_PASSWORD: test
67-
DB_DATABASE: postgres
68-
run: |
69-
php ./vendor/bin/phpunit test
70-
71-
api:
72-
runs-on: ubuntu-22.04
73-
name: Integration tests
74-
75-
services:
76-
db:
77-
image: demostf/db
78-
env:
79-
POSTGRES_PASSWORD: test
80-
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
81-
ports:
82-
- 5432:5432
83-
api:
84-
image: demostf/api
85-
env:
86-
BASE_HOST: localhost
87-
DEMO_ROOT: /tmp
88-
DEMO_HOST: localhost
89-
DB_TYPE: pgsql
90-
DB_HOST: db
91-
DB_PORT: 5432
92-
DB_DATABASE: postgres
93-
DB_USERNAME: postgres
94-
DB_PASSWORD: test
95-
APP_ROOT: https://localhost
96-
EDIT_SECRET: edit
97-
volumes:
98-
- src:/app
99-
nginx:
100-
image: demostf/api-nginx-test
101-
ports:
102-
- 80:80
103-
104-
steps:
105-
- uses: actions/checkout@v4
106-
- name: Setup PHP
107-
uses: shivammathur/setup-php@v2
108-
with:
109-
php-version: '8.2'
110-
extensions: apcu
111-
- name: Composer
112-
run: composer install
113-
- name: copy code
114-
run: |
115-
docker run -v src:/data --name helper busybox true
116-
docker cp src helper:/data/
117-
docker cp vendor helper:/data/
118-
docker rm helper
119-
- env:
120-
DB_URL: postgres://postgres:test@db:5432/postgres
121-
BASE_URL: http://nginx
122-
EDIT_KEY: edit
123-
uses: docker://demostf/api-test
124-
125-
build-parser:
126-
runs-on: ubuntu-latest
127-
strategy:
128-
matrix:
129-
machine:
130-
- platform: x86_64-linux
131-
- platform: aarch64-linux
132-
steps:
133-
- uses: actions/checkout@v4
134-
- if: matrix.machine.platform != 'x86_64-linux'
135-
uses: docker/setup-qemu-action@v3
136-
- uses: cachix/install-nix-action@v26
137-
with:
138-
extra_nix_config: |
139-
extra-platforms = aarch64-linux
140-
- uses: icewind1991/attic-action@v1
141-
with:
142-
name: ci
143-
instance: https://cache.icewind.me
144-
authToken: '${{ secrets.ATTIC_TOKEN }}'
145-
- run: nix build --option system ${{ matrix.machine.platform }} .#demostf-parser
146-
147-
build:
7+
matrix:
1488
runs-on: ubuntu-latest
149-
strategy:
150-
matrix:
151-
machine:
152-
- platform: x86_64-linux
153-
- platform: aarch64-linux
9+
outputs:
10+
matrix: ${{ steps.set-matrix.outputs.matrix }}
15411
steps:
15512
- uses: actions/checkout@v4
156-
- if: matrix.machine.platform != 'x86_64-linux'
157-
uses: docker/setup-qemu-action@v3
158-
- uses: cachix/install-nix-action@v26
159-
with:
160-
extra_nix_config: |
161-
extra-platforms = aarch64-linux
162-
- uses: icewind1991/attic-action@v1
163-
with:
164-
name: ci
165-
instance: https://cache.icewind.me
166-
authToken: '${{ secrets.ATTIC_TOKEN }}'
167-
- run: nix build --option system ${{ matrix.machine.platform }}
168-
13+
- uses: cachix/install-nix-action@v27
14+
- id: set-matrix
15+
run: echo "matrix={\"check\":$(nix eval --json '.#checks.x86_64-linux' --apply 'builtins.attrNames')}" | tee -a $GITHUB_OUTPUT
16916

170-
build-docker:
17+
checks:
17118
runs-on: ubuntu-latest
172-
needs: [build, build-parser]
19+
needs: [matrix]
17320
strategy:
174-
matrix:
175-
machine:
176-
- platform: x86_64-linux
177-
- platform: aarch64-linux
21+
fail-fast: false
22+
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
23+
name: ${{ matrix.check }}
17824
steps:
17925
- uses: actions/checkout@v4
180-
- if: matrix.machine.platform != 'x86_64-linux'
181-
uses: docker/setup-qemu-action@v3
182-
- uses: cachix/install-nix-action@v26
183-
with:
184-
extra_nix_config: |
185-
extra-platforms = aarch64-linux
186-
- uses: icewind1991/attic-action@v1
187-
with:
188-
name: ci
189-
instance: https://cache.icewind.me
190-
authToken: '${{ secrets.ATTIC_TOKEN }}'
191-
- run: nix build --option system ${{ matrix.machine.platform }} .#demostf-api-docker
192-
193-
docker:
194-
runs-on: ubuntu-latest
195-
needs: [build-docker, api, phpunit]
196-
steps:
197-
- name: Checkout code
198-
uses: actions/checkout@v4
19926
- uses: cachix/install-nix-action@v26
20027
- uses: icewind1991/attic-action@v1
20128
with:
20229
name: ci
20330
instance: https://cache.icewind.me
204-
- run: nix run .#dockerManifest
205-
if: github.ref == 'refs/heads/master'
206-
env:
207-
VERSION: "1.0.0"
208-
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
209-
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
31+
authToken: "${{ secrets.ATTIC_TOKEN }}"
32+
- run: nix build .#checks.x86_64-linux.${{ matrix.check }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules
55
*.cache
66
.direnv
77
result
8+
demos

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ composer install
3737

3838
## Deploying
3939

40-
Deploying the api requires php7.1 or later,
40+
Deploying the api requires php7.1 or later,
4141
the webserver needs to be configured to server all requests to `public/index.php` execept
4242
for request to `/upload` which needs to be handled by `public/upload.php`.
4343

composer.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@
33
"description": "api implementation for demos.tf",
44
"license": "MIT",
55
"require": {
6-
"mikecao/flight": "^3.6",
7-
"vlucas/phpdotenv": "^v5.4.1",
8-
"ircmaxell/random-lib": "^v1.2.0",
9-
"ehesp/steam-login": "^1.2",
10-
"koraktor/steam-condenser": "dev-master#92dde9e3b462e93cc498fe795a712c61eec7051e",
11-
"doctrine/dbal": "^3.3.6",
12-
"ext-pdo": "*",
13-
"ext-json": "*",
14-
"ext-apcu": "*"
6+
"mikecao/flight": "^3.6",
7+
"vlucas/phpdotenv": "^v5.4.1",
8+
"ircmaxell/random-lib": "^v1.2.0",
9+
"ehesp/steam-login": "^1.2",
10+
"koraktor/steam-condenser": "dev-master#92dde9e3b462e93cc498fe795a712c61eec7051e",
11+
"doctrine/dbal": "^3.3.6",
12+
"ext-pdo": "*",
13+
"ext-json": "*",
14+
"ext-apcu": "*"
1515
},
1616
"repositories": [
17-
{
18-
"type": "vcs",
19-
"url": "https://github.com/koraktor/steam-condenser-php"
20-
}
17+
{
18+
"type": "vcs",
19+
"url": "https://github.com/koraktor/steam-condenser-php"
20+
}
2121
],
2222
"autoload": {
23-
"psr-4": {
24-
"Demostf\\API\\": "src/",
25-
"Demostf\\API\\Test\\": "test/"
26-
}
23+
"psr-4": {
24+
"Demostf\\API\\": "src/",
25+
"Demostf\\API\\Test\\": "test/"
26+
}
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "^9.5.20",
30-
"friendsofphp/php-cs-fixer": "^v3.3.0",
31-
"phpstan/phpstan": "^1.6.8"
29+
"phpunit/phpunit": "^9.5.20",
30+
"friendsofphp/php-cs-fixer": "^v3.3.0",
31+
"phpstan/phpstan": "^1.6.8"
3232
},
3333
"config": {
3434
"allow-plugins": {

docker.nix

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)