Skip to content

Commit 86ba8bd

Browse files
authored
feat: Check pull requests using Lighthouse CI (#96)
* feat: Run Lighthouse CI via GitHub Actions Documentation: https://github.com/GoogleChrome/lighthouse-ci/blob/master/docs/getting-started.md#github-status-checks * chore: Upload Lighthouse CI results Results are not sensitive. The same results may be obtained by cloning this public repo and running 'npx lhci autorun', or by running Lighthouse via the Google Chrome DevTools against the public site. Terms: https://github.com/GoogleChrome/lighthouse-ci/blob/master/docs/services-disclaimer.md#temporary-public-storage * fix: Lighthouse audit issues * chore: Skip Lighthouse checks which fail in CI but not DevTools * chore: Cache Bundler gems to speed-up CI
1 parent 5ca6556 commit 86ba8bd

9 files changed

Lines changed: 3210 additions & 123 deletions

File tree

.github/workflows/lighthouse.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Lighthouse
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
lhci:
7+
name: Lighthouse
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout the project
11+
uses: actions/checkout@v2
12+
13+
- name: Use Node.js 14.x (LTS)
14+
uses: actions/setup-node@v1
15+
with:
16+
node-version: 14.x
17+
18+
- name: Use Ruby 2.7
19+
uses: actions/setup-ruby@v1
20+
with:
21+
ruby-version: '2.7'
22+
23+
- name: Restore npm cache
24+
uses: actions/cache@v2
25+
with:
26+
path: ~/.npm
27+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
28+
restore-keys: |
29+
${{ runner.os }}-node-
30+
31+
- name: Restore Bundler cache
32+
uses: actions/cache@v2
33+
with:
34+
path: docs/vendor/bundle
35+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
36+
restore-keys: |
37+
${{ runner.os }}-gems-
38+
39+
- name: Configure Bundler cache
40+
run: |
41+
bundle config path vendor/bundle
42+
43+
- name: Install dependencies
44+
run: |
45+
npm ci
46+
cd docs && bundle install && cd ..
47+
48+
- name: Build docs
49+
run: npm run build:docs
50+
env:
51+
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Run Lighthouse CI
54+
run: npx lhci autorun
55+
env:
56+
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
LHCI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules
22
_site
33
*.tsbuildinfo
44
lib/
5-
.jekyll-cache
5+
.jekyll-cache
6+
.lighthouseci

docs/Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ gem 'jekyll', '~> 4.1.1'
66

77
group :jekyll_plugins do
88
gem 'jekyll-commonmark-ghpages', '~> 0.1.5'
9-
gem "jekyll-github-metadata"
9+
gem 'jekyll-github-metadata'
10+
gem 'jekyll-gzip'
1011
end

docs/Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ GEM
4343
jekyll-github-metadata (2.13.0)
4444
jekyll (>= 3.4, < 5.0)
4545
octokit (~> 4.0, != 4.4.0)
46+
jekyll-gzip (2.4.2)
47+
jekyll (>= 3.0, < 5.0)
4648
jekyll-sass-converter (2.1.0)
4749
sassc (> 2.0.1, < 3.0)
4850
jekyll-watch (2.2.1)
@@ -87,6 +89,7 @@ DEPENDENCIES
8789
jekyll (~> 4.1.1)
8890
jekyll-commonmark-ghpages (~> 0.1.5)
8991
jekyll-github-metadata
92+
jekyll-gzip
9093

9194
BUNDLED WITH
9295
2.1.4

docs/_config.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Catalyst
33
markdown: CommonMarkGhPages
44

55
commonmark:
6-
extensions: ["autolink", "table"]
6+
extensions: ['autolink', 'table']
77

88
permalink: pretty
99

@@ -16,11 +16,14 @@ collections:
1616
guide:
1717
output: true
1818

19-
defaults:
19+
defaults:
2020
- scope:
2121
type: guide
2222
values:
2323
layout: guide
2424

25+
repository: github/catalyst
26+
2527
plugins:
26-
- "jekyll-github-metadata"
28+
- 'jekyll-github-metadata'
29+
- 'jekyll-gzip'

docs/_layouts/default.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
22
---
33
<!DOCTYPE html>
4-
<html class="height-full">
4+
<html lang="en" class="height-full">
55
<head>
66
<title>{% if page.title %}{{ page.title }} - {% endif %}{{ site.title }}</title>
7+
<meta name="description" content="Catalyst is a set of patterns and techniques for developing components within a complex application.">
78
<meta charset="utf-8">
9+
<meta name="viewport" content="width=device-width">
810
<link rel="stylesheet" href="{{ site.baseurl }}/primer.css">
911
<link rel="stylesheet" href="{{ site.baseurl }}/github-syntax.css">
1012
<link rel="stylesheet" href="{{ site.baseurl }}/custom.css">

lighthouserc.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"ci": {
3+
"collect": {
4+
"url": ["http://localhost:4000/"],
5+
"startServerCommand": "cd docs && bundle exec jekyll serve"
6+
},
7+
"assert": {
8+
"preset": "lighthouse:no-pwa",
9+
"assertions": {
10+
"unused-css-rules": "off",
11+
"uses-text-compression": "off",
12+
"render-blocking-resources": "off",
13+
"uses-rel-preload": "off",
14+
"first-contentful-paint": ["warn", {"minScore": 0.8}],
15+
"first-meaningful-paint": ["warn", {"minScore": 0.8}],
16+
"largest-contentful-paint": ["warn", {"minScore": 0.8}]
17+
}
18+
},
19+
"upload": {
20+
"target": "temporary-public-storage"
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)