-
-
Notifications
You must be signed in to change notification settings - Fork 266
188 lines (156 loc) · 5.23 KB
/
ci.yml
File metadata and controls
188 lines (156 loc) · 5.23 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Run lint
run: pnpm lint:ci
unit_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Run tests
run: pnpm test:ci
- name: Upload coverage artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: vitest-coverage
path: vitest-coverage
e2e_tests:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Install Playwright Browsers
run: pnpm playwright install --with-deps
- name: Run e2e tests
env:
AIRTABLE_PAT: ${{ secrets.AIRTABLE_PAT }}
run: pnpm test:e2e:headless
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Comment PR with Playwright artifact link
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const runId = context.runId;
const repo = context.repo;
const artifactUrl = `https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId}`;
const identifier = '<!-- playwright-test-status -->';
// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: repo.owner,
repo: repo.repo,
});
const existingComment = comments.find(comment =>
comment.body?.includes(identifier)
);
// Determine if tests passed or failed
const testsFailed = '${{ job.status }}' !== 'success';
if (testsFailed) {
const comment = `${identifier}
## ❌ Playwright Tests Failed
The Playwright tests have failed. Please download the test report artifact to see detailed information about the failures:
📊 [View test run and download artifact](${artifactUrl})
**How to view the report:**
1. Click the link above
2. Scroll to the bottom to the "Artifacts" section
3. Download the \`playwright-report\` artifact
4. Extract the zip file and open \`index.html\` in your browser
The report includes screenshots, videos, and detailed traces of the failed tests.`;
if (existingComment) {
await github.rest.issues.updateComment({
owner: repo.owner,
repo: repo.repo,
comment_id: existingComment.id,
body: comment
});
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: repo.owner,
repo: repo.repo,
body: comment
});
}
} else if (existingComment) {
// Tests passed - delete the failure comment
await github.rest.issues.deleteComment({
owner: repo.owner,
repo: repo.repo,
comment_id: existingComment.id
});
}
report_coverage:
runs-on: ubuntu-latest
needs: unit_tests
if: always() && github.event_name == 'pull_request'
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Download Coverage Artifact
uses: actions/download-artifact@v4
with:
name: vitest-coverage
path: vitest-coverage
- name: Report Coverage
uses: davelosert/vitest-coverage-report-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
json-summary-path: vitest-coverage/coverage-summary.json
json-final-path: vitest-coverage/coverage-final.json
file-coverage-mode: changes