|
1 | | -on: [push, pull_request] |
2 | | - |
3 | | -name: CI |
| 1 | +name: "CI" |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + push: |
4 | 5 |
|
5 | 6 | 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: |
148 | 8 | 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 }} |
154 | 11 | steps: |
155 | 12 | - 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 |
169 | 16 |
|
170 | | - build-docker: |
| 17 | + checks: |
171 | 18 | runs-on: ubuntu-latest |
172 | | - needs: [build, build-parser] |
| 19 | + needs: [matrix] |
173 | 20 | 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 }} |
178 | 24 | steps: |
179 | 25 | - 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 |
199 | 26 | - uses: cachix/install-nix-action@v26 |
200 | 27 | - uses: icewind1991/attic-action@v1 |
201 | 28 | with: |
202 | 29 | name: ci |
203 | 30 | 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 }} |
0 commit comments