]> 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 pull_request:
12
13 jobs:
14 lint:
15 runs-on: ubuntu-latest
16 name: "Lint on PHP ${{ matrix.php-versions }}"
17
18 strategy:
19 fail-fast: false
20 matrix:
21 php-versions: [ '8.1', '8.2' ]
22
23 steps:
24 - name: PHP
25 uses: shivammathur/setup-php@v2
26 with:
27 php-version: ${{ matrix.php-versions }}
28 tools: composer, pecl
29 coverage: ${{ matrix.coverage }}
30 extensions: apcu
31 ini-values: apc.enable_cli=1
32
33 - name: "Show versions"
34 run: |
35 php --version
36 composer --version
37
38 - name: Checkout
39 uses: actions/checkout@v3
40 with:
41 fetch-depth: 2
42
43 - name: Get composer cache directory
44 id: composer-cache
45 run: |
46 echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
47
48 - name: Cache dependencies
49 uses: actions/cache@v3
50 with:
51 path: ${{ steps.composer-cache.outputs.dir }}
52 key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
53 restore-keys: ${{ runner.os }}-composer-
54
55 - name: Install dependencies
56 run: |
57 cd galette
58 composer install
59
60 - name: CS
61 run: |
62 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/
63
64 - name: Twig CS
65 run: |
66 galette/vendor/bin/twigcs galette/templates/default --severity error --display blocking
67
68 - name: Install checker
69 working-directory: galette
70 run: composer require maglnet/composer-require-checker -W
71
72 - name: Check missing symbols
73 run: |
74 galette/vendor/bin/composer-require-checker check --config-file=.composer-require-checker.config.json galette/composer.json
75
76 - name: PHPStan checks
77 run: |
78 galette/vendor/bin/phpstan analyze --ansi --memory-limit=2G --no-interaction --no-progress
79
80 unit-tests:
81 runs-on: ubuntu-latest
82
83 strategy:
84 matrix:
85 php-versions: [ '8.1', '8.2' ]
86 coverage: ['none']
87 db-image: ['mysql:8.0', 'mariadb:10.11', 'mariadb:11', 'postgres:12', 'postgres:15']
88 include:
89 - php-versions: '8.2'
90 coverage: 'xdebug'
91 db-image: 'postgres:15'
92 fail-fast: false
93
94 env:
95 DB: ${{ matrix.db-image }}
96
97 services:
98 # Label used to access the service container
99 db:
100 # Docker Hub image
101 image: ${{ matrix.db-image }}
102 # Provide env variables for both mysql and pgsql
103 env:
104 POSTGRES_USER: galette_tests
105 POSTGRES_PASSWORD: g@l3tte
106 POSTGRES_DB: galette_tests
107 MYSQL_USER: galette_tests
108 MYSQL_PASSWORD: g@l3tte
109 MYSQL_ROOT_PASSWORD: g@l3tte
110 MYSQL_DATABASE: galette_tests
111 # Open network ports for both mysql and pgsql
112 ports:
113 - 3306:3306
114 - 5432:5432
115 # Set health checks to wait until postgres has started
116 options: >-
117 --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'"
118 --health-interval=10s
119 --health-timeout=5s
120 --health-retries=10
121
122 name: PHP ${{ matrix.php-versions }} ${{ matrix.db-image }}
123
124 steps:
125 - name: PHP
126 uses: shivammathur/setup-php@v2
127 with:
128 php-version: ${{ matrix.php-versions }}
129 tools: composer, pecl
130 coverage: ${{ matrix.coverage }}
131 extensions: apcu
132 ini-values: apc.enable_cli=1
133
134 - name: "Show versions"
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 uses: actions/checkout@v3
144 with:
145 fetch-depth: 2
146
147 - name: Get composer cache directory
148 id: composer-cache
149 run: |
150 echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
151
152 - name: Cache dependencies
153 uses: actions/cache@v3
154 with:
155 path: ${{ steps.composer-cache.outputs.dir }}
156 key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
157 restore-keys: ${{ runner.os }}-composer-
158
159 - name: Install dependencies
160 run: bin/install_deps
161
162 - name: Init for PostgreSQL (update)
163 env:
164 POSTGRES_HOST: localhost
165 POSTGRES_PORT: 5432
166 run: |
167 PGPASSWORD=g@l3tte psql -d galette_tests -a -f tests/pgsql_06.sql -U galette_tests -h localhost
168 if: startsWith(matrix.db-image, 'postgres')
169
170 - name: Init for MariaDB (update)
171 run: |
172 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
173 mysql -e 'use galette_tests; source tests/mysql_06.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
174 if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
175
176 - name: Update database tests
177 run: UPDATE=UPDATE galette/vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --no-coverage --process-isolation tests/GaletteUpdate/
178 if: matrix.coverage != 'xdebug'
179
180 - name: Init for PostgreSQL
181 env:
182 POSTGRES_HOST: localhost
183 POSTGRES_PORT: 5432
184 run: |
185 PGPASSWORD=g@l3tte psql -d galette_tests -a -f galette/install/scripts/pgsql.sql -U galette_tests -h localhost
186 if: startsWith(matrix.db-image, 'postgres')
187
188 - name: Init for MariaDB
189 run: |
190 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
191 mysql -e 'use galette_tests; source galette/install/scripts/mysql.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
192 if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
193
194 - name: Unit tests
195 run: galette/vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --no-coverage --process-isolation tests/Galette/
196 if: matrix.coverage != 'xdebug'
197
198 - name: Unit tests (with coverage)
199 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/
200 if: matrix.coverage == 'xdebug'
201
202 - name: Upload code coverage (scrutinizer)
203 run: |
204 cd galette
205 composer require scrutinizer/ocular
206 cd ..
207 php galette/vendor/bin/ocular code-coverage:upload --format=php-clover tests/clover.xml
208 if: matrix.coverage == 'xdebug'
209
210 - name: Upload code coverage (codecov)
211 uses: codecov/codecov-action@v3
212 with:
213 file: tests/clover.xml
214 if: matrix.coverage == 'xdebug'