Skip to content

Commit 29556ae

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

File tree

2 files changed

+48
-42
lines changed

2 files changed

+48
-42
lines changed

.github/workflows/test.yaml

Lines changed: 45 additions & 40 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'
@@ -85,42 +75,57 @@ 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+
echo COLUMNS=120 >> $GITHUB_ENV
86+
echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.minimum-stability }}) --ansi' >> $GITHUB_ENV
87+
echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest' }} --no-progress --ansi' >> $GITHUB_ENV
88+
echo PHPUNIT='vendor/bin/simple-phpunit' >> $GITHUB_ENV
89+
# TODO: exclude Swup Turbo Typed
90+
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
91+
92+
- name: Setup PHP
93+
uses: shivammathur/setup-php@v2
9794
with:
9895
php-version: ${{ matrix.php-version }}
96+
tools: flex
9997

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

106101
- name: Build root packages
107102
run: php .github/build-packages.php
108-
working-directory: ${{ github.workspace }}
109-
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 }}"
114103

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