Skip to content

Commit 5d72847

Browse files
committed
[CI] Re-organize workflows: split unit/functional/app tests, split code quality workflow
1 parent 5665746 commit 5d72847

8 files changed

+335
-263
lines changed

.github/workflows/.utils.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
_run_task() {
2+
local ok=0
3+
local title="$1"
4+
local start=$(date -u +%s)
5+
OUTPUT=$(bash -xc "$2" 2>&1) || ok=$?
6+
local end=$(date -u +%s)
7+
8+
if [[ $ok -ne 0 ]]; then
9+
printf "\n%-70s%10s\n" $title $(($end-$start))s
10+
echo "$OUTPUT"
11+
echo "Job exited with: $ok"
12+
echo -e "\n::error::KO $title\\n"
13+
else
14+
printf "::group::%-68s%10s\n" $title $(($end-$start))s
15+
echo "$OUTPUT"
16+
echo -e "\n\\e[32mOK\\e[0m $title\\n\\n::endgroup::"
17+
fi
18+
19+
exit $ok
20+
}
21+
export -f _run_task

.github/workflows/app-tests.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: App Tests
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'src/*/doc/**'
7+
- 'src/**/*.md'
8+
- 'ux.symfony.com/**'
9+
pull_request:
10+
paths-ignore:
11+
- 'src/*/doc/**'
12+
- 'src/**/*.md'
13+
- 'ux.symfony.com/**'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
encore-app:
21+
name: "Encore (${{ matrix.name}})"
22+
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- name: Internal, from "vendor/"
28+
ux-packages-source: php-vendor
29+
- name: External, from "npm add"
30+
ux-packages-source: js-packages
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- run: npm i -g corepack && corepack enable
35+
36+
- uses: actions/setup-node@v4
37+
with:
38+
cache: 'yarn'
39+
cache-dependency-path: |
40+
yarn.lock
41+
package.json
42+
src/**/package.json
43+
test_apps/encore-app/package.json
44+
45+
- uses: shivammathur/setup-php@v2
46+
47+
- name: Install root dependencies
48+
uses: ramsey/composer-install@v3
49+
with:
50+
working-directory: ${{ github.workspace }}
51+
52+
- name: Build root packages
53+
run: php .github/build-packages.php
54+
working-directory: ${{ github.workspace }}
55+
56+
# We always install PHP deps because we of the UX Translator, which requires `var/translations` to exists
57+
- uses: ramsey/composer-install@v3
58+
with:
59+
dependency-versions: 'highest'
60+
working-directory: test_apps/encore-app
61+
62+
- if: matrix.ux-packages-source == 'php-vendor'
63+
name: Refresh dependencies from vendor/
64+
working-directory: test_apps/encore-app
65+
run: yarn
66+
env:
67+
YARN_ENABLE_HARDENED_MODE: 0
68+
YARN_ENABLE_IMMUTABLE_INSTALLS: 0
69+
70+
- if: matrix.ux-packages-source == 'js-packages'
71+
name: Install UX JS packages with a JS package manager
72+
working-directory: test_apps/encore-app
73+
run: |
74+
PACKAGES_TO_INSTALL=''
75+
for PACKAGE in $(cd ../..; yarn workspaces list --no-private --json); do
76+
PACKAGE_DIR=../../$(echo $PACKAGE | jq -r '.location')
77+
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PACKAGE_DIR"
78+
done
79+
echo "Installing packages: $PACKAGES_TO_INSTALL"
80+
yarn add --dev $PACKAGES_TO_INSTALL
81+
82+
- name: Ensure UX packages are installed from "${{ matrix.ux-packages-source == 'php-vendor' && 'vendor/symfony/ux-...' || '../../../src/**/assets' }}"
83+
working-directory: test_apps/encore-app
84+
run: |
85+
for PACKAGE in $(cat package.json | jq -c '(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.key | startswith("@symfony/ux-")) | {name: .key, version: .value}'); do
86+
PACKAGE_NAME=$(echo $PACKAGE | jq -r '.name')
87+
PACKAGE_VERSION=$(echo $PACKAGE | jq -r '.version')
88+
89+
echo -n "Checking $PACKAGE_NAME@$PACKAGE_VERSION..."
90+
if [[ $PACKAGE_VERSION == $EXPECTED_PATTERN* ]]; then
91+
echo " OK"
92+
else
93+
echo " KO"
94+
echo "The package version of $PACKAGE_NAME must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead."
95+
exit 1
96+
fi
97+
done;
98+
env:
99+
EXPECTED_PATTERN: ${{ matrix.ux-packages-source == 'php-vendor' && 'file:vendor/symfony/*' || '../../src/*' }}
100+
101+
- name: Run Encore (dev)
102+
working-directory: test_apps/encore-app
103+
run: yarn encore dev
104+
105+
- name: Run Encore (prod)
106+
working-directory: test_apps/encore-app
107+
run: yarn encore production

.github/workflows/code-quality.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'src/*/doc/**'
7+
- 'src/**/*.md'
8+
- 'ux.symfony.com/**'
9+
pull_request:
10+
paths-ignore:
11+
- 'src/*/doc/**'
12+
- 'src/**/*.md'
13+
- 'ux.symfony.com/**'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
coding-style-js:
21+
name: JavaScript Coding Style
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- run: npm i -g corepack && corepack enable
26+
- uses: actions/setup-node@v4
27+
with:
28+
cache: 'yarn'
29+
- run: yarn --immutable
30+
- run: yarn ci
31+
32+
phpstan:
33+
name: PHPStan
34+
runs-on: ubuntu-latest
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
package: ${{ fromJson(needs.php-packages-matrix.outputs.packages) }}
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: Configure environment
44+
run: |
45+
echo COLUMNS=120 >> $GITHUB_ENV
46+
echo COMPOSER_MIN_STAB='composer config minimum-stability stable --ansi' >> $GITHUB_ENV
47+
echo COMPOSER_UP='composer update --no-progress --no-interaction --ansi' >> $GITHUB_ENV
48+
echo PHPSTAN='vendor/bin/phpstan' >> $GITHUB_ENV
49+
50+
# TODO: Only Turbo has PHPStan configuration, let's improve this later :)
51+
PACKAGES=Turbo
52+
#PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | sed 's/^src\///' | sort | tr '\n' ' ')
53+
echo "Packages: $PACKAGES"
54+
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
55+
56+
- name: Setup PHP
57+
uses: shivammathur/setup-php@v2
58+
with:
59+
php-version: '8.1'
60+
tools: flex
61+
62+
- name: Install root dependencies
63+
run: composer install
64+
65+
- name: Build root packages
66+
run: php .github/build-packages.php
67+
68+
- name: Run PHPStan on packages
69+
run: |
70+
source .github/workflows/.utils.sh
71+
72+
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPSTAN)'"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Dist Files Unbuilt
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'src/*/doc/**'
7+
- 'src/**/*.md'
8+
- 'ux.symfony.com/**'
9+
pull_request:
10+
paths-ignore:
11+
- 'src/*/doc/**'
12+
- 'src/**/*.md'
13+
- 'ux.symfony.com/**'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
check:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- run: npm i -g corepack && corepack enable
25+
- uses: actions/setup-node@v4
26+
with:
27+
cache: 'yarn'
28+
cache-dependency-path: |
29+
yarn.lock
30+
**/package.json
31+
- run: yarn --immutable && yarn build
32+
33+
- name: Check if JS dist files are current
34+
run: |
35+
if ! git diff --quiet; then
36+
echo "The Git workspace is unclean! Changes detected:"
37+
git status --porcelain
38+
git diff
39+
exit 1
40+
else
41+
echo "The Git workspace is clean. No changes detected."
42+
fi

.github/workflows/test-turbo.yml renamed to .github/workflows/functional-tests.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Symfony UX Turbo
1+
name: Functional Tests
22

33
on:
44
push:
@@ -9,31 +9,7 @@ on:
99
- 'src/Turbo/**'
1010

1111
jobs:
12-
phpstan:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v4
17-
18-
- name: Setup PHP
19-
uses: shivammathur/setup-php@v2
20-
with:
21-
php-version: '8.1'
22-
extensions: zip
23-
24-
- uses: ramsey/composer-install@v3
25-
with:
26-
working-directory: src/Turbo
27-
28-
- name: Install PHPUnit dependencies
29-
working-directory: src/Turbo
30-
run: vendor/bin/simple-phpunit --version
31-
32-
- name: PHPStan
33-
working-directory: src/Turbo
34-
run: vendor/bin/phpstan analyse --no-progress
35-
36-
tests:
12+
turbo-tests:
3713
runs-on: ubuntu-latest
3814
strategy:
3915
fail-fast: false

0 commit comments

Comments
 (0)