A shareable package of CircleCI configuration to integrate with lighthouse-check, written by foo-software
CommunityCode AnalysisUse CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1Add the orbs stanza below your version, invoking the orb:
1
2
orbs:
lighthouse-check: foo-software/lighthouse-check@0.0.13Use lighthouse-check elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Run a Lighthouse audit with advanced settings.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
jobs:
test:
executor: lighthouse-check/default
steps:
- lighthouse-check/audit:
awsAccessKeyId: $LIGHTHOUSE_CHECK_AWS_ACCESS_KEY_ID
awsBucket: $LIGHTHOUSE_CHECK_AWS_BUCKET
awsRegion: $LIGHTHOUSE_CHECK_AWS_REGION
awsSecretAccessKey: $LIGHTHOUSE_CHECK_AWS_SECRET_ACCESS_KEY
slackWebhookUrl: $LIGHTHOUSE_CHECK_SLACK_WEBHOOK_URL
urls: https://www.foo.software,https://www.foo.software/contact
- lighthouse-check/validate-status:
minAccessibilityScore: '50'
minBestPracticesScore: '50'
minPerformanceScore: '99'
minProgressiveWebAppScore: '50'
minSeoScore: '50'
orbs:
lighthouse-check: foo-software/lighthouse-check@0.0.8
version: 2.1
workflows:
test:
jobs:
- test
Run a Lighthouse audits from foo.software.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
jobs:
test:
executor: lighthouse-check/default
steps:
- lighthouse-check/audit:
apiToken: $LIGHTHOUSE_CHECK_API_TOKEN
urls: mypagetoken1,mypagetoken2
orbs:
lighthouse-check: foo-software/lighthouse-check@0.0.8
version: 2.1
workflows:
test:
jobs:
- test
Run a Lighthouse audits from foo.software and posts results as PR comments.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
jobs:
test:
executor: lighthouse-check/default
steps:
- lighthouse-check/audit:
apiToken: $LIGHTHOUSE_CHECK_API_TOKEN
prCommentAccessToken: $LIGHTHOUSE_CHECK_ACCESS_TOKEN
prCommentUrl: >-
https://api.github.com/repos/foo-software/lighthouse-check-orb/pulls/${CIRCLE_PULL_REQUEST##*/}/reviews
urls: mypagetoken1,mypagetoken2
orbs:
lighthouse-check: foo-software/lighthouse-check@0.0.8
version: 2.1
workflows:
test:
jobs:
- test
Run a simple Lighthouse audit with extra headers.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
jobs:
test:
executor: lighthouse-check/default
steps:
- lighthouse-check/audit:
extraHeaders: '{ "x-hello-world": "foobar", "x-some-other-thing": "hi" }'
urls: https://lighthouse-check-action.now.sh/
orbs:
lighthouse-check: foo-software/lighthouse-check@0.0.13
version: 2.1
workflows:
test:
jobs:
- test
Run a simple Lighthouse audit.
1
2
3
4
5
6
7
8
9
10
11
12
13
jobs:
test:
executor: lighthouse-check/default
steps:
- lighthouse-check/audit:
urls: https://www.foo.software,https://www.foo.software/contact
orbs:
lighthouse-check: foo-software/lighthouse-check@0.0.6
version: 2.1
workflows:
test:
jobs:
- test
Run a Lighthouse audit and save results
| PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
|---|---|---|---|---|
apiToken The foo.software account API token found in the dashboard. | The foo.software account API token found in the dashboard. | No | '' type: string | string |
author For Slack notifications - A user handle, typically from GitHub. | For Slack notifications - A user handle, typically from GitHub. | No | $CIRCLE_USERNAME type: string | string |
awsAccessKeyId The AWS accessKeyId for an S3 bucket for optional HTML report upload. | The AWS accessKeyId for an S3 bucket for optional HTML report upload. | No | $LIGHTHOUSE_CHECK_AWS_ACCESS_KEY_ID type: string | string |
awsBucket The AWS Bucket for an S3 bucket for optional HTML report upload. | The AWS Bucket for an S3 bucket for optional HTML report upload. | No | $LIGHTHOUSE_CHECK_AWS_BUCKET type: string | string |
awsRegion The AWS region for an S3 bucket for optional HTML report upload. | The AWS region for an S3 bucket for optional HTML report upload. | No | $LIGHTHOUSE_CHECK_AWS_REGION type: string | string |
awsSecretAccessKey The AWS secretAccessKey for an S3 bucket for optional HTML report upload. | The AWS secretAccessKey for an S3 bucket for optional HTML report upload. | No | $LIGHTHOUSE_CHECK_AWS_SECRET_ACCESS_KEY type: string | string |
branch For Slack notifications - A version control branch, typically from GitHub. | For Slack notifications - A version control branch, typically from GitHub. | No | $CIRCLE_BRANCH type: string | string |
configFile A configuration file path in JSON format which holds all options defined here. This file should be relative to the file being interpretted. In this case it will most likely be the root of the repo ("./") | A configuration file path in JSON format which holds all options defined here. This file should be relative to the file being interpretted. In this case it will most likely be the root of the repo ("./") | No | '' type: string | string |
emulatedFormFactor Lighthouse setting only used for local audits. See lighthouse-check NPM module for details. | Lighthouse setting only used for local audits. See lighthouse-check NPM module for details. | No | '' type: string | string |
extraHeaders Stringified HTTP Header object key/value pairs to send in requests. | Stringified HTTP Header object key/value pairs to send in requests. | No | '' type: string | string |
locale A locale for Lighthouse reports. Example - ja | A locale for Lighthouse reports. Example - ja | No | '' type: string | string |
maxWaitForLoad The maximum amount of time to wait for a page to load in ms | The maximum amount of time to wait for a page to load in ms | No | 45000 type: integer | integer |
overridesJsonFile A JSON file with config and option fields to overrides defaults. | A JSON file with config and option fields to overrides defaults. | No | '' type: string | string |
pr For Slack notifications - A version control pull request URL, typically from GitHub. | For Slack notifications - A version control pull request URL, typically from GitHub. | No | $CIRCLE_PULL_REQUEST type: string | string |
prCommentAccessToken Access token of a user to post PR comments. | Access token of a user to post PR comments. | No | '' type: string | string |
prCommentEnabled If true and accessToken is set scores will be posted as comments. | If true and accessToken is set scores will be posted as comments. | No | true type: boolean | boolean |
prCommentSaveOld If true and PR comment options are set, new comments will be posted on every change vs only updating once comment with most recent scores. | If true and PR comment options are set, new comments will be posted on every change vs only updating once comment with most recent scores. | No | false type: boolean | boolean |
prCommentUrl An endpoint to post comments to. Typically this will from GitHub's API. Example: https://api.github.com/repos/:owner/:repo/pulls/:pull_number/reviews | An endpoint to post comments to. Typically this will from GitHub's API. Example: https://api.github.com/repos/:owner/:repo/pulls/:pull_number/reviews | No | '' type: string | string |
sha For Slack notifications - A version control sha, typically from GitHub. | For Slack notifications - A version control sha, typically from GitHub. | No | $CIRCLE_SHA1 type: string | string |
slackWebhookUrl A Slack Incoming Webhook URL to send notifications to. | A Slack Incoming Webhook URL to send notifications to. | No | $LIGHTHOUSE_CHECK_SLACK_WEBHOOK_URL type: string | string |
tag An optional tag or name (example: "build #2" or "v0.0.2"). | An optional tag or name (example: "build #2" or "v0.0.2"). | No | '' type: string | string |
throttling Lighthouse setting only used for local audits. See lighthouse-check NPM module comments for details. | Lighthouse setting only used for local audits. See lighthouse-check NPM module comments for details. | No | '' type: string | string |
throttlingMethod Lighthouse setting only used for local audits. See lighthouse-check NPM module comments for details. | Lighthouse setting only used for local audits. See lighthouse-check NPM module comments for details. | No | '' type: string | string |
timeout Minutes to timeout for remote runs. If "wait" option is "true" (it is by default), we wait for results. If this timeout is met before results are received an error is thrown. | Minutes to timeout for remote runs. If "wait" option is "true" (it is by default), we wait for results. If this timeout is met before results are received an error is thrown. | No | 10 type: integer | integer |
urls A comma-separated list of URLs (or page API tokens if running remotely). | A comma-separated list of URLs (or page API tokens if running remotely). | No | '' type: string | string |
wait If "true", for remote runs, waits for all audit results to be returned, otherwise URLs are only enqueued. | If "true", for remote runs, waits for all audit results to be returned, otherwise URLs are only enqueued. | No | true type: boolean | boolean |
Validate results of Lighthouse audits from minimum score requirements. Fail the job if requirements aren't met.
| PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
|---|---|---|---|---|
minAccessibilityScore The minimum accessibility Lighthouse score required. | The minimum accessibility Lighthouse score required. | No | '' type: string | string |
minBestPracticesScore The minimum best practices Lighthouse score required. | The minimum best practices Lighthouse score required. | No | '' type: string | string |
minPerformanceScore The minimum performance Lighthouse score required. | The minimum performance Lighthouse score required. | No | '' type: string | string |
minProgressiveWebAppScore The minimum progressive web app Lighthouse score required. | The minimum progressive web app Lighthouse score required. | No | '' type: string | string |
minSeoScore The minimum SEO Lighthouse score required. | The minimum SEO Lighthouse score required. | No | '' type: string | string |
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
commands:
audit:
description: Run a Lighthouse audit and save results
parameters:
apiToken:
default: ""
description: The foo.software account API token found in the dashboard.
type: string
author:
default: $CIRCLE_USERNAME
description: For Slack notifications - A user handle, typically from GitHub.
type: string
awsAccessKeyId:
default: $LIGHTHOUSE_CHECK_AWS_ACCESS_KEY_ID
description: The AWS accessKeyId for an S3 bucket for optional HTML report
upload.
type: string
awsBucket:
default: $LIGHTHOUSE_CHECK_AWS_BUCKET
description: The AWS Bucket for an S3 bucket for optional HTML report upload.
type: string
awsRegion:
default: $LIGHTHOUSE_CHECK_AWS_REGION
description: The AWS region for an S3 bucket for optional HTML report upload.
type: string
awsSecretAccessKey:
default: $LIGHTHOUSE_CHECK_AWS_SECRET_ACCESS_KEY
description: The AWS secretAccessKey for an S3 bucket for optional HTML report
upload.
type: string
branch:
default: $CIRCLE_BRANCH
description: For Slack notifications - A version control branch, typically
from GitHub.
type: string
configFile:
default: ""
description: A configuration file path in JSON format which holds all options
defined here. This file should be relative to the file being interpretted.
In this case it will most likely be the root of the repo ("./")
type: string
emulatedFormFactor:
default: ""
description: Lighthouse setting only used for local audits. See lighthouse-check
NPM module for details.
type: string
extraHeaders:
default: ""
description: Stringified HTTP Header object key/value pairs to send in requests.
type: string
locale:
default: ""
description: A locale for Lighthouse reports. Example - ja
type: string
maxWaitForLoad:
default: 45000
description: The maximum amount of time to wait for a page to load in ms
type: integer
overridesJsonFile:
default: ""
description: A JSON file with config and option fields to overrides defaults.
type: string
pr:
default: $CIRCLE_PULL_REQUEST
description: For Slack notifications - A version control pull request URL,
typically from GitHub.
type: string
prCommentAccessToken:
default: ""
description: Access token of a user to post PR comments.
type: string
prCommentEnabled:
default: true
description: If true and accessToken is set scores will be posted as comments.
type: boolean
prCommentSaveOld:
default: false
description: If true and PR comment options are set, new comments will be
posted on every change vs only updating once comment with most recent scores.
type: boolean
prCommentUrl:
default: ""
description: 'An endpoint to post comments to. Typically this will from GitHub''s
API. Example: https://api.github.com/repos/:owner/:repo/pulls/:pull_number/reviews'
type: string
sha:
default: $CIRCLE_SHA1
description: For Slack notifications - A version control sha, typically from
GitHub.
type: string
slackWebhookUrl:
default: $LIGHTHOUSE_CHECK_SLACK_WEBHOOK_URL
description: A Slack Incoming Webhook URL to send notifications to.
type: string
tag:
default: ""
description: 'An optional tag or name (example: "build #2" or "v0.0.2").'
type: string
throttling:
default: ""
description: Lighthouse setting only used for local audits. See lighthouse-check
NPM module comments for details.
type: string
throttlingMethod:
default: ""
description: Lighthouse setting only used for local audits. See lighthouse-check
NPM module comments for details.
type: string
timeout:
default: 10
description: Minutes to timeout for remote runs. If "wait" option is "true"
(it is by default), we wait for results. If this timeout is met before results
are received an error is thrown.
type: integer
urls:
default: ""
description: A comma-separated list of URLs (or page API tokens if running
remotely).
type: string
wait:
default: true
description: If "true", for remote runs, waits for all audit results to be
returned, otherwise URLs are only enqueued.
type: boolean
steps:
- run:
command: |
mkdir /tmp/artifacts
echo "<< parameters.extraHeaders >>"
lighthouse-check --verbose --isOrb \
--apiToken << parameters.apiToken >> \
--author << parameters.author >> \
--awsAccessKeyId << parameters.awsAccessKeyId >> \
--awsBucket << parameters.awsBucket >> \
--awsRegion << parameters.awsRegion >> \
--awsSecretAccessKey << parameters.awsSecretAccessKey >> \
--branch << parameters.branch >> \
--configFile << parameters.configFile >> \
--emulatedFormFactor << parameters.emulatedFormFactor >> \
--extraHeaders "<< parameters.extraHeaders >>" \
--locale << parameters.locale >> \
--maxWaitForLoad << parameters.maxWaitForLoad >> \
--outputDirectory /tmp/artifacts \
--overridesJsonFile << parameters.overridesJsonFile >> \
--pr << parameters.pr >> \
--prCommentAccessToken << parameters.prCommentAccessToken >> \
--prCommentEnabled << parameters.prCommentEnabled >> \
--prCommentSaveOld << parameters.prCommentSaveOld >> \
--prCommentUrl << parameters.prCommentUrl >> \
--sha << parameters.sha >> \
--slackWebhookUrl << parameters.slackWebhookUrl >> \
--tag << parameters.tag >> \
--throttling << parameters.throttling >> \
--throttlingMethod << parameters.throttlingMethod >> \
--timeout << parameters.timeout >> \
--urls << parameters.urls >> \
--wait << parameters.wait >> \
name: Run a Lighthouse audit and save results
- store_artifacts:
name: Store Artifacts
path: /tmp/artifacts
validate-status:
description: Validate results of Lighthouse audits from minimum score requirements.
Fail the job if requirements aren't met.
parameters:
minAccessibilityScore:
default: ""
description: The minimum accessibility Lighthouse score required.
type: string
minBestPracticesScore:
default: ""
description: The minimum best practices Lighthouse score required.
type: string
minPerformanceScore:
default: ""
description: The minimum performance Lighthouse score required.
type: string
minProgressiveWebAppScore:
default: ""
description: The minimum progressive web app Lighthouse score required.
type: string
minSeoScore:
default: ""
description: The minimum SEO Lighthouse score required.
type: string
steps:
- run:
command: |
lighthouse-check-status --verbose \
--outputDirectory /tmp/artifacts \
--minAccessibilityScore << parameters.minAccessibilityScore >> \
--minBestPracticesScore << parameters.minBestPracticesScore >>\
--minPerformanceScore << parameters.minPerformanceScore >> \
--minProgressiveWebAppScore << parameters.minProgressiveWebAppScore >> \
--minSeoScore << parameters.minSeoScore >>
name: Validate Lighthouse results
description: "A CircleCI Orb for running Lighthouse audits with all the bells and
whistles \U0001F514 Multiple audits, Slack notifications and more!"
examples:
advanced:
description: Run a Lighthouse audit with advanced settings.
usage:
jobs:
test:
executor: lighthouse-check/default
steps:
- lighthouse-check/audit:
awsAccessKeyId: $LIGHTHOUSE_CHECK_AWS_ACCESS_KEY_ID
awsBucket: $LIGHTHOUSE_CHECK_AWS_BUCKET
awsRegion: $LIGHTHOUSE_CHECK_AWS_REGION
awsSecretAccessKey: $LIGHTHOUSE_CHECK_AWS_SECRET_ACCESS_KEY
slackWebhookUrl: $LIGHTHOUSE_CHECK_SLACK_WEBHOOK_URL
urls: https://www.foo.software,https://www.foo.software/contact
- lighthouse-check/validate-status:
minAccessibilityScore: "50"
minBestPracticesScore: "50"
minPerformanceScore: "99"
minProgressiveWebAppScore: "50"
minSeoScore: "50"
orbs:
lighthouse-check: foo-software/lighthouse-check@0.0.8
version: 2.1
workflows:
test:
jobs:
- test
automated-lighthouse-check:
description: Run a Lighthouse audits from foo.software.
usage:
jobs:
test:
executor: lighthouse-check/default
steps:
- lighthouse-check/audit:
apiToken: $LIGHTHOUSE_CHECK_API_TOKEN
urls: mypagetoken1,mypagetoken2
orbs:
lighthouse-check: foo-software/lighthouse-check@0.0.8
version: 2.1
workflows:
test:
jobs:
- test
automated-lighthouse-check-with-pr-comment:
description: Run a Lighthouse audits from foo.software and posts results as PR
comments.
usage:
jobs:
test:
executor: lighthouse-check/default
steps:
- lighthouse-check/audit:
apiToken: $LIGHTHOUSE_CHECK_API_TOKEN
prCommentAccessToken: $LIGHTHOUSE_CHECK_ACCESS_TOKEN
prCommentUrl: https://api.github.com/repos/foo-software/lighthouse-check-orb/pulls/${CIRCLE_PULL_REQUEST##*/}/reviews
urls: mypagetoken1,mypagetoken2
orbs:
lighthouse-check: foo-software/lighthouse-check@0.0.8
version: 2.1
workflows:
test:
jobs:
- test
extra-headers:
description: Run a simple Lighthouse audit with extra headers.
usage:
jobs:
test:
executor: lighthouse-check/default
steps:
- lighthouse-check/audit:
extraHeaders: '{ "x-hello-world": "foobar", "x-some-other-thing": "hi"
}'
urls: https://lighthouse-check-action.now.sh/
orbs:
lighthouse-check: foo-software/lighthouse-check@0.0.13
version: 2.1
workflows:
test:
jobs:
- test
simple:
description: Run a simple Lighthouse audit.
usage:
jobs:
test:
executor: lighthouse-check/default
steps:
- lighthouse-check/audit:
urls: https://www.foo.software,https://www.foo.software/contact
orbs:
lighthouse-check: foo-software/lighthouse-check@0.0.6
version: 2.1
workflows:
test:
jobs:
- test
executors:
default:
docker:
- image: foosoftware/lighthouse-check:latest
version: 2.1