Files
bookmarkmagic/.github/workflows/sonarcloud.yml
T
dependabot[bot] a7f152a833 ci(deps): Bump SonarSource/sonarqube-scan-action
Bumps the actions group with 1 update: [SonarSource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action).


Updates `SonarSource/sonarqube-scan-action` from 8.4.0 to 8.4.1
- [Release notes](https://github.com/sonarsource/sonarqube-scan-action/releases)
- [Commits](https://github.com/sonarsource/sonarqube-scan-action/compare/4d1dc0c91ee400dcf8a6dddf2f705ac36542e304...e805d875275f728fac1885b413934be6d7c63f65)

---
updated-dependencies:
- dependency-name: SonarSource/sonarqube-scan-action
  dependency-version: 8.4.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-11-16 18:35:44 +00:00

116 lines
3.9 KiB
YAML

# SonarCloud — docs/12 §2.5.
#
# A separate workflow on purpose, not a job in ci.yml: a SonarCloud outage or a
# quality-gate opinion must never change the colour of CI, which is what branch
# protection reads ("Quality gates", "Build + package / build"). The verdict
# reaches the PR through the SonarCloud GitHub App's own check.
#
# Two jobs, so the token never shares a runner with dependency code. Secrets
# are loaded into the runner for the whole job, and a step can read them from
# the runner process whatever its own `env:` says — the shape of the March 2025
# tj-actions compromise. So `coverage` installs and runs the dev dependencies
# with no secret at all, and `scan` installs nothing: it gets the lcov report as
# an artifact.
#
# ⚠️ Prerequisite: Automatic Analysis is OFF in the SonarCloud project
# (Administration → Analysis Method). With it on, the scanner refuses to run.
name: SonarCloud
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
concurrency:
group: sonarcloud-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
coverage:
name: Coverage for SonarCloud
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: npm
# --ignore-scripts: no dependency gets to run code at install time. Our own
# postinstall (`wxt prepare`) is the one script we need, so it runs
# explicitly — from the local binary, never fetched on demand.
- run: npm ci --ignore-scripts
- run: npx --no-install wxt prepare
# lcov for Sonar; the docs/11 §1 thresholds still gate core here too.
- run: npm run coverage
# The lcov report, and the generated .wxt/ that tsconfig.json extends (it
# defines the `@/` alias), so the scan can resolve our own modules.
- uses: actions/upload-artifact@v7
with:
name: lcov
path: |
coverage/lcov.info
.wxt/
include-hidden-files: true
retention-days: 1
if-no-files-found: error
scan:
name: SonarCloud analysis
needs: coverage
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@v7
with:
# Full history: Sonar's new-code detection and blame need it.
fetch-depth: 0
persist-credentials: false
- uses: actions/download-artifact@v8
with:
name: lcov
path: .
# No npm here: the runner's own Node reads one field of a JSON file.
- name: Read the package version
id: pkg
run: echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
# Dependabot and fork PRs get no repo secrets at all: they skip the scan
# with a notice instead of failing.
- name: Check for SONAR_TOKEN
id: token
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
if [ -n "$SONAR_TOKEN" ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "present=false" >> "$GITHUB_OUTPUT"
echo "::notice::SonarCloud scan skipped — SONAR_TOKEN is not available to this run (Dependabot or fork PR)."
fi
- name: SonarCloud scan
if: steps.token.outputs.present == 'true'
# Pinned to a commit, not a moving tag: this step holds a token. Dependabot
# proposes updates (with the repo's 7-day cooldown).
uses: SonarSource/sonarqube-scan-action@e805d875275f728fac1885b413934be6d7c63f65 # v8.4.1
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.projectVersion=${{ steps.pkg.outputs.version }}