1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-27 03:58:28 -04:00

trigger lighthouse audits on Netlify deploy previews

This commit is contained in:
Jake Jarvis 2020-03-28 23:33:18 -04:00
parent 5e5678a699
commit c33d8f9f18
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
3 changed files with 44 additions and 46 deletions

42
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,42 @@
name: CI
on: [push, pull_request]
jobs:
lighthouse:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install utilities
run: npm install -g netlify-cli @lhci/cli
- name: Wait for Netlify
run: netlify watch
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
- name: Audit deploy preview
if: github.event_name == 'pull_request'
continue-on-error: true
run: |
lhci autorun --config=./lighthouserc.json \
--collect.url=https://deploy-preview-${{ github.event.number }}--jakejarvis.netlify.com/ \
--collect.url=https://deploy-preview-${{ github.event.number }}--jakejarvis.netlify.com/notes/ \
--collect.url=https://deploy-preview-${{ github.event.number }}--jakejarvis.netlify.com/notes/how-to-pull-request-fork-github/ \
--collect.url=https://deploy-preview-${{ github.event.number }}--jakejarvis.netlify.com/notes/how-to-pull-request-fork-github/amp.html
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
- name: Audit jarv.is
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
continue-on-error: true
run: |
lhci autorun --config=./lighthouserc.json \
--collect.url=https://jarv.is/ \
--collect.url=https://jarv.is/notes/ \
--collect.url=https://jarv.is/notes/how-to-pull-request-fork-github/ \
--collect.url=https://jarv.is/notes/how-to-pull-request-fork-github/amp.html
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}

View File

@ -1,37 +0,0 @@
name: Lighthouse
on: [push, pull_request]
jobs:
lhci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
# https://github.com/actions/cache/blob/master/examples.md#node---yarn
# https://github.com/actions/cache/issues/60
- name: Get yarn cache location
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
yarn install --no-ignore-optional --frozen-lockfile
# - uses: jakepartusch/wait-for-netlify-action@v1
# id: wait
# with:
# site_name: "jakejarvis"
- name: Run Lighthouse CI
run: |
npm install -g @lhci/cli@0.3.x
lhci autorun --config=./lighthouserc.json
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}

View File

@ -1,20 +1,13 @@
{
"ci": {
"collect": {
"url": [
"http://localhost:1337/",
"http://localhost:1337/notes/",
"http://localhost:1337/notes/how-to-pull-request-fork-github/",
"http://localhost:1337/notes/how-to-pull-request-fork-github/amp.html"
],
"numberOfRuns": 1,
"startServerCommand": "yarn start --disableLiveReload",
"startServerReadyPattern": "Web Server is available at"
"numberOfRuns": 1
},
"assert": {
"preset": "lighthouse:no-pwa",
"assertions": {
"color-contrast": ["warn", {"minScore": 0.9}],
"errors-in-console": "warn",
"link-text": "warn",
"tap-targets": ["warn", {"minScore": 0.6}],
"total-byte-weight": ["warn", {"minScore": 0.9}],