-
Notifications
You must be signed in to change notification settings - Fork 206
185 lines (152 loc) · 7.53 KB
/
test.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
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
name: Performance check
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
comment-previews:
name: Create preview URLs and comment
# The job will only run if the pull request is from the same repository.
# Benchmarks can't run on PRs from forked repos due to comment posting restrictions without a GitHub token.
if: github.event.pull_request == null || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
- name: Checkout PR branch
uses: actions/checkout@v4
- name: Setup Job and Install Dependencies
uses: ./.github/actions/setup-job
- name: Post Previews Comment
uses: actions/github-script@v7
with:
script: |
const { buildPreviewURLComment } = await import('${{ github.workspace }}/tasks/build-preview-urls-comment.js');
const body = buildPreviewURLComment(process.env.GITHUB_HEAD_REF);
const { commentOrUpdate } = await import('${{ github.workspace }}/tasks/comment-or-update.js');
commentOrUpdate(github, context, '## Branch preview', body);
lighthouse:
name: Lighthouse CI
runs-on: ubuntu-22.04
needs: comment-previews
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
- name: Checkout PR branch
uses: actions/checkout@v4
- name: Setup Job and Install Dependencies
uses: ./.github/actions/setup-job
- name: Extract branch name
shell: bash
run: echo "branch=$(npx slugify-cli ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}})" >> $GITHUB_OUTPUT
id: extract_branch
- name: Run Lighthouse CI
id: lighthouse
uses: treosh/lighthouse-ci-action@v11
with:
budgetPath: '.github/lighthouse/budgets.json'
configPath: '.github/lighthouse/lighthouserc.json'
runs: 3
temporaryPublicStorage: true
uploadArtifacts: true
urls: |
https://opensource.adobe.com/spectrum-web-components/
https://main--spectrum-web-components.netlify.app/
https://${{ steps.extract_branch.outputs.branch }}--spectrum-web-components.netlify.app/
- name: Post Lighthouse Results Comment
uses: actions/github-script@v7
with:
script: |
const { buildLighthouseComment } = await import('${{ github.workspace }}/tasks/build-lighthouse-comment.js');
const body = buildLighthouseComment(${{ steps.lighthouse.outputs.links }}, ${{ steps.lighthouse.outputs.manifest }}, ${{ steps.lighthouse.outputs.assertionResults }});
const { commentOrUpdate } = await import('${{ github.workspace }}/tasks/comment-or-update.js');
commentOrUpdate(github, context, '## Lighthouse scores', body);
compare-firefox:
name: Compare performance to latest release on Firefox
# The job will only run if the pull request is from the same repository.
# Benchmarks can't run on PRs from forked repos due to comment posting restrictions without a GitHub token.
if: github.event.pull_request == null || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-22.04
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
- name: Checkout PR branch
uses: actions/checkout@v4
- name: Setup Job and Install Dependencies
uses: ./.github/actions/setup-job
- name: Print Firefox version
run: firefox --version
- name: Tachometer the changed packages
run: yarn test:changed --browser=firefox
- name: Create a dummy file to ensure at least one results file exists
run: touch tachometer.firefox-ran.txt
- name: Archive Firefox tachometer results
uses: actions/upload-artifact@v4
with:
name: tachometer-results-firefox
path: |
tach-results.firefox.*.json
tachometer.firefox-ran.txt
compare-chrome:
name: Compare performance to latest release on Chrome
# The job will only run if the pull request is from the same repository.
# Benchmarks can't run on PRs from forked repos due to comment posting restrictions without a GitHub token.
if: github.event.pull_request == null || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
- name: Checkout PR branch
uses: actions/checkout@v4
- name: Setup Job and Install Dependencies
uses: ./.github/actions/setup-job
- name: Tachometer the changed packages
run: yarn test:changed
- name: Create a dummy file to ensure at least one results file exists
run: touch tachometer.chrome-ran.txt
- name: Archive Chrome tachometer results
uses: actions/upload-artifact@v4
with:
name: tachometer-results-chrome
path: |
tach-results.*.json
tachometer.chrome-ran.txt
comment-performance:
name: Comment tachometer performance results
needs: [compare-chrome, compare-firefox]
# The job will only run if the pull request is from the same repository.
# Benchmarks can't run on PRs from forked repos due to comment posting restrictions without a GitHub token.
if: github.event.pull_request == null || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
- name: Checkout PR branch
uses: actions/checkout@v4
- name: Setup Job and Install Dependencies
uses: ./.github/actions/setup-job
- name: Retrieve tachometer results archives
uses: actions/download-artifact@v4
with:
name: tachometer-results-firefox
- name: Retrieve tachometer results archives
uses: actions/download-artifact@v4
with:
name: tachometer-results-chrome
- name: Post Tachometer Performance Comment
uses: actions/github-script@v7
with:
script: |
const { buildTachometerComment } = await import('${{ github.workspace }}/tasks/build-tachometer-comment.js');
const body = buildTachometerComment();
const { commentOrUpdate } = await import('${{ github.workspace }}/tasks/comment-or-update.js');
commentOrUpdate(github, context, '## Tachometer results', body);