Skip to content

Commit 155614b

Browse files
committed
Improve CI
1 parent ad55687 commit 155614b

File tree

1 file changed

+146
-74
lines changed

1 file changed

+146
-74
lines changed

.github/workflows/reusable-CI-workflow.yml

Lines changed: 146 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,86 +2,133 @@ name: 'CI reusable workflow'
22

33
on:
44
workflow_call:
5+
inputs:
6+
# >>>> Dummy env-inputs
7+
# Goal here is just to have access to variable values
8+
# in order to build job matrix as `env` variable is not available there
9+
php-min-version:
10+
default: '8.0'
11+
description: Lowest PHP version to assess (e.g Lowest supported version including security support)
12+
required: false
13+
type: string
14+
php-max-version:
15+
default: '8.2'
16+
description: Highest PHP version to assess (e.g Latest supported version)
17+
required: false
18+
type: string
19+
php-next-version:
20+
default: '8.3'
21+
description: Next (currently not supported) PHP version to assess (e.g Current dev version)
22+
required: false
23+
type: string
24+
symfony-min-version:
25+
default: '4.4'
26+
description: Lowest Symfony version to assess (e.g Lowest supported version including security support)
27+
required: false
28+
type: string
29+
symfony-max-version:
30+
default: '6.0'
31+
description: Highest Symfony version to assess (e.g Latest supported version)
32+
required: false
33+
type: string
34+
symfony-next-version:
35+
default: '6.3'
36+
description: Next (currently not supported) Symfony version to assess (e.g Current dev version)
37+
required: false
38+
type: string
39+
# <<<< Dummy env-inputs
540

641
env:
742
TEST_OUTPUT_STYLE: pretty
843
COMPOSER_OPTIONS: --optimize-autoloader
944

1045
jobs:
1146
tests:
12-
name: PHP ${{ matrix.php-version }} & Symfony ${{ matrix.symfony-version }}
47+
name: PHP ${{ matrix.php-version }}${{ matrix.php-prefer-latest && ' (latest)' || '' }} & Symfony ${{ matrix.symfony-version }}${{ matrix.composer-prefer-lowest && ' (lowest)' || '' }}
1348
runs-on: ubuntu-latest
1449
env:
1550
COVERAGE_TYPE: none
51+
COVERAGE_OUTPUT_STYLE: clover
1652
strategy:
1753
fail-fast: true
1854
max-parallel: 4
1955
matrix:
2056
include:
2157
# Bare minimum => Lowest versions allowed by composer config
22-
- symfony-version: '4.4'
23-
php-version: '8.0'
24-
composer-flag: --prefer-lowest
58+
- php-version: '${{ inputs.php-min-version }}'
59+
php-prefer-latest: false
60+
symfony-version: '${{ inputs.symfony-min-version }}'
61+
composer-prefer-lowest: true
2562
# Up to date versions => Latest versions allowed by composer config
26-
- symfony-version: '5.4'
27-
php-version: '8.2'
28-
# Late symfony migration => Lowest symfony version with latest minor php version allowed by composer config
29-
- symfony-version: '4.4'
30-
php-version: '8.2'
31-
composer-flag: --prefer-lowest
32-
# Late php migration => Latest symfony version with lowest minor php version allowed by composer config
33-
- symfony-version: '5.4'
34-
php-version: '8.0'
35-
# Symfony 6.0 latest
36-
- symfony-version: '6.0'
37-
php-version: '8.2'
38-
# Symfony 6.0 lowest
39-
- symfony-version: '6.0'
40-
php-version: '8.0'
41-
composer-flag: --prefer-lowest
63+
- php-version: '${{ inputs.php-max-version }}'
64+
php-prefer-latest: true
65+
symfony-version: '${{ inputs.symfony-max-version }}'
66+
composer-prefer-lowest: false
67+
# Late symfony migration => Lowest symfony version with latest php version allowed by composer config
68+
- php-version: '${{ inputs.php-max-version }}'
69+
php-prefer-latest: true
70+
symfony-version: '${{ inputs.symfony-min-version }}'
71+
composer-prefer-lowest: true
72+
# Late php migration => Latest symfony version with lowest php version allowed by composer config
73+
- php-version: '${{ inputs.php-min-version }}'
74+
php-prefer-latest: false
75+
symfony-version: '${{ inputs.symfony-max-version }}'
76+
composer-prefer-lowest: false
77+
# Bare minimum on latest versions => Lowest latest versions allowed by composer config
78+
- php-version: '${{ inputs.php-max-version }}'
79+
php-prefer-latest: false
80+
symfony-version: '${{ inputs.symfony-max-version }}'
81+
composer-prefer-lowest: true
82+
# Up to date bare minimum => Latest lowest versions allowed by composer config
83+
- php-version: '${{ inputs.php-min-version }}'
84+
php-prefer-latest: true
85+
symfony-version: '${{ inputs.symfony-min-version }}'
86+
composer-prefer-lowest: false
4287
steps:
4388
- name: Check out code
4489
uses: actions/checkout@v4
4590

91+
# Enable coverage only for specific version(s) !
92+
# Usually latest version(s), plus additional ones in case of code used only with specific versions
4693
- name: Enable coverage
47-
if: ${{ matrix.php-version == '8.2' }}
94+
if: ${{ matrix.php-version == inputs.php-max-version }}
4895
run: |
49-
echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV
5096
echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV
5197
5298
- name: Setup PHP ${{ matrix.php-version }}
99+
id: setup-php
53100
uses: shivammathur/setup-php@v2
54101
env:
55-
update: true # Always use latest available patch for the version
102+
update: ${{ matrix.php-prefer-latest }} # whether to use latest available patch for the version or not
56103
fail-fast: true # step will fail if an extension or tool fails to set up
57104
with:
58-
php-version: '${{ matrix.php-version }}'
105+
php-version: ${{ matrix.php-version }}${{ matrix.php-prefer-latest && '' || '.0' }}
59106
tools: composer
60107
coverage: ${{ env.COVERAGE_TYPE }}
61108

62-
- name: Setup cache
109+
- name: Setup cache for PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ matrix.symfony-version }}
63110
id: cache
64111
uses: actions/cache@v4
65112
with:
66113
path: |
67114
~/.composer
68115
./vendor
69116
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
70-
key: tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }}
117+
key: tests-php${{ steps.setup-php.outputs.php-version }}-sf${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }}
71118

72-
- name: Build
119+
- name: Build with PHP ${{ matrix.php-version }}${{ matrix.php-prefer-latest && ' (latest)' || '' }} & Symfony ${{ matrix.symfony-version }}${{ matrix.composer-prefer-lowest && ' (lowest)' || '' }}
73120
run: |
74121
SF_VERSION=${{ matrix.symfony-version }}
75122
# Issue with ParamterBag below 4.4.30 => https://github.com/symfony/symfony/commit/3eca446b21607ea1c7a865ece2dd8254c33679cc
76-
test '${{ matrix.symfony-version }}' = '4.4' && test '${{ matrix.php-version }}' = '8.2' && SF_VERSION=4.4.30
77-
composer require -W ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-flag }} \
78-
symfony/http-foundation:^$SF_VERSION \
79-
symfony/http-kernel:^$SF_VERSION \
80-
symfony/config:^$SF_VERSION \
81-
symfony/dependency-injection:^$SF_VERSION \
82-
symfony/event-dispatcher:^$SF_VERSION \
83-
symfony/routing:^$SF_VERSION \
84-
&& composer update ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-flag }} \
123+
test '${{ matrix.symfony-version }}' = '4.4' && test '${{ matrix.php-version }}' = '8.2' && SF_VERSION=4.4.30 || SF_VERSION=$SF_VERSION".0"
124+
composer require -W ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-prefer-lowest && '--prefer-lowest' || '' }} \
125+
"symfony/http-foundation:~"$SF_VERSION \
126+
"symfony/http-kernel:~"$SF_VERSION \
127+
"symfony/config:~"$SF_VERSION \
128+
"symfony/dependency-injection:~"$SF_VERSION \
129+
"symfony/event-dispatcher:~"$SF_VERSION \
130+
"symfony/routing:~"$SF_VERSION \
131+
&& composer update ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-prefer-lowest && '--prefer-lowest' || '' }} \
85132
&& make build
86133
87134
- name: Tests
@@ -97,8 +144,8 @@ jobs:
97144
files: build/coverage-phpunit/unit.clover
98145
flags: |
99146
unit-tests
100-
php-${{ matrix.php-version }}
101-
sf-${{ matrix.symfony-version }}
147+
php-${{ steps.setup-php.outputs.php-version }}
148+
sf-${{ matrix.symfony-version }}${{ matrix.composer-prefer-lowest && '@lowest' || '' }}
102149
path: build/coverage-groups
103150

104151
- name: Create "functional tests" reports group
@@ -113,47 +160,57 @@ jobs:
113160
build/coverage-behat/clover.xml
114161
flags: |
115162
functional-tests
116-
php-${{ matrix.php-version }}
117-
sf-${{ matrix.symfony-version }}
163+
php-${{ steps.setup-php.outputs.php-version }}
164+
sf-${{ matrix.symfony-version }}${{ matrix.composer-prefer-lowest && '@lowest' || '' }}
118165
path: build/coverage-groups
119166

120167
- name: Upload coverage reports
121168
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
122169
uses: actions/upload-artifact@v4
123170
with:
124-
name: coverage-groups-php${{ matrix.php-version }}-sf${{ matrix.symfony-version }}
171+
name: coverage-groups-php${{ matrix.php-version }}${{ matrix.php-prefer-latest && '@latest' || '' }}-sf${{ matrix.symfony-version }}${{ matrix.composer-prefer-lowest && '@lowest' || '' }}
125172
path: build/coverage-groups
126173
if-no-files-found: error
127174

128175
static-checks:
129176
name: Static analysis
130177
runs-on: ubuntu-latest
131178
env:
132-
SC_PHP_VERSION: 8.2 # Latest supported
179+
PHP_VERSION: ${{ inputs.php-max-version }}
180+
SYMFONY_VERSION: ${{ inputs.symfony-max-version }}
133181
steps:
134182
- uses: actions/checkout@v4
135183

136-
- name: Setup PHP ${{ env.SC_PHP_VERSION }}
184+
- name: Setup PHP ${{ env.PHP_VERSION }}
185+
id: setup-php
137186
uses: shivammathur/setup-php@v2
187+
env:
188+
update: true # Always use latest available patch for the version
189+
fail-fast: true # step will fail if an extension or tool fails to set up
138190
with:
139-
php-version: ${{ env.SC_PHP_VERSION }}
191+
php-version: ${{ env.PHP_VERSION }}
140192
tools: composer
141193
coverage: none
142-
env:
143-
# Always use latest available patch for the version
144-
update: true
145194

146-
- name: Setup cache
195+
- name: Setup cache for PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ env.SYMFONY_VERSION }}
147196
id: cache
148197
uses: actions/cache@v4
149198
with:
150199
path: |
151200
~/.composer
152201
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
153-
key: tests-${{ env.SC_PHP_VERSION }}-${{ hashFiles('composer.json') }}
202+
key: tests-php${{ steps.setup-php.outputs.php-version }}-sf${{ env.SYMFONY_VERSION }}-${{ hashFiles('composer.json') }}
154203

155-
- name: Build
156-
run: make build
204+
- name: Build with PHP ${{ steps.setup-php.outputs.php-version }} (latest) & Symfony ${{ env.SYMFONY_VERSION }}
205+
run: |
206+
composer require -W ${{ env.COMPOSER_OPTIONS }} \
207+
symfony/http-foundation:~${{ env.SYMFONY_VERSION }}.0 \
208+
symfony/http-kernel:~${{ env.SYMFONY_VERSION }}.0 \
209+
symfony/config:~${{ env.SYMFONY_VERSION }}.0 \
210+
symfony/dependency-injection:~${{ env.SYMFONY_VERSION }}.0 \
211+
symfony/event-dispatcher:~${{ env.SYMFONY_VERSION }}.0 \
212+
symfony/routing:~${{ env.SYMFONY_VERSION }}.0 \
213+
&& make build
157214
158215
- name: ComposerRequireChecker
159216
uses: docker://webfactory/composer-require-checker:4.5.0
@@ -163,65 +220,80 @@ jobs:
163220
uses: actions/dependency-review-action@v4
164221

165222
nightly-tests:
166-
name: Nightly - PHP ${{ matrix.php-version }} & Symfony ${{ matrix.symfony-version }}
223+
name: Nightly - PHP ${{ matrix.php-version }}${{ matrix.php-prefer-latest && ' (latest)' || '' }} & Symfony ${{ matrix.symfony-version }}${{ matrix.composer-prefer-lowest && ' (lowest)' || '' }}
167224
runs-on: ubuntu-latest
168225
env:
169-
COMPOSER_OPTIONS: '--optimize-autoloader --prefer-dist --ignore-platform-req=php+'
226+
COMPOSER_OPTIONS: '--optimize-autoloader --prefer-dist'
227+
COMPOSER_PREFER_STABLE: '1'
228+
COMPOSER_IGNORE_PLATFORM_REQ: 'php+'
170229
continue-on-error: true
171-
needs: [ static-checks, tests ]
230+
needs: [ tests ]
172231
strategy:
173232
fail-fast: false
174233
max-parallel: 4
175234
matrix:
176-
php-version:
177-
- '8.3' # Current php dev version
178-
symfony-version:
179-
- '4.4' # Lowest LTS
180-
- '5.4' # Latest LTS
181-
- '6.0' # Current major version
182235
include:
183-
- symfony-version: '6.3' # Next symfony minor version to manage with latest supported PHP version
184-
php-version: '8.2'
185-
- symfony-version: '4.4' # Fix to avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317)
186-
php-version: '8.3'
187-
pkg-extra-constraints: 'behat/gherkin:~4.12.0'
236+
# PHP upgrade - With lowest dependencies versions => Lowest supported symfony version against next php version
237+
- php-version: ${{ inputs.php-next-version }}
238+
php-prefer-latest: true
239+
symfony-version: ${{ inputs.symfony-min-version }}
240+
composer-prefer-lowest: true
241+
# Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317)
242+
# Fix - matthiasnoback/symfony-config-test => Avoid issue with phpunit <-> symfony-config-test packages
243+
pkg-extra-constraints: behat/gherkin:~4.12.0 matthiasnoback/symfony-config-test:^4.3
244+
# PHP upgrade - With highest dependencies versions => Highest supported symfony version against next php version
245+
- php-version: ${{ inputs.php-next-version }}
246+
php-prefer-latest: true
247+
symfony-version: ${{ inputs.symfony-max-version }}
248+
composer-prefer-lowest: false
249+
# Symfony upgrade - With lowest php version => Next symfony version against lowest supported PHP version
250+
- php-version: ${{ inputs.php-min-version > 8.1 && inputs.php-min-version || '8.1' }} # Fix - Sf 6.3 (current next) require php 8.1 minimum !
251+
php-prefer-latest: false
252+
symfony-version: ${{ inputs.symfony-next-version }}
253+
composer-prefer-lowest: false
254+
# Symfony upgrade - With highest php version => Next symfony version against highest supported PHP version
255+
- php-version: ${{ inputs.php-max-version }}
256+
php-prefer-latest: true
257+
symfony-version: ${{ inputs.symfony-next-version }}
258+
composer-prefer-lowest: false
188259

189260
steps:
190261
- name: Check out code
191262
uses: actions/checkout@v4
192263

193264
- name: Setup PHP ${{ matrix.php-version }}
265+
id: setup-php
194266
uses: shivammathur/setup-php@v2
267+
env:
268+
update: ${{ matrix.php-prefer-latest }} # whether to use latest available patch for the version or not
269+
fail-fast: true # step will fail if an extension or tool fails to set up
195270
with:
196-
php-version: '${{ matrix.php-version }}'
271+
php-version: ${{ matrix.php-version }}${{ matrix.php-prefer-latest && '' || '.0' }}
197272
tools: composer
198273
coverage: none
199-
env:
200-
# Always use latest available patch for the version
201-
update: true
202274

203-
- name: Setup cache
275+
- name: Setup cache for PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ matrix.symfony-version }}
204276
id: cache
205277
uses: actions/cache@v4
206278
with:
207279
path: |
208280
~/.composer
209281
./vendor
210282
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
211-
key: tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }}
283+
key: tests-php${{ steps.setup-php.outputs.php-version }}-sf${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }}
212284

213-
- name: Build
285+
- name: Build with PHP ${{ matrix.php-version }} (${{ matrix.php-prefer-latest && ' latest->' || '' }}${{ steps.setup-php.outputs.php-version }}) & Symfony ${{ matrix.symfony-version }}${{ matrix.composer-prefer-lowest && ' (lowest)' || '' }}
214286
run: |
215287
composer config minimum-stability dev \
216-
&& composer require -W ${{ env.COMPOSER_OPTIONS }} --prefer-stable \
288+
&& composer require -W ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-prefer-lowest && '--prefer-lowest' || '' }} \
217289
symfony/http-foundation:^${{ matrix.symfony-version }} \
218290
symfony/http-kernel:^${{ matrix.symfony-version }} \
219291
symfony/config:^${{ matrix.symfony-version }} \
220292
symfony/dependency-injection:^${{ matrix.symfony-version }} \
221293
symfony/event-dispatcher:^${{ matrix.symfony-version }} \
222294
symfony/routing:^${{ matrix.symfony-version }} \
223295
${{ matrix.pkg-extra-constraints }} \
224-
&& composer update ${{ env.COMPOSER_OPTIONS }} --prefer-stable \
296+
&& composer update ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-prefer-lowest && '--prefer-lowest' || '' }} \
225297
&& make build
226298
227299
- name: Test

0 commit comments

Comments
 (0)