Skip to content

Commit 23e6967

Browse files
committed
Improve CI
1 parent 4572d59 commit 23e6967

File tree

1 file changed

+50
-62
lines changed

1 file changed

+50
-62
lines changed

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

Lines changed: 50 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
type: string
1414
php-max-version:
1515
default: '8.2'
16-
description: Highest PHP version to assess (e.g Latest supported version)
16+
description: Highest PHP version to assess (e.g Highest supported version)
1717
required: false
1818
type: string
1919
php-next-version:
@@ -24,8 +24,8 @@ on:
2424
# <<<< Dummy env-inputs
2525

2626
env:
27+
COMPOSER_PREFER_STABLE: '1'
2728
TEST_OUTPUT_STYLE: pretty
28-
COMPOSER_OPTIONS: --optimize-autoloader
2929

3030
jobs:
3131
tests:
@@ -36,61 +36,54 @@ jobs:
3636
COVERAGE_OUTPUT_STYLE: clover
3737
strategy:
3838
fail-fast: true
39-
max-parallel: 4
4039
matrix:
4140
include:
42-
- job-name: Bare minimum # => Lowest versions allowed by composer config
43-
php-version: '${{ inputs.php-min-version }}'
44-
composer-prefer-lowest: true
45-
- job-name: Up to date versions # => Latest versions allowed by composer config
46-
php-version: '${{ inputs.php-max-version }}'
47-
- job-name: Bare minimum on latest versions # => Lowest latest versions allowed by composer config
41+
- job-name: Up to date versions # => Highest versions allowed by composer config
4842
php-version: '${{ inputs.php-max-version }}'
49-
composer-prefer-lowest: true
50-
- job-name: Up to date bare minimum # => Latest lowest versions allowed by composer config
43+
- job-name: Bare minimum # => Lowest versions allowed by composer config
5144
php-version: '${{ inputs.php-min-version }}'
5245
steps:
5346
- name: Check out code
54-
uses: actions/checkout@v5
47+
uses: actions/checkout@v4
5548

5649
# Enable coverage only for specific version(s) !
57-
# Usually latest version(s), plus additional ones in case of code used only with specific versions
50+
# Usually highest version(s), plus additional ones in case of code used only with specific versions
5851
- name: Enable coverage
5952
if: ${{ matrix.php-version == inputs.php-max-version }}
6053
run: |
6154
echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV
6255
6356
- name: Setup PHP ${{ matrix.php-version }}
57+
id: setup-php
6458
uses: shivammathur/setup-php@v2
6559
env:
66-
update: true # Always use latest available patch for the version
60+
update: true # whether to use latest available patch for the version or not
6761
fail-fast: true # step will fail if an extension or tool fails to set up
6862
with:
69-
php-version: '${{ matrix.php-version }}'
63+
php-version: ${{ matrix.php-version }}
7064
tools: composer
7165
coverage: ${{ env.COVERAGE_TYPE }}
7266

73-
- name: Setup cache
74-
id: cache
67+
- name: Get composer cache directory
68+
id: composer-cache
69+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
70+
71+
- name: Setup cache for PHP ${{ steps.setup-php.outputs.php-version }}
7572
uses: actions/cache@v4
7673
with:
7774
path: |
78-
~/.composer
79-
./vendor
80-
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
81-
key: tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}${{ matrix.composer-prefer-lowest == true && '-lowest' || '' }}
75+
${{ steps.composer-cache.outputs.dir }}
76+
# Clear the cache if composer.json (as composer.lock is not available) has been updated
77+
key: tests-php${{ steps.setup-php.outputs.php-version }}-${{ hashFiles('composer.json') }}
8278

83-
- name: Build
84-
run: |
85-
composer update ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-prefer-lowest == true && '--prefer-lowest' || '' }} \
86-
&& make build
79+
- name: Build with PHP ${{ steps.setup-php.outputs.php-version }}
80+
run: make build
8781

8882
- name: Tests
8983
run: make test-unit && make test-functional
9084

9185
- name: Create "unit tests" reports group
9286
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
93-
id: unit-tests-coverage-group
9487
uses: yoanm/temp-reports-group-workspace/create-group@v0
9588
with:
9689
name: unit-tests
@@ -103,7 +96,6 @@ jobs:
10396

10497
- name: Create "functional tests" reports group
10598
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
106-
id: functional-tests-coverage-group
10799
uses: yoanm/temp-reports-group-workspace/create-group@v0
108100
with:
109101
name: functional-tests
@@ -120,36 +112,42 @@ jobs:
120112
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
121113
uses: actions/upload-artifact@v4
122114
with:
123-
name: coverage-groups-php${{ matrix.php-version }}${{ matrix.composer-prefer-lowest == true && '-lowest' || '' }}
115+
name: coverage-groups-php${{ steps.setup-php.outputs.php-version }}
124116
path: build/coverage-groups
125117
if-no-files-found: error
126118

127119
static-checks:
128120
name: Static analysis
129121
runs-on: ubuntu-latest
122+
env:
123+
PHP_VERSION: ${{ inputs.php-max-version }}
130124
steps:
131-
- uses: actions/checkout@v5
125+
- uses: actions/checkout@v4
132126

133-
- name: Setup PHP ${{ inputs.php-max-version }}
127+
- name: Setup PHP ${{ env.PHP_VERSION }}
128+
id: setup-php
134129
uses: shivammathur/setup-php@v2
135130
env:
136131
update: true # Always use latest available patch for the version
137132
fail-fast: true # step will fail if an extension or tool fails to set up
138133
with:
139-
php-version: ${{ inputs.php-max-version }}
134+
php-version: ${{ env.PHP_VERSION }}
140135
tools: composer
141136
coverage: none
142137

143-
- name: Setup cache
144-
id: cache
138+
- name: Get composer cache directory
139+
id: composer-cache
140+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
141+
142+
- name: Setup cache for PHP ${{ steps.setup-php.outputs.php-version }}
145143
uses: actions/cache@v4
146144
with:
147145
path: |
148-
~/.composer
149-
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
150-
key: tests-${{ inputs.php-max-version }}-${{ hashFiles('composer.json') }}
146+
${{ steps.composer-cache.outputs.dir }}
147+
# Clear the cache if composer.json (as composer.lock is not available) has been updated
148+
key: tests-php${{ steps.setup-php.outputs.php-version }}-${{ hashFiles('composer.json') }}
151149

152-
- name: Build
150+
- name: Build with PHP ${{ steps.setup-php.outputs.php-version }}
153151
run: make build
154152

155153
- name: ComposerRequireChecker
@@ -160,53 +158,43 @@ jobs:
160158
uses: actions/dependency-review-action@v4
161159

162160
nightly-tests:
163-
name: Nightly - ${{ matrix.job-name }}
161+
name: Nightly
164162
runs-on: ubuntu-latest
165163
env:
166-
COMPOSER_OPTIONS: '--optimize-autoloader --prefer-dist'
167-
COMPOSER_PREFER_STABLE: '1'
164+
PHP_VERSION: ${{ inputs.php-next-version }}
168165
COMPOSER_IGNORE_PLATFORM_REQ: 'php+'
169166
continue-on-error: true
170167
needs: [ tests ]
171-
strategy:
172-
fail-fast: false
173-
max-parallel: 4
174-
matrix:
175-
include:
176-
- job-name: PHP upgrade with lowest dependencies versions # => Lowest supported symfony version against next php version
177-
php-version: ${{ inputs.php-next-version }}
178-
composer-prefer-lowest: true
179-
- job-name: PHP upgrade with highest dependencies versions # => Highest supported symfony version against next php version
180-
php-version: ${{ inputs.php-next-version }}
181-
symfony-version: ${{ inputs.symfony-max-version }}
182168
steps:
183169
- name: Check out code
184170
uses: actions/checkout@v5
185171

186-
- name: Setup PHP ${{ matrix.php-version }}
172+
- name: Setup PHP ${{ env.PHP_VERSION }}
173+
id: setup-php
187174
uses: shivammathur/setup-php@v2
188175
env:
189-
update: true # Always use latest available patch for the version
176+
update: true # whether to use latest available patch for the version or not
190177
fail-fast: true # step will fail if an extension or tool fails to set up
191178
with:
192-
php-version: '${{ matrix.php-version }}'
179+
php-version: ${{ env.PHP_VERSION }}
193180
tools: composer
194181
coverage: none
195182

196-
- name: Setup cache
197-
id: cache
183+
- name: Get composer cache directory
184+
id: composer-cache
185+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
186+
187+
- name: Setup cache for PHP ${{ steps.setup-php.outputs.php-version }}
198188
uses: actions/cache@v4
199189
with:
200190
path: |
201-
~/.composer
202-
./vendor
203-
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
204-
key: tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}${{ matrix.composer-prefer-lowest == true && '-lowest' || '' }}
191+
${{ steps.composer-cache.outputs.dir }}
192+
# Clear the cache if composer.json (as composer.lock is not available) has been updated
193+
key: tests-php${{ steps.setup-php.outputs.php-version }}-${{ hashFiles('composer.json') }}
205194

206-
- name: Build
195+
- name: Build with PHP ${{ steps.setup-php.outputs.php-version }}
207196
run: |
208197
composer config minimum-stability dev \
209-
&& composer update ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-prefer-lowest == true && '--prefer-lowest' || '' }} \
210198
&& make build
211199
212200
- name: Test

0 commit comments

Comments
 (0)