-
Notifications
You must be signed in to change notification settings - Fork 12
238 lines (226 loc) · 6.92 KB
/
pull-request.yaml
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
name: Pull Request
on:
pull_request:
types: [opened, edited, synchronize, reopened]
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions: write-all
jobs:
check-pr-title:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.13.1
cache: 'npm'
- run: npm ci
- name: Check PR title
uses: JulienKode/pull-request-name-linter-action@v0.5.0
with:
configuration-path: ./commitlint.config.js
check-test-requirements:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.13.1
- name: Install dependencies
run: npm install @actions/core @actions/github
- name: Check PR Type and Tests
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const script = require('./test-enforcement.js')
await script({github, context, core})
check-linting:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.13.1
cache: 'npm'
- name: Install
run: npm ci
- name: Lint
run: npm run lint
check-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.13.1
cache: 'npm'
- name: Install
run: npm ci
- name: Build
run: npm run build
run-unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.13.1
- name: Install
run: npm ci
- name: Coverage
run: npm run test:unit
check-coverage-thresholds:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.13.1
- name: Install
run: npm ci
- name: Coverage
run: npm run test:coverage
deployment:
needs: check-build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
record-web-vitals:
runs-on: ubuntu-latest
needs: deployment
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.13.1
cache: 'npm'
- name: Install dependencies
run: |
npm ci
npm install puppeteer web-vitals
- name: Install Chrome dependencies
run: |
sudo apt-get update
sudo apt-get install -y xvfb libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2
- name: Record Web Vitals
id: record-vitals
continue-on-error: true
run: |
xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24" node scripts/record-web-vitals.js
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
GITHUB_EVENT_NAME: 'pull_request'
GITHUB_EVENT_ACTION: 'closed'
GITHUB_PULL_REQUEST_MERGED: 'true'
- name: Create PR Comment
if: always()
uses: actions/github-script@v6
with:
script: |
let metrics;
try {
const fs = require('fs');
metrics = JSON.parse(fs.readFileSync('.github/current-metrics.json', 'utf8'));
} catch (error) {
console.log('Error reading metrics file:', error);
metrics = {
date: new Date().toISOString(),
metrics: {
lcp: null,
fid: null,
cls: null
}
};
}
const formatMetric = (value) => {
if (value === null) return 'N/A';
return value.toFixed(2);
};
const comment = `## Core Web Vitals Metrics
| Metric | Value |
|--------|-------|
| LCP | ${formatMetric(metrics.metrics?.lcp)} s |
| FID | ${formatMetric(metrics.metrics?.fid)} ms |
| CLS | ${formatMetric(metrics.metrics?.cls)} |
Recorded at: ${metrics.date}
PR: #${context.issue.number}`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
run-e2e-tests:
runs-on: ubuntu-latest
needs: deployment
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Chrome
uses: browser-actions/setup-chrome@v1
with:
chrome-version: 'stable'
- uses: actions/setup-node@v3
with:
node-version: 16.13.1
- name: Install
run: npm ci
- name: Install Matching ChromeDriver
run: |
CHROME_VERSION=$(google-chrome --version | cut -d' ' -f3 | cut -d'.' -f1)
npm install chromedriver@$CHROME_VERSION
- name: E2E
run: npm run test:e2e-prod
run-accessibility-checks:
runs-on: ubuntu-latest
needs: deployment
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.0.0x
uses: actions/setup-node@v3
with:
node-version: 18.0.0
- name: Run pa11y
run: |
npm install -g pa11y@latest
pa11y https://adobecom.github.io/caas/ --timeout=10000 --threshold 20 --debug
run-lighthouse-checks:
runs-on: ubuntu-latest
needs: deployment
steps:
- uses: actions/checkout@master
- name: Lighthouse
uses: foo-software/lighthouse-check-action@master
id: lighthouseCheck
with:
urls: 'https://adobecom.github.io/caas/'
- name: Verify Lighthouse Check results
uses: foo-software/lighthouse-check-status-action@master
with:
lighthouseCheckResults: ${{ steps.lighthouseCheck.outputs.lighthouseCheckResults }}
minAccessibilityScore: "80"
minBestPracticesScore: "80"
minPerformanceScore: "30"
minProgressiveWebAppScore: "30"
minSeoScore: "70"