Skip to content

Commit 5eb7fc6

Browse files
Fixed throttling settings, improved docker image caching
1 parent 58bcccb commit 5eb7fc6

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

.github/workflows/push.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@ jobs:
2929
run: DOCKER_BUILDKIT=1 docker build -t ghcr.io/wanteddev/lighthouse:${{github.event.release.tag_name}} --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ghcr.io/wanteddev/lighthouse:latest .
3030

3131
- name: Push image
32-
run: docker push ghcr.io/wanteddev/lighthouse:${{github.event.release.tag_name}}
32+
run: docker push ghcr.io/wanteddev/lighthouse:${{github.event.release.tag_name}}
33+
34+
- name: Update latest image (to be used in caching)
35+
run: |
36+
docker tag ghcr.io/wanteddev/lighthouse:${{github.event.release.tag_name}} ghcr.io/wanteddev/lighthouse:latest
37+
docker push ghcr.io/wanteddev/lighthouse:latest

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
node_modules
2+
*.http

src/utils/lighthouse.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,42 +41,36 @@ async function launchPuppeteer(url, options) {
4141

4242
// Lighthouse will open URL. Puppeteer observes `targetchanged` and sets up network conditions.
4343
// Possible race condition.
44-
let flags = {
44+
let opts = {
4545
port: (new URL(browser.wsEndpoint())).port,
4646
output: 'json',
47-
logLevel: 'error',
47+
onlyCategories: [],
48+
screenEmulation: {
49+
disabled: true,
50+
},
4851
};
4952

50-
let opts = {
51-
settings: {
52-
onlyCategories: [],
53-
screenEmulation: {
54-
disabled: true,
55-
},
56-
}
57-
}
58-
59-
if (options.performance) opts.settings.onlyCategories.push('performance');
60-
if (options.accessibility) opts.settings.onlyCategories.push('accessibility');
61-
if (options['best-practices']) opts.settings.onlyCategories.push('best-practices');
62-
if (options.pwa) opts.settings.onlyCategories.push('pwa');
63-
if (options.seo) opts.settings.onlyCategories.push('seo');
53+
if (options.performance) opts.onlyCategories.push('performance');
54+
if (options.accessibility) opts.onlyCategories.push('accessibility');
55+
if (options['best-practices']) opts.onlyCategories.push('best-practices');
56+
if (options.pwa) opts.onlyCategories.push('pwa');
57+
if (options.seo) opts.onlyCategories.push('seo');
6458

6559
// as throttling is enabled by default in lighthouse, disable it if explicitly unchecked
6660
if (options.throttling === false) {
6761
// Values referenced in
6862
// https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/config/constants.js
69-
opts.settings.throttlingMethod = 'provided';
70-
opts.settings.emulatedUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4420.0 Safari/537.36 Chrome-Lighthouse';
71-
opts.settings.throttling = {
63+
opts.throttlingMethod = 'provided';
64+
opts.emulatedUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4420.0 Safari/537.36 Chrome-Lighthouse';
65+
opts.throttling = {
7266
rttMs: 40,
7367
throughputKbps: 10 * 1024,
7468
cpuSlowdownMultiplier: 1,
7569
requestLatencyMs: 0,
7670
downloadThroughputKbps: 0,
7771
uploadThroughputKbps: 0,
7872
};
79-
opts.settings.screenEmulation = {
73+
opts.screenEmulation = {
8074
mobile: false,
8175
width: 1350,
8276
height: 940,
@@ -85,7 +79,7 @@ async function launchPuppeteer(url, options) {
8579
}
8680
}
8781

88-
const {lhr} = await lighthouse(url, flags, opts);
82+
const {lhr} = await lighthouse(url, opts);
8983
// Return response back to main thread
9084
parentPort.postMessage(lhr);
9185

0 commit comments

Comments
 (0)