forked from symfony/ux
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (152 loc) · 7.59 KB
/
unit-tests.yaml
File metadata and controls
177 lines (152 loc) · 7.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Unit Tests
defaults:
run:
shell: bash
on:
push:
branches-ignore:
- 'dependabot/**'
paths-ignore:
- '.github/workflows/app-tests.yaml'
- '.github/workflows/demo-native.yaml'
- 'apps/demo-native/**'
- 'apps/e2e/**'
- 'src/*/doc/**'
- 'src/**/*.md'
pull_request:
paths-ignore:
- '.github/workflows/app-tests.yaml'
- '.github/workflows/demo-native.yaml'
- 'apps/demo-native/**'
- 'apps/e2e/**'
- 'src/*/doc/**'
- 'src/**/*.md'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
php:
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']
dependency-version: ['']
symfony-version: ['']
minimum-stability: ['stable']
os: ['']
include:
- minimum-stability: 'dev'
php-version: '8.5'
# lowest deps
- php-version: '8.1'
dependency-version: 'lowest'
# LTS version of Symfony
- php-version: '8.1'
symfony-version: '6.4.*'
- php-version: '8.1'
symfony-version: '6.4.*'
os: 'windows-latest'
- php-version: '8.2'
symfony-version: '7.4.*'
- php-version: '8.2'
symfony-version: '7.4.*'
os: 'windows-latest'
# Explicit Symfony versions
- php-version: '8.4'
symfony-version: '8.0.*'
- php-version: '8.5'
symfony-version: '8.0.*'
env:
SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=5.4' }} # TODO: To change to '>=6.4' in 3.x
# https://github.com/spatie/phpunit-snapshot-assertions#usage-in-ci
CREATE_SNAPSHOTS: false
steps:
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
- name: Configure environment
run: |
echo COLUMNS=120 >> $GITHUB_ENV
echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.minimum-stability || 'stable' }} --ansi' >> $GITHUB_ENV
echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest' || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV
echo PHPUNIT='vendor/bin/simple-phpunit ${{ matrix.dependency-version == 'lowest' && '--exclude-group skip-on-lowest' || '' }} ${{ matrix.os == 'windows-latest' && '--exclude-group transient-on-windows' || '' }}' >> $GITHUB_ENV
[ 'lowest' = '${{ matrix.dependency-version }}' ] && export SYMFONY_DEPRECATIONS_HELPER=weak
# Swup and Typed have no tests, Turbo has its own workflow file
EXCLUDED_PACKAGES="Typed|Swup|Turbo"
# Exclude deprecated packages when testing against lowest dependencies
if [ "${{ matrix.dependency-version }}" = "lowest" ]; then
EXCLUDED_PACKAGES="$EXCLUDED_PACKAGES|LazyImage|TogglePassword|Svelte"
fi
PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | sed 's/^src\///' | grep -Ev "$EXCLUDED_PACKAGES" | sort | tr '\n' ' ')
echo "Packages: $PACKAGES"
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
- name: Setup PHP
uses: shivammathur/setup-php@690cb7c9d81dbfe51eba732cfca0a00ca42db777
with:
php-version: ${{ matrix.php-version }}
extensions: ${{ matrix.os == 'windows-latest' && 'pdo_sqlite,sqlite3,fileinfo,gd,zip' || '' }}
tools: flex
- name: Get composer cache directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache packages dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}-${{ matrix.minimum-stability }}-${{ hashFiles('src/**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}-${{ matrix.minimum-stability }}
- name: Install root dependencies
uses: ramsey/composer-install@5c2bcf28d7b060ef3c601d7b476d5430a7b46c27
with:
working-directory: ${{ github.workspace }}
- name: Build root packages
run: php .github/build-packages.php
- name: Run packages tests (Unix)
if: matrix.os != 'windows-latest'
run: |
source .github/workflows/.utils.sh
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} \
'(cd src/{} \
&& $COMPOSER_MIN_STAB \
&& before_composer_install \"{}\" \"${{ matrix.php-version }}\" \"${{ matrix.symfony-version }}\" \
&& $COMPOSER_UP \
&& after_composer_install \"{}\" \"${{ matrix.php-version }}\" \"${{ matrix.symfony-version }}\" \
&& $PHPUNIT)'"
- name: Run packages tests (Windows)
if: matrix.os == 'windows-latest'
run: |
source .github/workflows/.utils.sh
# parallel is not available on Windows, so we need to run the tests sequentially
FAILED_PACKAGES=""
for PACKAGE in $PACKAGES; do
if ! PACKAGE="$PACKAGE" _run_task_sequential $PACKAGE \
'(cd src/$PACKAGE \
&& $COMPOSER_MIN_STAB \
&& before_composer_install $PACKAGE ${{ matrix.php-version }} ${{ matrix.symfony-version }} \
&& $COMPOSER_UP \
&& after_composer_install $PACKAGE ${{ matrix.php-version }} ${{ matrix.symfony-version }} \
&& $PHPUNIT)'; then
FAILED_PACKAGES="$FAILED_PACKAGES $PACKAGE"
fi
done
if [ -n "$FAILED_PACKAGES" ]; then
echo "The following packages failed:$FAILED_PACKAGES"
exit 1
fi
js:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
- run: npm i -g corepack && corepack enable
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
cache-dependency-path: |
pnpm-lock.yaml
package.json
src/**/package.json
- name: Install root JS dependencies
run: pnpm install --frozen-lockfile
- run: pnpm run test:unit