Skip to content

Commit a26d78a

Browse files
committed
[CI] Run unit and functional tests under Windows too
1 parent 7c3afc9 commit a26d78a

File tree

2 files changed

+67
-10
lines changed

2 files changed

+67
-10
lines changed

.github/workflows/functional-tests.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Functional Tests
22

3+
defaults:
4+
run:
5+
shell: bash
6+
37
on:
48
push:
59
paths:
@@ -12,14 +16,15 @@ on:
1216

1317
jobs:
1418
turbo-tests:
15-
runs-on: ubuntu-latest
19+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
1620
strategy:
1721
fail-fast: false
1822
matrix:
1923
php-version: ['8.1', '8.2', '8.3', '8.4']
2024
dependency-version: ['']
2125
symfony-version: ['']
2226
minimum-stability: ['stable']
27+
os: ['']
2328
include:
2429
# dev packages (probably not needed to have multiple such jobs)
2530
- minimum-stability: 'dev'
@@ -30,7 +35,9 @@ jobs:
3035
# LTS version of Symfony
3136
- php-version: '8.1'
3237
symfony-version: '6.4.*'
33-
38+
- php-version: '8.1'
39+
symfony-version: '6.4.*'
40+
os: 'windows-latest'
3441
env:
3542
SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=5.4' }}
3643
services:

.github/workflows/unit-tests.yaml

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Unit Tests
22

3+
defaults:
4+
run:
5+
shell: bash
6+
37
on:
48
push:
59
paths-ignore:
@@ -18,14 +22,15 @@ concurrency:
1822

1923
jobs:
2024
php:
21-
runs-on: ubuntu-latest
25+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
2226
strategy:
2327
fail-fast: false
2428
matrix:
2529
php-version: ['8.1', '8.2', '8.3', '8.4']
2630
dependency-version: ['']
2731
symfony-version: ['']
2832
minimum-stability: ['stable']
33+
os: ['']
2934
include:
3035
# dev packages (probably not needed to have multiple such jobs)
3136
- minimum-stability: 'dev'
@@ -36,6 +41,9 @@ jobs:
3641
# LTS version of Symfony
3742
- php-version: '8.1'
3843
symfony-version: '6.4.*'
44+
- php-version: '8.1'
45+
symfony-version: '6.4.*'
46+
os: 'windows-latest'
3947

4048
env:
4149
SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=5.4' }}
@@ -66,6 +74,7 @@ jobs:
6674
uses: shivammathur/setup-php@v2
6775
with:
6876
php-version: ${{ matrix.php-version }}
77+
extensions: ${{ matrix.os == 'windows-latest' && 'pdo_sqlite,sqlite3,fileinfo,gd' || '' }}
6978
tools: flex
7079

7180
- name: Get composer cache directory
@@ -93,13 +102,54 @@ jobs:
93102
run: |
94103
source .github/workflows/.utils.sh
95104
96-
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} \
97-
'(cd src/{} \
98-
&& $COMPOSER_MIN_STAB \
99-
&& $COMPOSER_UP \
100-
&& if [ {} = LiveComponent ]; then install_property_info_for_version \"${{ matrix.php-version }}\" \"${{ matrix.minimum-stability }}\"; fi \
101-
&& $PHPUNIT)'"
102-
105+
# Create a non-exiting version of _run_task for sequential execution
106+
_run_task_sequential() {
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+
return $ok # Return instead of exit
125+
}
126+
127+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
128+
# parallel is not available on Windows, so we need to run the tests sequentially
129+
FAILED_PACKAGES=""
130+
for PACKAGE in $PACKAGES; do
131+
if ! PACKAGE="$PACKAGE" _run_task_sequential $PACKAGE \
132+
'(cd src/$PACKAGE \
133+
&& $COMPOSER_MIN_STAB \
134+
&& $COMPOSER_UP \
135+
&& if [ "$PACKAGE" = "LiveComponent" ]; then install_property_info_for_version \"${{ matrix.php-version }}\" \"${{ matrix.minimum-stability }}\"; fi \
136+
&& $PHPUNIT)'; then
137+
FAILED_PACKAGES="$FAILED_PACKAGES $PACKAGE"
138+
fi
139+
done
140+
141+
if [ -n "$FAILED_PACKAGES" ]; then
142+
echo "The following packages failed:$FAILED_PACKAGES"
143+
exit 1
144+
fi
145+
else
146+
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} \
147+
'(cd src/{} \
148+
&& $COMPOSER_MIN_STAB \
149+
&& $COMPOSER_UP \
150+
&& if [ {} = LiveComponent ]; then install_property_info_for_version \"${{ matrix.php-version }}\" \"${{ matrix.minimum-stability }}\"; fi \
151+
&& $PHPUNIT)'"
152+
fi
103153
js:
104154
runs-on: ubuntu-latest
105155
strategy:

0 commit comments

Comments
 (0)