lighthouse-keeper

command module
v0.0.0-...-5bd24a5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

README

CircleCI

lighthouse-keeper

Utility to run lighthouse in a CI environment, especially against Docker containers, and report back the results into a Pull Request.

Features

  • Create lighthouse audit reports, running lighthouse and Chrome headless in a Docker container
  • Print report results in a readable form
  • Compare two reports, optionally comment the result into a GitHub pull request

Installation

go get github.com/giantswarm/lighthouse-keeper
go install github.com/giantswarm/lighthouse-keeper

Usage

Check lighthouse-keeper --help for details.

audit - Create a lighthouse report

This will create a lighthouse report for https://example.com/ in mysite.json:

lighthouse-keeper audit --name mysite --url https://example.com/

To audit a site running in a docker container named container, use --docker-link:

lighthouse-keeper audit --url http://container:8000/ --docker-link container:container

More flags:

  • Use --form-factor mobile to emulate a mobile device form factor. Default is desktop.
  • Use --ignore-certificate-errors to check against an HTTPS site using a self-signed or otherwise bad certificate.

Check lighthouse-keeper audit --help for details.

view - Pretty-print a report

This will print the complete report results:

lighthouse-keeper --input ./report.json

To only print the rows with scores below 100, use this:

lighthouse-keeper --input ./report.json --omit-done
compare - Compare two lighthouse reports

This prints the differences between two lighthouse reports:

lighthouse-keeper compare \
  --input before.json --inputlabel before \
  --input after.json --inputlabel after

The output looks somewhat like this:

+-----------------------------+--------+-------+-------+
|                             | BEFORE | AFTER | DELTA |
+-----------------------------+--------+-------+-------+
| Performance                 |     64 |    66 | +2    |
| - First Contentful Paint    |     36 |    40 | +4    |
| - Speed Index               |     70 |    74 | +4    |
| - Time to Interactive       |     77 |    78 | +1    |
| - Estimated Input Latency   |     98 |   100 | +2    |
| - JavaScript execution time |     93 |    94 | +1    |
+-----------------------------+--------+-------+-------+

Here is an example how the result would be commented into a GitHub pull request:

lighthouse-keeper compare \
  --input before.json --inputlabel before \
  --input after.json --inputlabel after \
  --github-owner myorg \
  --github-repo myrepo \
  --github-issue 11 \
  --github-token $GITHUB_PERSONAL_ACCESS_TOKEN

Preview:


Comparison of lighthouse reports:

BEFORE AFTER DELTA
Performance 64 66 ✅ +2
- First Contentful Paint 36 40 ✅ +4
- Speed Index 70 74 ✅ +4
- Time to Interactive 77 78 ✅ +1
- Estimated Input Latency 98 100 ✅ +2
- JavaScript execution time 93 94 ✅ +1

Misc

lighthouse-keeper requires Docker to be installed. It executes the image

quay.io/giantswarm/lighthouse

to run Chrome and lighthouse independent of the environment. The image is built automatically based on this Dockerfile.

Thanks for the inspiration to:

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
audit
Package audit provides the `audit` command to create a lighthouse report.
Package audit provides the `audit` command to create a lighthouse report.
compare
Package compare provides the `compare` command to perform a comparison of two lighthouse reports
Package compare provides the `compare` command to perform a comparison of two lighthouse reports
view
Package view provides the `view` command to print a lighthouse report
Package view provides the `view` command to print a lighthouse report
service
commenter
Package commenter provides functionality to post a comment into a GitHub PR
Package commenter provides functionality to post a comment into a GitHub PR
lighthouse
Package lighthouse provides the lighthouse auditing service.
Package lighthouse provides the lighthouse auditing service.
parser
Package parser implements the parsing of lighthouse reports into Go types
Package parser implements the parsing of lighthouse reports into Go types

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL