-
Notifications
You must be signed in to change notification settings - Fork 266
163 lines (157 loc) · 5.48 KB
/
Copy pathtest.yml
File metadata and controls
163 lines (157 loc) · 5.48 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
name: Test
on:
push:
workflow_dispatch:
jobs:
testBrowser:
name: 'Test: Browsers'
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v6
env:
cache-name: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-modules-${{ env.cache-name }}-
${{ runner.os }}-modules-
${{ runner.os }}-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium firefox webkit
- name: Run browser tests
run: npm run test:browser
testNode:
name: 'Test: Node.js ${{ matrix.node-version }}'
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['22.x', '24.x', '26.x']
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v6
env:
cache-name: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ env.cache-name }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-modules-${{ env.cache-name }}--node-${{ matrix.node-version }}-
${{ runner.os }}-modules-${{ env.cache-name }}
${{ runner.os }}-modules-
${{ runner.os }}-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Run tests
run: npm test
testTypes:
name: 'Test: Types'
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
- name: Install dependencies
run: npm ci
- name: Check type compatibility
run: npm run test:types
testDeno:
name: 'Test: Deno'
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Install dependencies
run: deno install
- name: Run tests
run: npm run test:deno
testBun:
name: 'Test: Bun'
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Dependencies
run: bun install --frozen-lockfile
- name: Run tests
run: npm run test:bun
# Known-failing environments, reported but never gating.
#
# happy-dom reports the test server's requests as cross-origin and blocks them. workerd's
# remaining failures all trace to cloudflare/workerd#6022, where its `EventTarget` dispatches
# `on<type>` handler properties itself and so fires our `on*` handlers twice.
#
# `continue-on-error` is deliberately on the *step* rather than the job. At job level it keeps
# the overall run green but the job still reports a check run with a `failure` conclusion, which
# is what puts a red X on the commit. At step level the job itself succeeds, so the commit stays
# green, and the outcome is written to the run summary to keep the result visible. Move
# `continue-on-error` up to the job (or drop it) once these are expected to pass.
testKnownFailing:
name: 'Test: ${{ matrix.suite }} (informational)'
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
suite: ['happy-dom', 'workerd']
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
- name: Install dependencies
run: npm ci
- name: Run tests
id: tests
continue-on-error: true
run: |
# `pipefail` is not set in the default shell, so without it `tee` swallows the exit
# code and the step reports success no matter what the suite did.
set -o pipefail
npm run test:${{ matrix.suite }} 2>&1 | tee /tmp/${{ matrix.suite }}.log
- name: Summarise
if: always()
run: |
# Vitest forces colour on in CI, so the escape sequences have to come off before
# anything can be matched at the start of a line.
sed -E 's/\x1b\[[0-9;]*[mGKH]//g' '/tmp/${{ matrix.suite }}.log' > /tmp/plain.log
{
if [ '${{ steps.tests.outcome }}' = 'success' ]; then
echo '### ${{ matrix.suite }}: passing 🎉'
echo
echo 'This environment is no longer failing. It can be promoted to a gating job.'
else
echo '### ${{ matrix.suite }}: failing, as expected'
echo
echo '```'
grep -E '^ +(Tests|Test Files) ' /tmp/plain.log || true
echo '```'
echo
grep -E '^ FAIL ' /tmp/plain.log | sed 's/^ FAIL /- /' || true
fi
} | tee -a "$GITHUB_STEP_SUMMARY"