-
Notifications
You must be signed in to change notification settings - Fork 1
171 lines (148 loc) · 4.95 KB
/
Copy pathe2e.yml
File metadata and controls
171 lines (148 loc) · 4.95 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
name: E2E Tests
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
pull-requests: read
concurrency:
group: e2e-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
direct_push_check:
name: Detect direct push to main
runs-on: ubuntu-latest
outputs:
is_direct: ${{ steps.detect.outputs.is_direct }}
steps:
- name: Determine if commit belongs to a PR
id: detect
uses: actions/github-script@v8
with:
script: |
if (context.eventName !== 'push' || context.ref !== 'refs/heads/main') {
// Only `push` to `main` needs direct-vs-merge detection.
core.setOutput('is_direct', 'false')
return
}
const sha = context.sha
// If this commit is associated with any PR, it's almost certainly coming from a PR merge.
// Direct pushes to main won't have associated PRs.
const { data } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: sha,
})
core.setOutput('is_direct', String(data.length === 0))
e2e:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.57.0-jammy
options: --ipc=host
needs: [direct_push_check]
if: |
github.event_name == 'pull_request' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.direct_push_check.outputs.is_direct == 'true')
env:
# Playwright's Firefox won't launch in the container unless $HOME is owned by the current user.
HOME: /root
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- browser: chromium
shardIndex: 1
shardTotal: 2
- browser: chromium
shardIndex: 2
shardTotal: 2
- browser: firefox
shardIndex: 1
shardTotal: 2
- browser: firefox
shardIndex: 2
shardTotal: 2
# WebKit is consistently slower; split into more shards so no single job dominates.
- browser: webkit
shardIndex: 1
shardTotal: 3
- browser: webkit
shardIndex: 2
shardTotal: 3
- browser: webkit
shardIndex: 3
shardTotal: 3
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install unzip
run: apt-get update && apt-get install -y unzip
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Cache Bun install + node_modules
uses: actions/cache@v4
with:
path: |
~/.bun/install/cache
node_modules
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build app
run: bun run build
- name: Run E2E tests (headless)
env:
CI: true
E2E_BROWSERS: ${{ matrix.browser }}
run: bun run test:e2e -- --project=${{ matrix.browser }} --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Upload Playwright blob report
if: always()
uses: actions/upload-artifact@v6
with:
name: playwright-blob-${{ matrix.browser }}-${{ matrix.shardIndex }}of${{ matrix.shardTotal }}
path: blob-report/
if-no-files-found: ignore
e2e_report:
name: Merge Playwright report
runs-on: ubuntu-latest
# Skip when `e2e` did not run (e.g. merge push to main); merge-reports fails with no blob artifacts.
if: ${{ !cancelled() && (needs.e2e.result == 'success' || needs.e2e.result == 'failure') }}
needs: [direct_push_check, e2e]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install unzip
run: sudo apt-get update && sudo apt-get install -y unzip
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Cache Bun install + node_modules
uses: actions/cache@v4
with:
path: |
~/.bun/install/cache
node_modules
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Download all blob reports
uses: actions/download-artifact@v6
with:
pattern: playwright-blob-*
path: playwright-blobs
merge-multiple: true
- name: Merge HTML report
run: bunx playwright merge-reports --reporter=html playwright-blobs
- name: Upload Playwright HTML report
uses: actions/upload-artifact@v6
with:
name: playwright-report
path: playwright-report/
if-no-files-found: ignore