Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/lighthouse-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ on:
default: ""
required: false
type: string
min_performance:
description: "minimum performance score (0-100)"
default: 80
required: false
type: number
min_accessibility:
description: "minimum accessibility score (0-100)"
default: 90
required: false
type: number
min_best_practices:
description: "minimum best-practices score (0-100)"
default: 80
required: false
type: number
min_seo:
description: "minimum SEO score (0-100)"
default: 80
required: false
type: number
runner:
description: "workflow-runner"
default: "ubuntu-latest"
Expand All @@ -35,6 +55,34 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: write lighthouserc
run: |
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
Comment on lines +60 to +83

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.

mv .lighthouserc.tmp.json .lighthouserc.json

- name: build urls list
id: urls
run: |
Expand All @@ -57,6 +105,7 @@ jobs:
uses: treosh/lighthouse-ci-action@v12
with:
urls: ${{ steps.urls.outputs.urls }}
configPath: .lighthouserc.json
uploadArtifacts: true
temporaryPublicStorage: true

Expand Down
Loading