Skip to content

Commit d06e653

Browse files
committed
[CI] Rework tests-php job matrix, better covers different PHP/SF versions, test all components in a single job
1 parent 00fa069 commit d06e653

File tree

3 files changed

+79
-62
lines changed

3 files changed

+79
-62
lines changed

.github/workflows/test-turbo.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,20 @@ jobs:
4141
strategy:
4242
fail-fast: false
4343
matrix:
44-
php-version: ['8.1', '8.3', '8.4']
44+
php-version: ['8.1', '8.2', '8.3', '8.4']
45+
dependency-version: ['']
46+
symfony-version: ['']
47+
minimum-stability: ['stable']
4548
include:
46-
- php-version: '8.1'
47-
dependency-version: 'lowest'
48-
- php-version: '8.3'
49-
dependency-version: 'highest'
50-
- php-version: '8.4'
51-
dependency-version: 'highest'
49+
# dev packages (probably not needed to have multiple such jobs)
50+
- minimum-stability: 'dev'
51+
php-version: '8.4'
52+
# lowest deps
53+
- php-version: '8.1'
54+
dependency-version: 'lowest'
55+
# LTS version of Symfony
56+
- php-version: '8.1'
57+
symfony-version: '6.4.*'
5258

5359
services:
5460
mercure:

.github/workflows/test.yaml

Lines changed: 63 additions & 53 deletions
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,81 @@ 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']
62+
php-version: ['8.1', '8.2', '8.3', '8.4']
63+
dependency-version: ['']
64+
symfony-version: ['']
65+
minimum-stability: ['stable']
7466
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-
67+
# dev packages (probably not needed to have multiple such jobs)
68+
- minimum-stability: 'dev'
69+
php-version: '8.4'
70+
# lowest deps
71+
- php-version: '8.1'
72+
dependency-version: 'lowest'
73+
# LTS version of Symfony
74+
- php-version: '8.1'
75+
symfony-version: '6.4.*'
76+
77+
env:
78+
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
9179
steps:
9280
- uses: actions/checkout@v4
9381

94-
- uses: shivammathur/setup-php@v2
82+
- name: Configure environment
83+
run: |
84+
echo COLUMNS=120 >> $GITHUB_ENV
85+
echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.minimum-stability || 'stable' }} --ansi' >> $GITHUB_ENV
86+
echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV
87+
echo PHPUNIT='vendor/bin/simple-phpunit' >> $GITHUB_ENV
88+
[ 'lowest' = '${{ matrix.dependency-version }}' ] && export SYMFONY_DEPRECATIONS_HELPER=weak
89+
90+
# Swup and Typed have no tests, Turbo has its own workflow file
91+
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' ' ')
92+
echo "Packages: $PACKAGES"
93+
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
94+
95+
- name: Setup PHP
96+
uses: shivammathur/setup-php@v2
9597
with:
9698
php-version: ${{ matrix.php-version }}
99+
tools: flex
97100

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

104104
- name: Build root packages
105105
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 }}"
112106

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
107+
- name: Run packages tests
108+
run: |
109+
_run_task() {
110+
local ok=0
111+
local title="$1"
112+
local start=$(date -u +%s)
113+
OUTPUT=$(bash -xc "$2" 2>&1) || ok=$?
114+
local end=$(date -u +%s)
115+
116+
if [[ $ok -ne 0 ]]; then
117+
printf "\n%-70s%10s\n" $title $(($end-$start))s
118+
echo "$OUTPUT"
119+
echo "Job exited with: $ok"
120+
echo -e "\n::error::KO $title\\n"
121+
else
122+
printf "::group::%-68s%10s\n" $title $(($end-$start))s
123+
echo "$OUTPUT"
124+
echo -e "\n\\e[32mOK\\e[0m $title\\n\\n::endgroup::"
125+
fi
126+
127+
exit $ok
128+
}
129+
export -f _run_task
130+
131+
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT)'"
122132
123133
tests-js:
124134
runs-on: ubuntu-latest

composer.json

Lines changed: 3 additions & 2 deletions
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": "^6.4|^7.0",
10+
"symfony/finder": "^6.4|^7.0",
1011
"php-cs-fixer/shim": "^3.62"
1112
}
1213
}

0 commit comments

Comments
 (0)