mirror of
https://github.com/BBaoVanC/bbaovanc.com.git
synced 2025-07-03 10:37:29 -05:00
Run Lighthouse for all changed pages (#26)
This commit is contained in:
74
.github/workflows/audit.yml
vendored
74
.github/workflows/audit.yml
vendored
@ -2,20 +2,76 @@ name: Audit
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
lighthouse:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkount
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
with:
|
||||
hugo-version: latest
|
||||
extended: true
|
||||
|
||||
- name: Checkout (pull_request)
|
||||
if: github.event.pull_request
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
ref: ${{github.event.pull_request.head.ref}}
|
||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
ref: ${{ github.event.pull_request.base.ref }}
|
||||
|
||||
- name: Checkout (push)
|
||||
if: github.event_name == 'push'
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.before }}
|
||||
|
||||
- name: Build previous commit
|
||||
run: |
|
||||
hugo --printI18nWarnings --printPathWarnings --baseURL https://localhost -d old/
|
||||
|
||||
- name: Checkout current commit
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
clean: false
|
||||
|
||||
- name: Build current commit
|
||||
run: |
|
||||
hugo --printI18nWarnings --printPathWarnings --baseURL https://localhost
|
||||
cp -r public/ new/
|
||||
# copy, so that public/ stays, it will be needed for Caddy to serve
|
||||
|
||||
- name: Save full diff
|
||||
run: diff -r old/ new/ | tee changes.diff || true
|
||||
|
||||
- name: Upload full diff
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: diff
|
||||
path: changes.diff
|
||||
|
||||
- name: Find changed URLs
|
||||
id: changed_urls
|
||||
env:
|
||||
SCHEME: https
|
||||
DOMAIN: localhost
|
||||
run: |
|
||||
urls="$(./changed-urls.sh)"
|
||||
urls="${urls//'%'/'%25'}"
|
||||
urls="${urls//$'\n'/'%0A'}"
|
||||
urls="${urls//$'\r'/'%0D'}"
|
||||
echo "::set-output name=urls::$urls"
|
||||
|
||||
- name: Install Caddy
|
||||
if: "${{ steps.changed_urls.outputs.urls != '' }}"
|
||||
run: |
|
||||
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy-stable.asc
|
||||
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
|
||||
@ -23,19 +79,12 @@ jobs:
|
||||
sudo apt install caddy
|
||||
sudo systemctl disable --now caddy
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
with:
|
||||
hugo-version: latest
|
||||
extended: true
|
||||
|
||||
- name: Build
|
||||
run: hugo --printI18nWarnings --printPathWarnings --baseURL https://localhost
|
||||
|
||||
- name: Compress
|
||||
if: "${{ steps.changed_urls.outputs.urls != '' }}"
|
||||
run: time ./compress.sh
|
||||
|
||||
- name: Audit using Lighthouse
|
||||
if: "${{ steps.changed_urls.outputs.urls != '' }}"
|
||||
uses: treosh/lighthouse-ci-action@v9
|
||||
with:
|
||||
uploadArtifacts: true
|
||||
@ -44,6 +93,7 @@ jobs:
|
||||
serverBaseUrl: https://lhci.bbaovanc.com/
|
||||
# this should be safe since it only allows adding (not deleting) data
|
||||
serverToken: 926a24f2-90e4-48b1-809f-055b9408cf4b
|
||||
urls: ${{ steps.changed_urls.outputs.urls }}
|
||||
|
||||
|
||||
audit:
|
||||
|
8
changed-urls.sh
Executable file
8
changed-urls.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
diff -qrN old/ new/ |
|
||||
grep -oP '(?<=\s)new\/\S*' |
|
||||
xargs -d '\n' ls -1d 2>/dev/null |
|
||||
grep 'index.html$' |
|
||||
sed 's/index.html$//' |
|
||||
sed "s/^new/${SCHEME:=http}:\/\/${DOMAIN:=example.com}/"
|
@ -1,23 +1,5 @@
|
||||
ci:
|
||||
collect:
|
||||
url:
|
||||
- https://localhost/ # homepage
|
||||
- https://localhost/links/ # very simple page
|
||||
|
||||
- https://localhost/blog/ # list page
|
||||
- https://localhost/blog/the-redesign-of-my-website/ # average post, but no footnotes
|
||||
- https://localhost/blog/blog-post-newsletter/ # average post, but WITH footnotes
|
||||
- https://localhost/blog/caddy-is-the-best-webserver/ # another average post with footnotes, WITH code blocks
|
||||
- https://localhost/blog/youtube-url-structures-you-should-know/ # youtube embed
|
||||
- https://localhost/blog/copilot-post/ # lots of code blocks & text
|
||||
- https://localhost/blog/github-copilot-experiments/ # heavy use of images
|
||||
|
||||
- https://localhost/categories/
|
||||
- https://localhost/categories/linux/
|
||||
|
||||
- https://localhost/tags/
|
||||
- https://localhost/tags/github-copilot/
|
||||
|
||||
startServerCommand: sudo caddy run
|
||||
settings:
|
||||
chromeFlags: "--ignore-certificate-errors --throttling.cpuSlowdownMultiplier=2.4"
|
||||
|
Reference in New Issue
Block a user