Skip to content

Commit 38662c0

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

File tree

2 files changed

+48
-38
lines changed

2 files changed

+48
-38
lines changed

.github/workflows/test.yaml

Lines changed: 45 additions & 36 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,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'
@@ -93,34 +83,53 @@ jobs:
9383
steps:
9484
- uses: actions/checkout@v4
9585

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

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

106125
- name: Build root packages
107126
run: php .github/build-packages.php
108-
working-directory: ${{ github.workspace }}
109127

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 }}
128+
- name: Install packages dependencies
129+
run: echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} 'cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT install'"
120130

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

125134
tests-js:
126135
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": "^7.0",
10+
"symfony/finder": "^7.0",
1011
"php-cs-fixer/shim": "^3.62"
1112
}
1213
}

0 commit comments

Comments
 (0)