Skip to content

feat(lighthouse): add configurable score thresholds#92

Merged
tehw0lf merged 1 commit into
mainfrom
feat/lighthouse-score-thresholds
Jun 25, 2026
Merged

feat(lighthouse): add configurable score thresholds#92
tehw0lf merged 1 commit into
mainfrom
feat/lighthouse-score-thresholds

Conversation

@tehw0lf

@tehw0lf tehw0lf commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds four optional inputs with sensible defaults: min_performance (80), min_accessibility (90), min_best_practices (80), min_seo (80)
  • Generates .lighthouserc.json at runtime via jq — no config file needs to be checked into individual repos
  • Repos can override any threshold per-workflow via with: inputs
  • Lighthouse CI will now fail the workflow when a score drops below the configured minimum

Test plan

  • Merge and retrigger a lighthouse scan to confirm thresholds are applied
  • Confirm workflow fails if scores drop below defaults
  • Confirm a repo can override a threshold via with: min_performance: 70

Summary by CodeRabbit

  • New Features
    • Added configurable Lighthouse score thresholds for performance, accessibility, best practices, and SEO.
    • The scan now uses these thresholds during CI checks, so builds can fail when scores fall below the set minimums.
    • Default score targets are provided, while still allowing overrides when the workflow is triggered.

Add min_performance (80), min_accessibility (90), min_best_practices (80),
and min_seo (80) inputs with sensible defaults. Generates a lighthouserc.json
at runtime so repos can override per-workflow without checking in config files.
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The reusable Lighthouse scan workflow now accepts minimum score inputs for performance, accessibility, best-practices, and SEO. It generates .lighthouserc.json during the job with those thresholds and passes that file to the Lighthouse CI action.

Changes

Lighthouse scan thresholds

Layer / File(s) Summary
Workflow inputs for score floors
.github/workflows/lighthouse-scan.yml
Adds reusable workflow inputs for minimum performance, accessibility, best-practices, and SEO scores with numeric defaults.
Generate and use runtime Lighthouse config
.github/workflows/lighthouse-scan.yml
Writes .lighthouserc.json, patches each category minScore from the workflow inputs, and sets the Lighthouse CI action configPath to the generated file.

Sequence Diagram(s)

sequenceDiagram
  participant Caller as workflow_call
  participant Workflow as .github/workflows/lighthouse-scan.yml
  participant Runner as GitHub Actions runner
  participant jq
  participant LHCI as Lighthouse CI action
  Caller->>Workflow: provide min_* inputs
  Workflow->>Runner: start config-generation step
  Runner->>Runner: write .lighthouserc.json template
  Runner->>jq: patch minScore values from inputs / 100
  jq-->>Runner: updated .lighthouserc.json
  Runner->>LHCI: configPath=.lighthouserc.json
  LHCI-->>Workflow: run Lighthouse scan
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • tehw0lf/workflows#89: Extends the same reusable Lighthouse scan workflow with threshold inputs and a generated Lighthouse config.

Poem

🐰 I hopped through scores both high and low,
then tuned the lighthouse to aglow.
Four thresholds twinkled in the night,
and jq made the config right.
Hoppy scans now chase the light!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: configurable Lighthouse score thresholds.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/lighthouse-score-thresholds

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/lighthouse-scan.yml:
- Around line 60-83: The Lighthouse workflow step writes invalid JSON because
the quoted heredoc in the .lighthouserc.json creation block leaves $MIN_PERF,
$MIN_A11Y, $MIN_BP, and $MIN_SEO as literal text. Update the heredoc in
lighthouse-scan.yml to emit valid placeholder numeric values in the initial
assertions object, since the subsequent jq transformation in the same step
(which updates categories:performance, categories:accessibility,
categories:best-practices, and categories:seo) overwrites each minScore anyway.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3ec4c1c4-876b-45b0-bad6-0db65efa7eb0

📥 Commits

Reviewing files that changed from the base of the PR and between 2c2b297 and 72d0be3.

📒 Files selected for processing (1)
  • .github/workflows/lighthouse-scan.yml

Comment on lines +60 to +83
cat > .lighthouserc.json << 'RCEOF'
{
"ci": {
"assert": {
"assertions": {
"categories:performance": ["error", {"minScore": $MIN_PERF}],
"categories:accessibility": ["error", {"minScore": $MIN_A11Y}],
"categories:best-practices": ["error", {"minScore": $MIN_BP}],
"categories:seo": ["error", {"minScore": $MIN_SEO}]
}
}
}
}
RCEOF
jq \
--argjson MIN_PERF "${{ inputs.min_performance }}" \
--argjson MIN_A11Y "${{ inputs.min_accessibility }}" \
--argjson MIN_BP "${{ inputs.min_best_practices }}" \
--argjson MIN_SEO "${{ inputs.min_seo }}" \
'.ci.assert.assertions."categories:performance"[1].minScore = ($MIN_PERF / 100) |
.ci.assert.assertions."categories:accessibility"[1].minScore = ($MIN_A11Y / 100) |
.ci.assert.assertions."categories:best-practices"[1].minScore = ($MIN_BP / 100) |
.ci.assert.assertions."categories:seo"[1].minScore = ($MIN_SEO / 100)' \
.lighthouserc.json > .lighthouserc.tmp.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Expect: jq exits non-zero with a parse error on the literal `$MIN_PERF` token.
cat > /tmp/rc.json << 'RCEOF'
{ "ci": { "assert": { "assertions": {
  "categories:performance": ["error", {"minScore": $MIN_PERF}]
}}}}
RCEOF
jq --argjson MIN_PERF 80 \
  '.ci.assert.assertions."categories:performance"[1].minScore = ($MIN_PERF / 100)' \
  /tmp/rc.json
echo "exit=$?"

Repository: tehw0lf/workflows

Length of output: 220


Heredoc writes invalid JSON, so jq fails immediately.
.github/workflows/lighthouse-scan.yml:60-83 uses a quoted heredoc, so $MIN_PERF, $MIN_A11Y, $MIN_BP, and $MIN_SEO stay literal in .lighthouserc.json. That makes the file invalid JSON and jq exits on parse. Use valid placeholders such as 0 here; the later jq assignments overwrite every minScore anyway.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/lighthouse-scan.yml around lines 60 - 83, The Lighthouse
workflow step writes invalid JSON because the quoted heredoc in the
.lighthouserc.json creation block leaves $MIN_PERF, $MIN_A11Y, $MIN_BP, and
$MIN_SEO as literal text. Update the heredoc in lighthouse-scan.yml to emit
valid placeholder numeric values in the initial assertions object, since the
subsequent jq transformation in the same step (which updates
categories:performance, categories:accessibility, categories:best-practices, and
categories:seo) overwrites each minScore anyway.

@tehw0lf tehw0lf merged commit 634895d into main Jun 25, 2026
3 checks passed
@tehw0lf tehw0lf deleted the feat/lighthouse-score-thresholds branch June 25, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant