generated from stacks-network/.github
-
Notifications
You must be signed in to change notification settings - Fork 102
141 lines (140 loc) · 5.79 KB
/
lighthouse.yml
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
name: PR Deploy and Audit
on: [pull_request]
jobs:
deploy_and_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Vercel Action
id: vercel_action
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID}}
vercel-project-id: ${{ secrets.PROJECT_ID}}
scope: ${{ secrets.VERCEL_SCOPE }}
- name: Add comment to PR
id: loading_lighthouse_comment_to_pr
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse
message: |
🚦 Running Lighthouse audit...
- name: Add comment to PR
id: loading_budget_comment_to_pr
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: budget
message: |
⏱ Running budget checks...
- name: Audit URLs using Lighthouse
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v7
with:
# add as many urls here as you wish to audit
# prefixed by the preview-url
urls: |
https://explorer-git-prod-reference-blockstack.vercel.app/
https://explorer-git-prod-reference-blockstack.vercel.app/txid/0xa176909e4681cf41cf8662ce51ffcf109fb2fdb2aeae6bb8425d236241debe3f
https://explorer-git-prod-reference-blockstack.vercel.app/address/SM2MARAVW6BEJCD13YV2RHGYHQWT7TDDNMNRB1MVT
https://explorer-git-prod-reference-blockstack.vercel.app/block/0xe1c163a23ce0fa8a552b5237c25bc36f3ec0612eb8a01322d9f154f09163b1a0
${{ steps.vercel_action.outputs.preview-url }}
${{ steps.vercel_action.outputs.preview-url }}/txid/0xa176909e4681cf41cf8662ce51ffcf109fb2fdb2aeae6bb8425d236241debe3f
${{ steps.vercel_action.outputs.preview-url }}/address/SM2MARAVW6BEJCD13YV2RHGYHQWT7TDDNMNRB1MVT
${{ steps.vercel_action.outputs.preview-url }}/block/0xe1c163a23ce0fa8a552b5237c25bc36f3ec0612eb8a01322d9f154f09163b1a0
budgetPath: '.github/lighthouse/budget.json'
uploadArtifacts: true
temporaryPublicStorage: true
runs: 3
- name: Format lighthouse result
id: lighthouse_result
if: ${{ always() }}
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const links = ${{ steps.lighthouse_audit.outputs.links }}
const results = (${{ steps.lighthouse_audit.outputs.manifest }}).filter(result => result.isRepresentativeRun);
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴';
const comment = results.map((result) => {
const summary = result.summary;
const url = result.url;
return `
🌎 [${url}](${url})
⚡️ [Lighthouse report](${links[url]})
| Category | Score |
| --- | --- |
${Object.keys(summary).map((key) => {
const percentage = Math.round(summary[key] * 100);
return `| ${score(percentage)} ${key} | ${percentage} |`;
}).join('\n')}
`;
}).join('---');
core.setOutput("comment", comment);
- name: Format budget result
id: budget_result
if: ${{ always() }}
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const assertions = ${{ steps.lighthouse_audit.outputs.assertionResults }};
if (!assertions.length) {
core.setOutput("comment", '✅ Budget met, nothing to see here');
} else {
const comment = assertions.map((result) => {
return `
❌ **${result.auditProperty || ''}.${result.auditId}** failure on [${result.url}](${result.url})
*${result.auditTitle}* - [docs](${result.auditDocumentationLink})
| Actual | Expected |
| --- | --- |
| ${result.actual} | ${result.operator} ${result.expected} |
`;
}).join('---');
core.setOutput("comment", comment);
}
- name: Add Lighthouse comment to PR
id: lighthouse_comment_to_pr
if: ${{ always() }}
uses: marocchino/sticky-pull-request-comment@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse
message: |
${{ steps.lighthouse_result.outputs.comment }}
- name: Add Budget comment to PR
id: budget_comment_to_pr
if: ${{ always() }}
uses: marocchino/sticky-pull-request-comment@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: budget
message: |
${{ steps.budget_result.outputs.comment }}
test_e2e:
needs: test_setup
name: Playwright tests
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Prepare testing env
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18.9.0'
- run: npm install -g pnpm
- run: pnpm i
- run: npx playwright install --with-deps
- name: Run tests
run: |
xvfb-run --auto-servernum -- \
pnpm run test:e2e
env:
PLAYWRIGHT_TEST_BASE_URL: ${{ steps.vercel_action.outputs.preview-url }}