Skip to content

Improve reports

Improve reports #69

Workflow file for this run

# Performs Lighthouse checks
name: Lighthouse
on:
# Runs on pushes targeting the default branch
pull_request:
branches: ["main"]
# Default to bash
defaults:
run:
shell: bash
jobs:
# Check on PR
lighthouse:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.108.0
permissions:
# Required to upload/save artifact, otherwise you'll get
# "Error: Resource not accessible by integration"
contents: write
# Required to post comment, otherwise you'll get
# "Error: Resource not accessible by integration"
pull-requests: write
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass Embedded
run: sudo snap install dart-sass-embedded
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
working-directory: ./src
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--minify
- name: Run Hugo Server
working-directory: ./src
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
# Run server in background
run: hugo server &
# Wait till the server warms up
- run: sleep 15
- run: mkdir -p ${{ github.workspace }}/tmp/desktop
- run: mkdir -p ${{ github.workspace }}/tmp/mobile
- name: Lighthouse Desktop
uses: foo-software/lighthouse-check-action@v12.0.1
id: lighthouseDesktop
with:
device: 'desktop'
locale: 'en'
tag: "desktop"
prCommentEnabled: true
prCommentSaveOld: true
gitAuthor: ${{ github.actor }}
gitBranch: ${{ github.ref }}
gitHubAccessToken: ${{ secrets.GITHUB_TOKEN }}
outputDirectory: ${{ github.workspace }}/tmp/desktop
# see https://github.com/GoogleChrome/lighthouse/blob/master/docs/configuration.md
# and https://github.com/GoogleChrome/lighthouse/blob/main/core/config/default-config.js
overridesJsonFile: ./lighthouse-overrides.json
sha: ${{ github.sha }}
urls: 'http://localhost:1313/'
- name: Lighthouse Mobile
uses: foo-software/lighthouse-check-action@v12.0.1
id: lighthouseMobile
with:
device: 'mobile'
locale: 'en'
tag: "mobile"
prCommentEnabled: true
prCommentSaveOld: true
gitAuthor: ${{ github.actor }}
gitBranch: ${{ github.ref }}
gitHubAccessToken: ${{ secrets.GITHUB_TOKEN }}
outputDirectory: ${{ github.workspace }}/tmp/mobile
# see https://github.com/GoogleChrome/lighthouse/blob/master/docs/configuration.md
# and https://github.com/GoogleChrome/lighthouse/blob/main/core/config/default-config.js
overridesJsonFile: ./lighthouse-overrides.json
sha: ${{ github.sha }}
urls: 'http://localhost:1313/'
- name: Upload mobile report
id: lighthouse-mobile-report
uses: actions/upload-artifact@master
with:
name: Lighthouse-mobile-report
path: ${{ github.workspace }}/tmp/mobile
- name: Upload desktop report
id: lighthouse-desktop-report
uses: actions/upload-artifact@master
with:
name: Lighthouse-desktop-report
path: ${{ github.workspace }}/tmp/desktop
- name: Publish the reports
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
## Lighthouse Reports
- [Mobile](${{ steps.lighthouse-mobile-report.outputs.artifact-url }})
- [Desktop](${{ steps.lighthouse-desktop-report.outputs.artifact-url }})
- name: Verify Lighthouse Desktop Results
uses: foo-software/lighthouse-check-status-action@v3.0.1
with:
lighthouseCheckResults: ${{ steps.lighthouseDesktop.outputs.lighthouseCheckResults }}
minAccessibilityScore: "80"
minBestPracticesScore: "80"
minPerformanceScore: "40"
minProgressiveWebAppScore: "0"
minSeoScore: "70"
- name: Verify Lighthouse Mobile Results
uses: foo-software/lighthouse-check-status-action@v3.0.1
with:
lighthouseCheckResults: ${{ steps.lighthouseMobile.outputs.lighthouseCheckResults }}
minAccessibilityScore: "80"
minBestPracticesScore: "80"
minPerformanceScore: "40"
minProgressiveWebAppScore: "0"
minSeoScore: "70"