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