mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:31:43 +00:00
Performance: Run weekly audits against Sourcegraph.com (#26779)
This commit is contained in:
parent
6a2eec86d4
commit
7234a2f931
30
.github/workflows/lighthouse-production.yml
vendored
Normal file
30
.github/workflows/lighthouse-production.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: Lighthouse production audit
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# Every Monday at 12pm UTC
|
||||
- cron: '0 12 * * MON'
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
# set up correct version of node
|
||||
- id: nvmrc
|
||||
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
|
||||
- uses: actions/setup-node@v2
|
||||
with: { node-version: '${{ steps.nvmrc.outputs.NODE_VERSION }}' }
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn --ignore-engines --ignore-scripts
|
||||
|
||||
- name: Run Lighthouse
|
||||
run: |
|
||||
echo -e "*Weekly audit against Sourcegraph.com*\n" > lighthouse_results.txt
|
||||
./dev/ci/generate-lighthouse-slack-report.sh ":house: *Homepage*" "https://sourcegraph.com/search" ./lighthouse_results.txt
|
||||
./dev/ci/generate-lighthouse-slack-report.sh ":mag_right: *Search results*" "https://sourcegraph.com/search?q=repo:sourcegraph/lighthouse-ci-test-repository+file:index.js" ./lighthouse_results.txt
|
||||
./dev/ci/generate-lighthouse-slack-report.sh ":repository: *Repository page*" "https://sourcegraph.com/github.com/sourcegraph/lighthouse-ci-test-repository" ./lighthouse_results.txt
|
||||
./dev/ci/generate-lighthouse-slack-report.sh ":code: *File blob*" "https://sourcegraph.com/github.com/sourcegraph/lighthouse-ci-test-repository/-/blob/index.js" ./lighthouse_results.txt
|
||||
curl -X POST -H 'Content-type: application/json' --data "{'text':'$(cat ./lighthouse_results.txt)'}" ${{ secrets.LIGHTHOUSE_SLACK_WEBHOOK }}
|
||||
37
dev/ci/generate-lighthouse-slack-report.sh
Executable file
37
dev/ci/generate-lighthouse-slack-report.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script will run Lighthouse audits against a specified URL
|
||||
# and generate a text report suitable for uploading to Slack.
|
||||
|
||||
# Friendly name to associate with the Lighthouse audit
|
||||
NAME=$1
|
||||
# URL to run Lighthouse against
|
||||
URL=$2
|
||||
# File to output results to
|
||||
OUTPUT_FILE=$3
|
||||
|
||||
yarn lhci collect --url="$URL" --no-lighthouserc --settings.preset="desktop" --numberOfRuns=10
|
||||
|
||||
# LHCI doesn't an provide a way to easily expose the temporary storage URL, we have to extract it ourselves
|
||||
REPORT_URL=$(yarn lhci upload --target=temporary-public-storage | grep -o "https:\/\/storage.googleapis.*.html\+")
|
||||
# Primary result source, we'll use this to extract the raw audit data.
|
||||
yarn lhci upload --target=filesystem
|
||||
|
||||
# Lighthouse runs multiple times and takes the median to account for varying network latency
|
||||
REPRESENTATIVE_RUN=$(jq -r '.[] | select(.isRepresentativeRun==true)' manifest.json)
|
||||
|
||||
# Extract the Lighthouse score for each relevant category
|
||||
PERFORMANCE=$(jq -r '.summary.performance' <<<"$REPRESENTATIVE_RUN")
|
||||
ACCESSIBILITY=$(jq -r '.summary.accessibility' <<<"$REPRESENTATIVE_RUN")
|
||||
BEST_PRACTICES=$(jq -r '.summary."best-practices"' <<<"$REPRESENTATIVE_RUN")
|
||||
SEO=$(jq -r '.summary.seo' <<<"$REPRESENTATIVE_RUN")
|
||||
|
||||
SUMMARY="
|
||||
$NAME: <$REPORT_URL|Report>
|
||||
Performance: $PERFORMANCE/1
|
||||
Accessibility: $ACCESSIBILITY/1
|
||||
Best practices: $BEST_PRACTICES/1
|
||||
SEO: $SEO/1\n
|
||||
"
|
||||
|
||||
echo -e "$SUMMARY" >>"$OUTPUT_FILE"
|
||||
Loading…
Reference in New Issue
Block a user