Skip to content

Commit 5ee3705

Browse files
committed
[CI] Rework tests-php job matrix, use explicit configurations, test all components in a single job
1 parent d4c48be commit 5ee3705

File tree

2 files changed

+81
-56
lines changed

2 files changed

+81
-56
lines changed

.github/workflows/test.yaml

+78-54
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
- 'src/**/*.md'
1313
- 'ux.symfony.com/**'
1414

15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
1519
jobs:
1620
coding-style-js:
1721
name: JavaScript Coding Style
@@ -50,75 +54,95 @@ jobs:
5054
echo "The Git workspace is clean. No changes detected."
5155
fi
5256
53-
tests-php-components:
54-
runs-on: ubuntu-latest
55-
outputs:
56-
components: ${{ steps.components.outputs.components }}
57-
steps:
58-
- uses: actions/checkout@v4
59-
60-
- id: components
61-
run: |
62-
components=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | jq -R -s -c 'split("\n")[:-1] | map(. | sub("^src/";"")) | sort')
63-
echo "$components"
64-
echo "components=$components" >> $GITHUB_OUTPUT
65-
6657
tests-php:
6758
runs-on: ubuntu-latest
68-
needs: tests-php-components
6959
strategy:
7060
fail-fast: false
7161
matrix:
72-
php-version: ['8.1', '8.3', '8.4']
73-
minimum-stability: ['stable', 'dev']
74-
include:
75-
- php-version: '8.1'
76-
dependency-version: 'lowest'
77-
- php-version: '8.3'
78-
dependency-version: 'highest'
79-
- php-version: '8.4'
80-
dependency-version: 'highest'
81-
component: ${{ fromJson(needs.tests-php-components.outputs.components )}}
82-
exclude:
83-
- php-version: '8.1'
84-
minimum-stability: 'dev'
85-
- php-version: '8.3'
86-
minimum-stability: 'dev'
87-
- component: Swup # has no tests
88-
- component: Turbo # has its own workflow (test-turbo.yml)
89-
- component: Typed # has no tests
90-
62+
config:
63+
# Minimum supported PHP versions, LTS Symfony versions, with highest deps
64+
- PHP_VERSION: '8.1'
65+
SYMFONY_VERSION: '6.4.*'
66+
67+
# Minimum supported PHP versions, with highest and lowest deps
68+
- PHP_VERSION: '8.1'
69+
- PHP_VERSION: '8.1'
70+
COMPOSER_FLAGS: --prefer-lowest
71+
- PHP_VERSION: '8.2'
72+
- PHP_VERSION: '8.3'
73+
- PHP_VERSION: '8.4'
74+
75+
# Multiple PHP versions, major Symfony development versions
76+
- PHP_VERSION: '8.1'
77+
SYMFONY_VERSION: '6.*'
78+
MINIMUM_STABILITY: dev
79+
80+
- PHP_VERSION: '8.2'
81+
SYMFONY_VERSION: '7.*'
82+
MINIMUM_STABILITY: dev
83+
84+
- PHP_VERSION: '8.3'
85+
SYMFONY_VERSION: '7.*'
86+
MINIMUM_STABILITY: dev
87+
88+
- PHP_VERSION: '8.4'
89+
SYMFONY_VERSION: '7.*'
90+
MINIMUM_STABILITY: dev
91+
92+
env:
93+
SYMFONY_REQUIRE: ${{ matrix.config.SYMFONY_VERSION }}
9194
steps:
9295
- uses: actions/checkout@v4
9396

94-
- uses: shivammathur/setup-php@v2
97+
- name: Configure environment
98+
run: |
99+
echo COLUMNS=120 >> $GITHUB_ENV
100+
echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.config.MINIMUM_STABILITY || 'stable' }} --ansi' >> $GITHUB_ENV
101+
echo COMPOSER_UP='composer update ${{ matrix.config.COMPOSER_FLAGS || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV
102+
echo PHPUNIT='vendor/bin/simple-phpunit' >> $GITHUB_ENV
103+
104+
# Swup and Typed have no tests, Turbo has its own workflow file
105+
PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | sed 's/^src\///' | grep -Ev "Swup|Turbo|Typed" | sort | tr '\n' ' ')
106+
echo "Packages: $PACKAGES"
107+
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
108+
109+
- name: Setup PHP
110+
uses: shivammathur/setup-php@v2
95111
with:
96112
php-version: ${{ matrix.php-version }}
113+
tools: flex
97114

98-
- name: Install root packages
99-
uses: ramsey/composer-install@v3
100-
with:
101-
working-directory: ${{ github.workspace }}
102-
dependency-versions: ${{ matrix.dependency-version }}
115+
- name: Install root dependencies
116+
run: composer install
103117

104118
- name: Build root packages
105119
run: php .github/build-packages.php
106-
working-directory: ${{ github.workspace }}
107-
108-
- name: Configure ${{ matrix.minimum-stability }} stability
109-
if: ${{ matrix.minimum-stability }}
110-
run: composer config minimum-stability ${{ matrix.minimum-stability }}
111-
working-directory: "src/${{ matrix.component }}"
112120

113-
- name: Install ${{ matrix.component }} packages
114-
uses: ramsey/composer-install@v3
115-
with:
116-
working-directory: "src/${{ matrix.component }}"
117-
dependency-versions: ${{ matrix.dependency-version }}
118-
119-
- name: ${{ matrix.component }} Tests
120-
working-directory: "src/${{ matrix.component }}"
121-
run: vendor/bin/simple-phpunit
121+
- name: Run packages tests
122+
run: |
123+
_run_task() {
124+
local ok=0
125+
local title="$1"
126+
local start=$(date -u +%s)
127+
OUTPUT=$(bash -xc "$2" 2>&1) || ok=$?
128+
local end=$(date -u +%s)
129+
130+
if [[ $ok -ne 0 ]]; then
131+
printf "\n%-70s%10s\n" $title $(($end-$start))s
132+
echo "$OUTPUT"
133+
echo "Job exited with: $ok"
134+
echo -e "\n::error::KO $title\\n"
135+
else
136+
printf "::group::%-68s%10s\n" $title $(($end-$start))s
137+
echo "$OUTPUT"
138+
echo -e "\n\\e[32mOK\\e[0m $title\\n\\n::endgroup::"
139+
fi
140+
141+
exit $ok
142+
}
143+
export -f _run_task
144+
145+
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT)'"
122146
123147
tests-js:
124148
runs-on: ubuntu-latest

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
"dev"
66
],
77
"require-dev": {
8-
"symfony/filesystem": "^5.2|^6.0|^7.0",
9-
"symfony/finder": "^5.4|^6.0|^7.0",
8+
"php": ">=8.1",
9+
"symfony/filesystem": "^7.0",
10+
"symfony/finder": "^7.0",
1011
"php-cs-fixer/shim": "^3.62"
1112
}
1213
}

0 commit comments

Comments
 (0)