mirror of
https://github.com/BBaoVanC/bbaovanc.com.git
synced 2025-07-03 18:47:30 -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:
|
on:
|
||||||
push:
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lighthouse:
|
lighthouse:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
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
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{github.event.pull_request.head.ref}}
|
ref: ${{ github.event.pull_request.base.ref }}
|
||||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
|
||||||
|
- 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
|
- name: Install Caddy
|
||||||
|
if: "${{ steps.changed_urls.outputs.urls != '' }}"
|
||||||
run: |
|
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/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
|
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 apt install caddy
|
||||||
sudo systemctl disable --now 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
|
- name: Compress
|
||||||
|
if: "${{ steps.changed_urls.outputs.urls != '' }}"
|
||||||
run: time ./compress.sh
|
run: time ./compress.sh
|
||||||
|
|
||||||
- name: Audit using Lighthouse
|
- name: Audit using Lighthouse
|
||||||
|
if: "${{ steps.changed_urls.outputs.urls != '' }}"
|
||||||
uses: treosh/lighthouse-ci-action@v9
|
uses: treosh/lighthouse-ci-action@v9
|
||||||
with:
|
with:
|
||||||
uploadArtifacts: true
|
uploadArtifacts: true
|
||||||
@ -44,6 +93,7 @@ jobs:
|
|||||||
serverBaseUrl: https://lhci.bbaovanc.com/
|
serverBaseUrl: https://lhci.bbaovanc.com/
|
||||||
# this should be safe since it only allows adding (not deleting) data
|
# this should be safe since it only allows adding (not deleting) data
|
||||||
serverToken: 926a24f2-90e4-48b1-809f-055b9408cf4b
|
serverToken: 926a24f2-90e4-48b1-809f-055b9408cf4b
|
||||||
|
urls: ${{ steps.changed_urls.outputs.urls }}
|
||||||
|
|
||||||
|
|
||||||
audit:
|
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:
|
ci:
|
||||||
collect:
|
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
|
startServerCommand: sudo caddy run
|
||||||
settings:
|
settings:
|
||||||
chromeFlags: "--ignore-certificate-errors --throttling.cpuSlowdownMultiplier=2.4"
|
chromeFlags: "--ignore-certificate-errors --throttling.cpuSlowdownMultiplier=2.4"
|
||||||
|
Reference in New Issue
Block a user