chore: release prep for v1.25.1 #373
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/lighthouse.yml | |
| # | |
| # Copyright © 2025 Network Pro Strategies (Network Pro™) | |
| # SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later | |
| # This file is part of Network Pro | |
| name: Lighthouse Audit | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| workflow_dispatch: | |
| # cspell:ignore tostring | |
| # Sets permissions of the GITHUB_TOKEN to allow read access to repo and write | |
| # permission for PRs for comment summary | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| audit: | |
| name: Run Lighthouse CI | |
| runs-on: ubuntu-24.04 | |
| env: | |
| ENV_MODE: ci | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| - name: Authenticate GitHub CLI | |
| run: gh auth status | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Log ENV_MODE | |
| run: 'echo "ENV_MODE is set to: $ENV_MODE"' | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| cache-dependency-path: package-lock.json | |
| - name: Upgrade npm | |
| run: | | |
| corepack enable | |
| npm install -g [email protected] | |
| - name: Clean previous Lighthouse reports | |
| run: | | |
| if [ -d ".lighthouseci" ]; then | |
| COUNT=$(find .lighthouseci -type f | wc -l) | |
| echo "🧹 Removing $COUNT file(s) from .lighthouseci/" | |
| rm -rf .lighthouseci | |
| else | |
| echo "🧹 No previous .lighthouseci/ directory to clean." | |
| fi | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Build Site | |
| run: npm run build | |
| - name: Install Google Chrome | |
| run: | | |
| wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb | |
| sudo apt install -y ./google-chrome-stable_current_amd64.deb | |
| - name: Record Chrome version and timestamp | |
| run: | | |
| mkdir -p .lighthouseci | |
| { | |
| echo "Chrome Version: $(google-chrome --version)" | |
| echo "Audit Timestamp: $(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
| } > .lighthouseci/chrome-version.txt | |
| - name: Collect Lighthouse results | |
| run: | | |
| npx @lhci/cli collect \ | |
| --chrome-path="$(which google-chrome)" \ | |
| --config=.lighthouserc.cjs | |
| - name: Log Chrome version used | |
| run: cat .lighthouseci/chrome-version.txt | |
| - name: Check for budget.json | |
| run: | | |
| if [ ! -f budget.json ]; then | |
| echo "❌ ERROR: budget.json not found. LHCI budget assertions will be skipped." | |
| exit 1 | |
| else | |
| echo "✅ Found budget.json" | |
| fi | |
| - name: Assert Lighthouse results (non-blocking) | |
| run: npx @lhci/cli assert --config=.lighthouserc.cjs | |
| continue-on-error: true | |
| - name: Annotate and Comment on Lighthouse Budget Failures | |
| if: always() | |
| continue-on-error: true | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| REPORT=$(ls -t .lighthouseci/*.report.json .lighthouseci/lhr-*.json 2>/dev/null | head -n 1) | |
| if [ -z "$REPORT" ]; then | |
| echo "::warning ::No valid Lighthouse report found for annotation step." | |
| exit 0 | |
| fi | |
| echo "🔍 Parsing $REPORT for failing audits..." | |
| if ! jq -e '.audits' "$REPORT" > /dev/null; then | |
| echo "::warning ::The selected report is not a valid Lighthouse output (missing .audits key)." | |
| exit 0 | |
| fi | |
| FAILURES=$(jq -r '.audits | to_entries[] | select(.value.score < 1 and .value.score != null) | [.key, .value.title, (.value.score | tostring)] | @tsv' "$REPORT") | |
| if [ -z "$FAILURES" ]; then | |
| echo "✅ No failing audits found. Lighthouse budgets passed." | |
| exit 0 | |
| fi | |
| echo "⚠️ Failing Lighthouse audits:" | |
| COMMENT_BODY="### ⚠️ Lighthouse Budget Issues Detected" | |
| while IFS=$'\t' read -r key title score; do | |
| echo "::warning file=.lighthouseci/report.json,line=1,title=Lighthouse Budget Issue::$title (score: $score)" | |
| COMMENT_BODY="${COMMENT_BODY}"$'\n'"- ${title} (score: ${score})" | |
| done <<< "$FAILURES" | |
| COMMENT_BODY="${COMMENT_BODY}"$'\n\n'"View the full report in the workflow artifacts or in \`.lighthouseci/report.html\`." | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT_BODY" || echo "::warning ::Failed to post PR comment" | |
| else | |
| echo "Not a PR — skipping GitHub comment post." | |
| fi | |
| - name: Upload Lighthouse results | |
| run: npx @lhci/cli upload --config=.lighthouserc.cjs | |
| - name: List contents of .lighthouseci | |
| run: ls -al .lighthouseci | |
| - name: Upload full .lighthouseci output | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: lighthouse-reports | |
| path: .lighthouseci/ | |
| include-hidden-files: true | |
| if-no-files-found: error |