-
Notifications
You must be signed in to change notification settings - Fork 1.5k
331 lines (325 loc) · 12.5 KB
/
Copy pathbuild_and_test.yml
File metadata and controls
331 lines (325 loc) · 12.5 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
name: Build & Test
on:
workflow_dispatch:
push:
branches:
- master
- minor
- major
paths:
- 'packages/**'
- 'package.json'
- 'bun.lock'
- 'bunfig.toml'
pull_request:
branches:
- master
- major
- minor
env:
CI: true
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# NOTE: The Redis service definition is duplicated across the e2e-* jobs
# because GitHub Actions does not support YAML anchors or service definition reuse.
# When updating the service (version bumps, env changes, health checks), update ALL four copies:
# e2e-sqljs, e2e-mariadb, e2e-mysql, e2e-postgres.
jobs:
detect-changes:
name: detect changes
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
packages: ${{ steps.check.outputs.packages }}
dashboard: ${{ steps.check.outputs.dashboard }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
fetch-depth: 0
- name: Detect changed paths
id: check
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "packages=true" >> "$GITHUB_OUTPUT"
echo "dashboard=true" >> "$GITHUB_OUTPUT"
exit 0
fi
base="${{ github.event.pull_request.base.sha }}"
if [ -z "$base" ]; then base="${{ github.event.before }}"; fi
if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ]; then
base="HEAD~1"
fi
changed=$(git diff --name-only "$(git merge-base "$base" HEAD)" HEAD)
if echo "$changed" | grep -qE '^(packages/|package\.json|bun\.lock|bunfig\.toml)'; then
echo "packages=true" >> "$GITHUB_OUTPUT"
else
echo "packages=false" >> "$GITHUB_OUTPUT"
fi
if echo "$changed" | grep -q '^packages/dashboard/'; then
echo "dashboard=true" >> "$GITHUB_OUTPUT"
else
echo "dashboard=false" >> "$GITHUB_OUTPUT"
fi
codegen:
needs: detect-changes
if: needs.detect-changes.outputs.packages == 'true'
uses: ./.github/workflows/codegen.yml
build:
name: build
needs: detect-changes
if: needs.detect-changes.outputs.packages == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- uses: ./.github/actions/setup
- name: Build
run: bun run build
unit-tests:
name: unit tests
needs: detect-changes
if: needs.detect-changes.outputs.packages == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
node: [20.x, 22.x, 24.x]
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- name: Build
run: bunx lerna run ci
- name: Unit tests
run: bun run test
dashboard-i18n:
name: dashboard i18n sync
needs: detect-changes
if: needs.detect-changes.outputs.dashboard == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- uses: ./.github/actions/setup
- name: Check i18n catalogs are in sync
working-directory: packages/dashboard
run: bash scripts/check-i18n-sync.sh
dashboard-e2e:
name: dashboard e2e (${{ matrix.shard }})
needs: detect-changes
if: needs.detect-changes.outputs.dashboard == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- uses: ./.github/actions/setup
- name: Build
run: bunx lerna run ci --scope @vendure/testing --include-dependencies
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ~/.cache/ms-playwright
# The key version prefix (v2) lets us evict caches poisoned by an
# earlier incomplete browser install. No restore-keys: a prefix
# fallback would drag stale browser binaries forward on a Playwright
# version bump, and an exact hit on that poisoned cache then skips
# the install step indefinitely.
key: playwright-v2-${{ runner.os }}-${{ hashFiles('**/bun.lock') }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
# chromium-headless-shell is a separate download since Playwright 1.49
# and is what headless CI runs actually launch.
run: bunx playwright install chromium chromium-headless-shell
working-directory: packages/dashboard
- name: Install Playwright system deps
run: bunx playwright install-deps chromium
working-directory: packages/dashboard
- name: Dashboard e2e tests
run: bun run e2e:pw -- --shard=${{ matrix.shard }}/4
working-directory: packages/dashboard
sonarqube:
name: SonarQube
needs: detect-changes
if: needs.detect-changes.outputs.packages == 'true' && (github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
fetch-depth: 0
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 # v6
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
e2e-sqljs:
name: e2e (sqljs)
needs: detect-changes
if: needs.detect-changes.outputs.packages == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
services:
redis:
image: redis:7.4.1
ports:
- 6379
strategy:
fail-fast: false
matrix:
node: ${{ github.event_name == 'pull_request' && fromJSON('["22.x"]') || fromJSON('["20.x", "22.x", "24.x"]') }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- name: Build
run: bunx lerna run ci
- name: e2e tests
env:
E2E_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DB: sqljs
run: bun run e2e
e2e-mariadb:
name: e2e (mariadb)
needs: detect-changes
if: needs.detect-changes.outputs.packages == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
services:
mariadb:
# With v11.6.2+, a default was changed, (https://mariadb.com/kb/en/innodb-system-variables/#innodb_snapshot_isolation)
# which causes e2e test failures currently
image: mariadb:11.5
env:
MARIADB_ROOT_PASSWORD: password
ports:
- 3306
options: --health-cmd="mariadb-admin ping -h localhost -u vendure -ppassword" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis:7.4.1
ports:
- 6379
strategy:
fail-fast: false
matrix:
node: ${{ github.event_name == 'pull_request' && fromJSON('["22.x"]') || fromJSON('["20.x", "22.x", "24.x"]') }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- name: Build
run: bunx lerna run ci
- name: e2e tests
env:
E2E_MARIADB_PORT: ${{ job.services.mariadb.ports['3306'] }}
E2E_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DB: mariadb
run: bun run e2e
e2e-mysql:
name: e2e (mysql)
needs: detect-changes
if: needs.detect-changes.outputs.packages == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
services:
mysql:
image: vendure/mysql-8-native-auth:latest
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 3306
options: --health-cmd="mysqladmin ping --silent" --health-interval=10s --health-timeout=20s --health-retries=10
redis:
image: redis:7.4.1
ports:
- 6379
strategy:
fail-fast: false
matrix:
node: ${{ github.event_name == 'pull_request' && fromJSON('["22.x"]') || fromJSON('["20.x", "22.x", "24.x"]') }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- name: Build
run: bunx lerna run ci
- name: e2e tests
env:
E2E_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
E2E_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DB: mysql
run: bun run e2e
e2e-postgres:
name: e2e (postgres)
needs: detect-changes
if: needs.detect-changes.outputs.packages == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: vendure
POSTGRES_PASSWORD: password
ports:
- 5432
options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis:7.4.1
ports:
- 6379
strategy:
fail-fast: false
matrix:
node: ${{ github.event_name == 'pull_request' && fromJSON('["22.x"]') || fromJSON('["20.x", "22.x", "24.x"]') }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}
- name: Build
run: bunx lerna run ci
- name: e2e tests
env:
E2E_POSTGRES_PORT: ${{ job.services.postgres.ports['5432'] }}
E2E_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DB: postgres
run: bun run e2e
all-passed:
name: all-passed
runs-on: ubuntu-latest
permissions: {}
if: always()
needs:
- detect-changes
- codegen
- build
- unit-tests
- dashboard-i18n
- dashboard-e2e
- sonarqube
- e2e-sqljs
- e2e-mariadb
- e2e-mysql
- e2e-postgres
steps:
- run: exit ${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && 1 || 0 }}