]> git.agnieray.net Git - galette.git/blob - .github/workflows/ci-linux.yml
Rework CI matrix
[galette.git] / .github / workflows / ci-linux.yml
1 name: Galette CI
2
3 on:
4 push:
5 branches:
6 - master
7 - develop
8 - 'feature/*'
9 - 'hotfix/*'
10 - 'release/*'
11 tags:
12 - '*'
13 pull_request:
14 # Enable manual run
15 workflow_dispatch:
16
17 jobs:
18 lint:
19 runs-on: ubuntu-latest
20 name: "Lint on PHP ${{ matrix.php-versions }}"
21
22 strategy:
23 fail-fast: false
24 matrix:
25 php-versions: [ '8.1', '8.2', '8.3-rc' ]
26
27 steps:
28 - name: PHP
29 uses: shivammathur/setup-php@v2
30 with:
31 php-version: ${{ matrix.php-versions }}
32 tools: composer, pecl
33 coverage: ${{ matrix.coverage }}
34 extensions: apcu
35 ini-values: apc.enable_cli=1
36
37 - name: "Show versions"
38 run: |
39 php --version
40 composer --version
41
42 - name: Checkout
43 uses: actions/checkout@v3
44 with:
45 fetch-depth: 2
46
47 - name: "Restore dependencies cache"
48 uses: actions/cache@v3
49 with:
50 path: |
51 ~/.composer/cache/
52 ~/.npm/_cacache/
53 key: "${{ runner.os }}-galette-${{ matrix.php-version }}-${{ hashFiles('galette/composer.lock', 'package-lock.json') }}"
54 restore-keys: |
55 ${{ runner.os }}-galette-${{ matrix.php-version }}-
56
57 - name: Install dependencies
58 run: |
59 cd galette
60 composer install --optimize-autoloader --ignore-platform-reqs
61
62 - name: CS
63 run: |
64 galette/vendor/bin/phpcs -n -p --ignore=galette_tcpdf_config.php --standard=phpcs-rules.xml galette/lib/ tests/TestsBootstrap.php tests/Galette tests/plugins galette/webroot/index.php galette/includes/
65
66 - name: Twig CS
67 run: |
68 galette/vendor/bin/twigcs galette/templates/default --severity error --display blocking
69
70 - name: Install checker
71 working-directory: galette
72 run: composer require maglnet/composer-require-checker -W --optimize-autoloader --ignore-platform-reqs
73
74 - name: Check missing symbols
75 run: |
76 galette/vendor/bin/composer-require-checker check --config-file=.composer-require-checker.config.json galette/composer.json
77
78 - name: PHPStan checks
79 run: |
80 galette/vendor/bin/phpstan analyze --ansi --memory-limit=2G --no-interaction --no-progress
81
82 unsupported-dbs:
83 runs-on: ubuntu-latest
84 name: DB Fail on ${{ matrix.php-versions }} ${{ matrix.db-image }} ${{ (matrix.always == false && (github.event_name == 'pull_request' || github.repository != 'galette/galette' || !(github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags')))) && ' (skipped)' || ''}}
85
86 strategy:
87 matrix:
88 include:
89 - { php-version: "8.2", db-image: "mysql:5.6", always: false}
90 - { php-version: "8.2", db-image: "mariadb:10.3", always: false}
91 - { php-version: "8.2", db-image: "postgres:10", always: true}
92 fail-fast: false
93
94 env:
95 skip: ${{ matrix.always == false && (github.event_name == 'pull_request' || !(github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))) }}
96 DB: ${{ matrix.db-image }}
97
98 services:
99 # Label used to access the service container
100 db:
101 # Docker Hub image
102 image: ${{ matrix.db-image }}
103 # Provide env variables for both mysql and pgsql
104 env:
105 POSTGRES_USER: galette_tests
106 POSTGRES_PASSWORD: g@l3tte
107 POSTGRES_DB: galette_fail_tests
108 MYSQL_USER: galette_tests
109 MYSQL_PASSWORD: g@l3tte
110 MYSQL_ROOT_PASSWORD: g@l3tte
111 MYSQL_DATABASE: galette_fail_tests
112 # Open network ports for both mysql and pgsql
113 ports:
114 - 3306:3306
115 - 5432:5432
116 # Set health checks to wait until postgres has started
117 options: >-
118 --health-cmd="bash -c 'if [[ -n $(command -v pg_isready) ]]; then pg_isready; else if [[ -n $(command -v mysqladmin) ]]; then mysqladmin ping; else mariadb-admin ping; fi fi'"
119 --health-interval=10s
120 --health-timeout=5s
121 --health-retries=10
122
123 steps:
124 - name: PHP
125 if: env.skip != 'true'
126 uses: shivammathur/setup-php@v2
127 with:
128 php-version: ${{ matrix.php-versions }}
129 tools: composer, pecl
130 extensions: apcu
131 ini-values: apc.enable_cli=1
132
133 - name: "Show versions"
134 if: env.skip != 'true'
135 run: |
136 php --version
137 composer --version
138 echo "node $(node --version)"
139 echo "npm $(npm --version)"
140 docker exec ${{ job.services.db.id }} bash -c "if [[ -n \$(command -v psql) ]]; then psql --version; else if [[ -n \$(command -v mysql) ]]; then mysql --version; else mariadb --version; fi fi"
141
142 - name: Checkout
143 if: env.skip != 'true'
144 uses: actions/checkout@v3
145 with:
146 fetch-depth: 2
147
148 - name: "Restore dependencies cache"
149 if: env.skip != 'true'
150 uses: actions/cache@v3
151 with:
152 path: |
153 ~/.composer/cache/
154 ~/.npm/_cacache/
155 key: "${{ runner.os }}-galette-${{ matrix.php-version }}-${{ hashFiles('galette/composer.lock', 'package-lock.json') }}"
156 restore-keys: |
157 ${{ runner.os }}-galette-${{ matrix.php-version }}-
158
159 - name: Install dependencies
160 if: env.skip != 'true'
161 run: bin/install_deps
162
163 - name: Init for PostgreSQL (update)
164 env:
165 POSTGRES_HOST: localhost
166 POSTGRES_PORT: 5432
167 run: |
168 PGPASSWORD=g@l3tte psql -d galette_fail_tests -a -f galette/install/scripts/pgsql.sql -U galette_tests -h localhost
169 if: env.skip != 'true' && startsWith(matrix.db-image, 'postgres')
170
171 - name: Init for MariaDB (update)
172 run: |
173 mysql -e 'create database IF NOT EXISTS galette_fail_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
174 mysql -e 'use galette_fail_tests; source galette/install/scripts/mysql.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
175 if: env.skip != 'true' && (startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb'))
176
177 - name: Fail database tests
178 if: env.skip != 'true'
179 run: FAIL=FAIL DB=${{ matrix.db-image }} galette/vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --no-coverage --process-isolation tests/GaletteDbFails/
180
181 unit-tests:
182 runs-on: ubuntu-latest
183
184 strategy:
185 matrix:
186 include:
187 #always tests higher stable php version with lower db version
188 #enable coverage on higher stable php version with higher postrgesql version
189 #lower php version
190 - { php-version: "8.1", db-image: "mysql:5.7", coverage: none, always: false }
191 - { php-version: "8.1", db-image: "mysql:8.1", coverage: none, always: false }
192 - { php-version: "8.1", db-image: "mariadb:10.4", coverage: none, always: false }
193 - { php-version: "8.1", db-image: "mariadb:11", coverage: none, always: false }
194 - { php-version: "8.1", db-image: "postgres:11", coverage: none, always: false }
195 - { php-version: "8.1", db-image: "postgres:16", coverage: none, always: false }
196 #higher stable php version
197 - { php-version: "8.2", db-image: "mysql:5.7", coverage: none, always: true}
198 - { php-version: "8.2", db-image: "mysql:8.1", coverage: none, always: false }
199 - { php-version: "8.2", db-image: "mariadb:10.4", coverage: none, always: true}
200 - { php-version: "8.2", db-image: "mariadb:11", coverage: none, always: false }
201 - { php-version: "8.2", db-image: "postgres:11", coverage: none, always: true}
202 - { php-version: "8.2", db-image: "postgres:16", coverage: 'xdebug', always: true }
203 #unstable php version
204 - { php-version: "8.3-rc", db-image: "mysql:5.7", coverage: none, always: false }
205 - { php-version: "8.3-rc", db-image: "mysql:8.1", coverage: none, always: false }
206 - { php-version: "8.3-rc", db-image: "mariadb:10.4", coverage: none, always: false }
207 - { php-version: "8.3-rc", db-image: "mariadb:11", coverage: none, always: false }
208 - { php-version: "8.3-rc", db-image: "postgres:11", coverage: none, always: false }
209 - { php-version: "8.3-rc", db-image: "postgres:16", coverage: none, always: false }
210 fail-fast: false
211
212 env:
213 skip: ${{ matrix.always == false && (github.event_name == 'pull_request' || github.repository != 'galette/galette' || !(github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))) }}
214 DB: ${{ matrix.db-image }}
215
216 services:
217 # Label used to access the service container
218 db:
219 # Docker Hub image
220 image: ${{ matrix.db-image }}
221 # Provide env variables for both mysql and pgsql
222 env:
223 POSTGRES_USER: galette_tests
224 POSTGRES_PASSWORD: g@l3tte
225 POSTGRES_DB: galette_tests
226 MYSQL_USER: galette_tests
227 MYSQL_PASSWORD: g@l3tte
228 MYSQL_ROOT_PASSWORD: g@l3tte
229 MYSQL_DATABASE: galette_tests
230 # Open network ports for both mysql and pgsql
231 ports:
232 - 3306:3306
233 - 5432:5432
234 # Set health checks to wait until postgres has started
235 options: >-
236 --health-cmd="bash -c 'if [[ -n $(command -v pg_isready) ]]; then pg_isready; else if [[ -n $(command -v mysqladmin) ]]; then mysqladmin ping; else mariadb-admin ping; fi fi'"
237 --health-interval=10s
238 --health-timeout=5s
239 --health-retries=10
240
241 name: PHP ${{ matrix.php-version }} ${{ matrix.db-image }} ${{ (matrix.always == false && (github.event_name == 'pull_request' || github.repository != 'galette/galette' || !(github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags')))) && ' (skipped)' || matrix.coverage == 'xdebug' && ' (with coverage)' || ''}}
242
243 steps:
244 - name: PHP
245 if: env.skip != 'true'
246 uses: shivammathur/setup-php@v2
247 with:
248 php-version: ${{ matrix.php-versions }}
249 tools: composer, pecl
250 coverage: ${{ matrix.coverage }}
251 extensions: apcu
252 ini-values: apc.enable_cli=1
253
254 - name: "Show versions"
255 if: env.skip != 'true'
256 run: |
257 php --version
258 composer --version
259 echo "node $(node --version)"
260 echo "npm $(npm --version)"
261 docker exec ${{ job.services.db.id }} bash -c "if [[ -n \$(command -v psql) ]]; then psql --version; else if [[ -n \$(command -v mysql) ]]; then mysql --version; else mariadb --version; fi fi"
262
263 - name: Checkout
264 if: env.skip != 'true'
265 uses: actions/checkout@v3
266 with:
267 fetch-depth: 2
268
269 - name: "Restore dependencies cache"
270 if: env.skip != 'true'
271 uses: actions/cache@v3
272 with:
273 path: |
274 ~/.composer/cache/
275 ~/.npm/_cacache/
276 key: "${{ runner.os }}-galette-${{ matrix.php-version }}-${{ hashFiles('galette/composer.lock', 'package-lock.json') }}"
277 restore-keys: |
278 ${{ runner.os }}-galette-${{ matrix.php-version }}-
279
280 - name: Install dependencies
281 if: env.skip != 'true'
282 run: bin/install_deps
283
284 - name: Init for PostgreSQL (update)
285 env:
286 POSTGRES_HOST: localhost
287 POSTGRES_PORT: 5432
288 run: |
289 PGPASSWORD=g@l3tte psql -d galette_tests -a -f tests/pgsql_06.sql -U galette_tests -h localhost
290 if: env.skip != 'true' && startsWith(matrix.db-image, 'postgres')
291
292 - name: Init for MariaDB (update)
293 run: |
294 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
295 mysql -e 'use galette_tests; source tests/mysql_06.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
296 if: env.skip != 'true' && (startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb'))
297
298 - name: Update database tests
299 run: UPDATE=UPDATE galette/vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --no-coverage --process-isolation tests/GaletteUpdate/
300 if: env.skip != 'true' && matrix.coverage != 'xdebug'
301
302 - name: Init for PostgreSQL
303 env:
304 POSTGRES_HOST: localhost
305 POSTGRES_PORT: 5432
306 run: |
307 PGPASSWORD=g@l3tte psql -d galette_tests -a -f galette/install/scripts/pgsql.sql -U galette_tests -h localhost
308 if: env.skip != 'true' && startsWith(matrix.db-image, 'postgres')
309
310 - name: Init for MariaDB
311 run: |
312 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
313 mysql -e 'use galette_tests; source galette/install/scripts/mysql.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
314 if: env.skip != 'true' && (startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb'))
315
316 - name: Unit tests
317 run: galette/vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --no-coverage --process-isolation tests/Galette/
318 if: env.skip != 'true' && matrix.coverage != 'xdebug'
319
320 - name: Unit tests (with coverage)
321 run: galette/vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --process-isolation --coverage-filter galette/lib --coverage-clover tests/clover.xml tests/Galette/
322 if: env.skip != 'true' && matrix.coverage == 'xdebug'
323
324 - name: Upload code coverage (scrutinizer)
325 run: |
326 cd galette
327 composer require scrutinizer/ocular
328 cd ..
329 php galette/vendor/bin/ocular code-coverage:upload --format=php-clover tests/clover.xml
330 if: env.skip != 'true' && matrix.coverage == 'xdebug'
331
332 - name: Upload code coverage (codecov)
333 uses: codecov/codecov-action@v3
334 with:
335 file: tests/clover.xml
336 if: env.skip != 'true' && matrix.coverage == 'xdebug'