feat(lighthouse): add configurable score thresholds#92
Conversation
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.
📝 WalkthroughWalkthroughThe reusable Lighthouse scan workflow now accepts minimum score inputs for performance, accessibility, best-practices, and SEO. It generates ChangesLighthouse scan thresholds
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
.github/workflows/lighthouse-scan.yml
| 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 |
There was a problem hiding this comment.
🩺 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.
Summary
min_performance(80),min_accessibility(90),min_best_practices(80),min_seo(80).lighthouserc.jsonat runtime viajq— no config file needs to be checked into individual reposwith:inputsTest plan
with: min_performance: 70Summary by CodeRabbit