Skip to content

Commit ec516fb

Browse files
committed
[CI] Remove "component" matrix entry and test all UX packages in a single job, minor improvements
1 parent ea0927e commit ec516fb

File tree

2 files changed

+49
-41
lines changed

2 files changed

+49
-41
lines changed

.github/workflows/test.yaml

+46-39
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,30 +54,16 @@ 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
59+
name: "PHP ${{ matrix.php-version }} - Symfony ${{ matrix.symfony-version }} - ${{ matrix.minimum-stability }} ${{ matrix.dependency-version }} deps"
6960
strategy:
7061
fail-fast: false
7162
matrix:
7263
php-version: ['8.1', '8.3', '8.4']
73-
symfony-version: ['6.4', '7.2']
64+
symfony-version: ['6.4.x', '7.2.x']
7465
minimum-stability: ['stable', 'dev']
7566
dependency-version: ['lowest', 'highest']
76-
component: ${{ fromJson(needs.tests-php-components.outputs.components )}}
7767
exclude:
7868
- php-version: '8.1'
7969
minimum-stability: 'dev'
@@ -85,42 +75,59 @@ jobs:
8575
dependency-version: 'lowest'
8676
- php-version: '8.4'
8777
dependency-version: 'lowest'
88-
- component: Swup # has no tests
89-
- component: Turbo # has its own workflow (test-turbo.yml)
90-
- component: Typed # has no tests
9178
env:
9279
SYMFONY_REQUIRE: ${{ matrix.config.symfony-version }}
9380
steps:
9481
- uses: actions/checkout@v4
9582

96-
- uses: shivammathur/setup-php@v2
83+
- name: Configure environment
84+
run: |
85+
_run_task() {
86+
local ok=0
87+
local title="$1"
88+
local start=$(date -u +%s)
89+
OUTPUT=$(bash -xc "$2" 2>&1) || ok=$?
90+
local end=$(date -u +%s)
91+
92+
if [[ $ok -ne 0 ]]; then
93+
printf "\n%-70s%10s\n" $title $(($end-$start))s
94+
echo "$OUTPUT"
95+
echo "Job exited with: $ok"
96+
echo -e "\n::error::KO $title\\n"
97+
else
98+
printf "::group::%-68s%10s\n" $title $(($end-$start))s
99+
echo "$OUTPUT"
100+
echo -e "\n\\e[32mOK\\e[0m $title\\n\\n::endgroup::"
101+
fi
102+
103+
exit $ok
104+
}
105+
export -f _run_task
106+
107+
echo COLUMNS=120 >> $GITHUB_ENV
108+
echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.minimum-stability }}) --ansi' >> $GITHUB_ENV
109+
echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest' }} --no-progress --ansi' >> $GITHUB_ENV
110+
echo PHPUNIT='vendor/bin/simple-phpunit' >> $GITHUB_ENV
111+
# TODO: exclude Swup Turbo Typed
112+
echo PACKAGES=$(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') >> $GITHUB_OUTPUT
113+
114+
- name: Setup PHP
115+
uses: shivammathur/setup-php@v2
97116
with:
98117
php-version: ${{ matrix.php-version }}
118+
tools: flex
99119

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

106123
- name: Build root packages
107124
run: php .github/build-packages.php
108-
working-directory: ${{ github.workspace }}
109125

110-
- name: Configure ${{ matrix.minimum-stability }} stability
111-
if: ${{ matrix.minimum-stability }}
112-
run: composer config minimum-stability ${{ matrix.minimum-stability }}
113-
working-directory: "src/${{ matrix.component }}"
114-
115-
- name: Install ${{ matrix.component }} packages
116-
uses: ramsey/composer-install@v3
117-
with:
118-
working-directory: "src/${{ matrix.component }}"
119-
dependency-versions: ${{ matrix.dependency-version }}
126+
- name: Install packages dependencies
127+
run: echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} 'cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT install'"
120128

121-
- name: ${{ matrix.component }} Tests
122-
working-directory: "src/${{ matrix.component }}"
123-
run: vendor/bin/simple-phpunit
129+
- name: Run packages tests
130+
run: echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} 'cd src/{} && $PHPUNIT'"
124131

125132
tests-js:
126133
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)