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
This commit is contained in:
Clay Miller 2020-12-10 13:09:34 -05:00 коммит произвёл GitHub
Родитель 5ca6556df1
Коммит 86ba8bdc23
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 3094 добавлений и 7 удалений

57
.github/workflows/lighthouse.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,57 @@
name: Lighthouse
on: [pull_request]
jobs:
lhci:
name: Lighthouse
runs-on: ubuntu-latest
steps:
- name: Checkout the project
uses: actions/checkout@v2
- name: Use Node.js 14.x (LTS)
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Use Ruby 2.7
uses: actions/setup-ruby@v1
with:
ruby-version: '2.7'
- name: Restore npm cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Restore Bundler cache
uses: actions/cache@v2
with:
path: docs/vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Configure Bundler cache
run: |
bundle config path vendor/bundle
- name: Install dependencies
run: |
npm ci
cd docs && bundle install && cd ..
- name: Build docs
run: npm run build:docs
env:
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run Lighthouse CI
run: npx lhci autorun
env:
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LHCI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

3
.gitignore поставляемый
Просмотреть файл

@ -2,4 +2,5 @@ node_modules
_site
*.tsbuildinfo
lib/
.jekyll-cache
.jekyll-cache
.lighthouseci

Просмотреть файл

@ -6,5 +6,6 @@ gem 'jekyll', '~> 4.1.1'
group :jekyll_plugins do
gem 'jekyll-commonmark-ghpages', '~> 0.1.5'
gem "jekyll-github-metadata"
gem 'jekyll-github-metadata'
gem 'jekyll-gzip'
end

Просмотреть файл

@ -43,6 +43,8 @@ GEM
jekyll-github-metadata (2.13.0)
jekyll (>= 3.4, < 5.0)
octokit (~> 4.0, != 4.4.0)
jekyll-gzip (2.4.2)
jekyll (>= 3.0, < 5.0)
jekyll-sass-converter (2.1.0)
sassc (> 2.0.1, < 3.0)
jekyll-watch (2.2.1)
@ -87,6 +89,7 @@ DEPENDENCIES
jekyll (~> 4.1.1)
jekyll-commonmark-ghpages (~> 0.1.5)
jekyll-github-metadata
jekyll-gzip
BUNDLED WITH
2.1.4

Просмотреть файл

@ -3,7 +3,7 @@ title: Catalyst
markdown: CommonMarkGhPages
commonmark:
extensions: ["autolink", "table"]
extensions: ['autolink', 'table']
permalink: pretty
@ -16,11 +16,14 @@ collections:
guide:
output: true
defaults:
defaults:
- scope:
type: guide
values:
layout: guide
repository: github/catalyst
plugins:
- "jekyll-github-metadata"
- 'jekyll-github-metadata'
- 'jekyll-gzip'

Просмотреть файл

@ -1,10 +1,12 @@
---
---
<!DOCTYPE html>
<html class="height-full">
<html lang="en" class="height-full">
<head>
<title>{% if page.title %}{{ page.title }} - {% endif %}{{ site.title }}</title>
<meta name="description" content="Catalyst is a set of patterns and techniques for developing components within a complex application.">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="{{ site.baseurl }}/primer.css">
<link rel="stylesheet" href="{{ site.baseurl }}/github-syntax.css">
<link rel="stylesheet" href="{{ site.baseurl }}/custom.css">

23
lighthouserc.json Normal file
Просмотреть файл

@ -0,0 +1,23 @@
{
"ci": {
"collect": {
"url": ["http://localhost:4000/"],
"startServerCommand": "cd docs && bundle exec jekyll serve"
},
"assert": {
"preset": "lighthouse:no-pwa",
"assertions": {
"unused-css-rules": "off",
"uses-text-compression": "off",
"render-blocking-resources": "off",
"uses-rel-preload": "off",
"first-contentful-paint": ["warn", {"minScore": 0.8}],
"first-meaningful-paint": ["warn", {"minScore": 0.8}],
"largest-contentful-paint": ["warn", {"minScore": 0.8}]
}
},
"upload": {
"target": "temporary-public-storage"
}
}
}

2996
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -25,7 +25,7 @@
"scripts": {
"build": "tsc --build",
"build:docs": "npm run build:docs:reference && npm run build:docs:jekyll",
"build:docs:jekyll": "cd docs && bundle exec jekyll build",
"build:docs:jekyll": "cd docs && JEKYLL_ENV=production bundle exec jekyll build",
"build:docs:reference": "typedoc --json docs/_data/reference.json",
"clean": "tsc --build --clean",
"lint": "eslint . --ignore-path .gitignore",
@ -36,6 +36,7 @@
"prettier": "@github/prettier-config",
"devDependencies": {
"@github/prettier-config": "^0.0.4",
"@lhci/cli": "^0.6.1",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
"chai": "^4.2.0",