@@ -2,94 +2,133 @@ name: 'CI reusable workflow'
22
33on :
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 Highest 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 - usually LTS 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 Highest 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
641env :
42+ COMPOSER_PREFER_STABLE : ' 1'
743 TEST_OUTPUT_STYLE : pretty
8- COMPOSER_OPTIONS : --optimize-autoloader
944
1045jobs :
1146 tests :
12- name : PHP ${{ matrix.php-version }} & Symfony ${{ matrix.symfony-version }}
47+ name : ${{ matrix.job-name }}
1348 runs-on : ubuntu-latest
1449 env :
1550 COVERAGE_TYPE : none
51+ COVERAGE_OUTPUT_STYLE : clover
1652 strategy :
1753 fail-fast : true
18- max-parallel : 4
1954 matrix :
2055 include :
21- # Bare minimum => Lowest versions allowed by composer config
22- - symfony-version : ' 4.4'
23- php-version : ' 8.0'
24- composer-flag : --prefer-lowest
25- # 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
56+ - job-name : Up to date versions # => Highest versions allowed by composer config
57+ php-version : ' ${{ inputs.php-max-version }}'
58+ symfony-version : ' ${{ inputs.symfony-max-version }}'
59+ # # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317)
60+ pkg-extra-constraints : behat/gherkin:~4.12.0
61+ - job-name : Up to date versions - Special case - Symfony 5.4
62+ php-version : ' ${{ inputs.php-max-version }}'
63+ symfony-version : ' 5.4'
64+ # # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317)
65+ pkg-extra-constraints : behat/gherkin:~4.12.0
66+ - job-name : Bare minimum # => Lowest versions allowed by composer config
67+ php-version : ' ${{ inputs.php-min-version }}'
68+ symfony-version : ' ${{ inputs.symfony-min-version }}'
69+ - job-name : Bare minimum - Special case - Symfony 5.4
70+ php-version : ' ${{ inputs.php-min-version }}'
71+ symfony-version : ' 5.4'
72+ - job-name : Late migration - PHP # => Highest symfony version with lowest php version allowed by composer config
73+ php-version : ' ${{ inputs.php-min-version }}'
74+ symfony-version : ' ${{ inputs.symfony-max-version }}'
75+ - job-name : Late migration - Symfony # => Lowest symfony version with highest php version allowed by composer config
76+ php-version : ' ${{ inputs.php-max-version }}'
77+ symfony-version : ' ${{ inputs.symfony-min-version }}'
78+ # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317)
79+ pkg-extra-constraints : behat/gherkin:~4.12.0
4280 steps :
4381 - name : Check out code
4482 uses : actions/checkout@v4
4583
84+ # Enable coverage only for specific version(s) !
85+ # Usually highest version(s), plus additional ones in case of code used only with specific versions
4686 - name : Enable coverage
47- if : ${{ matrix.php-version == '8.2' }}
87+ if : ${{ matrix.php-version == inputs.php-max-version }}
4888 run : |
49- echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV
5089 echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV
5190
5291 - name : Setup PHP ${{ matrix.php-version }}
92+ id : setup-php
5393 uses : shivammathur/setup-php@v2
5494 env :
55- update : true # Always use latest available patch for the version
95+ update : true # whether to use latest available patch for the version or not
5696 fail-fast : true # step will fail if an extension or tool fails to set up
5797 with :
58- php-version : ' ${{ matrix.php-version }}'
98+ php-version : ${{ matrix.php-version }}
5999 tools : composer
60100 coverage : ${{ env.COVERAGE_TYPE }}
61101
62- - name : Setup cache
63- id : cache
102+ - name : Get composer cache directory
103+ id : composer-cache
104+ run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
105+
106+ - name : Setup cache for PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ matrix.symfony-version }}
64107 uses : actions/cache@v4
65108 with :
66109 path : |
67- ~/.composer
68- ./vendor
69- # 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') }}
110+ ${{ steps.composer-cache.outputs.dir }}
111+ # Clear the cache if composer.json (as composer.lock is not available) has been updated
112+ key : tests-php${{ steps.setup-php.outputs.php-version }}-sf${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }}
71113
72- - name : Build
114+ - name : Build with PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ matrix.symfony-version }}
73115 run : |
74- SF_VERSION=${{ matrix.symfony-version }}
75- # 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 }} \
116+ SF_CONSTRAINT="~${{ matrix.symfony-version }}.0"
117+ composer require -W \
118+ symfony/http-foundation:${SF_CONSTRAINT} \
119+ symfony/http-kernel:${SF_CONSTRAINT} \
120+ symfony/config:${SF_CONSTRAINT} \
121+ symfony/dependency-injection:${SF_CONSTRAINT} \
122+ symfony/event-dispatcher:${SF_CONSTRAINT} \
123+ symfony/routing:${SF_CONSTRAINT} \
124+ ${{ matrix.pkg-extra-constraints }} \
85125 && make build
86126
87127 - name : Tests
88128 run : make test-unit && make test-functional
89129
90130 - name : Create "unit tests" reports group
91131 if : ${{ env.COVERAGE_TYPE == 'xdebug' }}
92- id : unit-tests-coverage-group
93132 uses : yoanm/temp-reports-group-workspace/create-group@v0
94133 with :
95134 name : unit-tests
@@ -103,7 +142,6 @@ jobs:
103142
104143 - name : Create "functional tests" reports group
105144 if : ${{ env.COVERAGE_TYPE == 'xdebug' }}
106- id : functional-tests-coverage-group
107145 uses : yoanm/temp-reports-group-workspace/create-group@v0
108146 with :
109147 name : functional-tests
@@ -121,39 +159,53 @@ jobs:
121159 if : ${{ env.COVERAGE_TYPE == 'xdebug' }}
122160 uses : actions/upload-artifact@v4
123161 with :
124- name : coverage-groups-php${{ matrix .php-version }}-sf${{ matrix.symfony-version }}
162+ name : coverage-groups-php${{ steps.setup-php.outputs .php-version }}-sf${{ matrix.symfony-version }}
125163 path : build/coverage-groups
126164 if-no-files-found : error
127165
128166 static-checks :
129167 name : Static analysis
130168 runs-on : ubuntu-latest
131169 env :
132- SC_PHP_VERSION : 8.2 # Latest supported
170+ PHP_VERSION : ${{ inputs.php-max-version }}
171+ SYMFONY_VERSION : ${{ inputs.symfony-max-version }}
133172 steps :
134173 - uses : actions/checkout@v4
135174
136- - name : Setup PHP ${{ env.SC_PHP_VERSION }}
175+ - name : Setup PHP ${{ env.PHP_VERSION }}
176+ id : setup-php
137177 uses : shivammathur/setup-php@v2
178+ env :
179+ update : true # Always use latest available patch for the version
180+ fail-fast : true # step will fail if an extension or tool fails to set up
138181 with :
139- php-version : ${{ env.SC_PHP_VERSION }}
182+ php-version : ${{ env.PHP_VERSION }}
140183 tools : composer
141184 coverage : none
142- env :
143- # Always use latest available patch for the version
144- update : true
145185
146- - name : Setup cache
147- id : cache
186+ - name : Get composer cache directory
187+ id : composer-cache
188+ run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
189+
190+ - name : Setup cache for PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ env.SYMFONY_VERSION }}
148191 uses : actions/cache@v4
149192 with :
150193 path : |
151- ~/ .composer
152- # 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') }}
194+ ${{ steps .composer-cache.outputs.dir }}
195+ # Clear the cache if composer. json (as composer.lock is not available ) has been updated
196+ key : tests-php ${{ steps.setup-php.outputs.php-version }}-sf${{ env.SYMFONY_VERSION }}-${{ hashFiles('composer.json') }}
154197
155- - name : Build
156- run : make build
198+ - name : Build with PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ env.SYMFONY_VERSION }}
199+ run : |
200+ SF_CONSTRAINT="~${{ env.SYMFONY_VERSION }}.0"
201+ composer require -W \
202+ symfony/http-foundation:${SF_CONSTRAINT} \
203+ symfony/http-kernel:${SF_CONSTRAINT} \
204+ symfony/config:${SF_CONSTRAINT} \
205+ symfony/dependency-injection:${SF_CONSTRAINT} \
206+ symfony/event-dispatcher:${SF_CONSTRAINT} \
207+ symfony/routing:${SF_CONSTRAINT} \
208+ && make build
157209
158210 - name : ComposerRequireChecker
159211 uses : docker://webfactory/composer-require-checker:4.5.0
@@ -163,65 +215,76 @@ jobs:
163215 uses : actions/dependency-review-action@v4
164216
165217 nightly-tests :
166- name : Nightly - PHP ${{ matrix.php-version }} & Symfony ${{ matrix.symfony-version }}
218+ name : Nightly - ${{ matrix.job-name }}
167219 runs-on : ubuntu-latest
168220 env :
169- COMPOSER_OPTIONS : ' --optimize-autoloader --prefer-dist --ignore-platform-req= php+'
221+ COMPOSER_IGNORE_PLATFORM_REQ : ' php+'
170222 continue-on-error : true
171- needs : [ static-checks, tests ]
223+ needs : [ tests ]
172224 strategy :
173225 fail-fast : false
174- max-parallel : 4
175226 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
182227 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'
228+ - job-name : PHP - With highest supported Symfony versions
229+ php-version : ${{ inputs.php-next-version }}
230+ symfony-version : ${{ inputs.symfony-max-version }}
231+ # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317)
232+ pkg-extra-constraints : behat/gherkin:~4.12.0
233+ - job-name : PHP - With lowest supported Symfony versions
234+ php-version : ${{ inputs.php-next-version }}
235+ symfony-version : ${{ inputs.symfony-min-version }}
236+ # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317)
237+ pkg-extra-constraints : behat/gherkin:~4.12.0
238+ - job-name : Symfony - With highest supported PHP version
239+ php-version : ${{ inputs.php-max-version }}
240+ symfony-version : ${{ inputs.symfony-next-version }}
241+ # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317)
242+ pkg-extra-constraints : behat/gherkin:~4.12.0
243+ - job-name : Symfony - With lowest supported PHP version
244+ 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 !
245+ symfony-version : ${{ inputs.symfony-next-version }}
246+ # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317)
247+ pkg-extra-constraints : behat/gherkin:~4.12.0
188248
189249 steps :
190250 - name : Check out code
191251 uses : actions/checkout@v4
192252
193253 - name : Setup PHP ${{ matrix.php-version }}
254+ id : setup-php
194255 uses : shivammathur/setup-php@v2
256+ env :
257+ update : true # whether to use latest available patch for the version or not
258+ fail-fast : true # step will fail if an extension or tool fails to set up
195259 with :
196- php-version : ' ${{ matrix.php-version }}'
260+ php-version : ${{ matrix.php-version }}
197261 tools : composer
198262 coverage : none
199- env :
200- # Always use latest available patch for the version
201- update : true
202263
203- - name : Setup cache
204- id : cache
264+ - name : Get composer cache directory
265+ id : composer-cache
266+ run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
267+
268+ - name : Setup cache for PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ matrix.symfony-version }}
205269 uses : actions/cache@v4
206270 with :
207271 path : |
208- ~/.composer
209- ./vendor
210- # 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') }}
272+ ${{ steps.composer-cache.outputs.dir }}
273+ # Clear the cache if composer.json (as composer.lock is not available) has been updated
274+ key : tests-php${{ steps.setup-php.outputs.php-version }}-sf${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }}
212275
213- - name : Build
276+ - name : Build with PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ matrix.symfony-version }}
214277 run : |
278+ SF_CONSTRAINT="~${{ matrix.symfony-version }}.0@dev"
215279 composer config minimum-stability dev \
216- && composer require -W ${{ env.COMPOSER_OPTIONS }} --prefer-stable \
217- symfony/http-foundation:^${{ matrix.symfony-version } } \
218- symfony/http-kernel:^${{ matrix.symfony-version } } \
219- symfony/config:^${{ matrix.symfony-version } } \
220- symfony/dependency-injection:^${{ matrix.symfony-version } } \
221- symfony/event-dispatcher:^${{ matrix.symfony-version } } \
222- symfony/routing:^${{ matrix.symfony-version } } \
280+ && composer require -W \
281+ symfony/http-foundation:${SF_CONSTRAINT } \
282+ symfony/http-kernel:${SF_CONSTRAINT } \
283+ symfony/config:${SF_CONSTRAINT } \
284+ symfony/dependency-injection:${SF_CONSTRAINT } \
285+ symfony/event-dispatcher:${SF_CONSTRAINT } \
286+ symfony/routing:${SF_CONSTRAINT } \
223287 ${{ matrix.pkg-extra-constraints }} \
224- && composer update ${{ env.COMPOSER_OPTIONS }} --prefer-stable \
225288 && make build
226289
227290 - name : Test
0 commit comments