Skip to content

Commit 637a89a

Browse files
committed
ci: cache SonarScanner CLI to avoid flaky CDN download
The scan action downloads the scanner CLI from binaries.sonarsource.com on every run, which intermittently returns HTTP 403 and fails the build. The action checks the tool-cache first (tc.find) and only downloads on a miss, so persisting that directory with actions/cache makes every run after the first restore the scanner and skip the CDN entirely. scannerVersion is pinned to keep the cache key in sync.
1 parent 4408ba5 commit 637a89a

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,19 @@ jobs:
8383
- run: bun install --frozen-lockfile
8484
- name: Run Tests
8585
run: bun run coverage
86+
# Persist the scanner CLI across runs so the action restores it from cache
87+
# (tc.find short-circuits the download) instead of fetching it from the
88+
# intermittently-403ing binaries.sonarsource.com on every run.
89+
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
90+
if: ${{ env.SONAR_TOKEN != '' }}
91+
env:
92+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
93+
with:
94+
path: ${{ runner.tool_cache }}/sonar-scanner-cli
95+
key: sonar-scanner-cli-${{ runner.os }}-${{ runner.arch }}-8.1.0.6389
8696
- uses: sonarsource/sonarqube-scan-action@7006c4492b2e0ee0f816d36501671557c97f5995 # v8.1
87-
# Reporting only; a transient scanner-download 403 must not fail the build. The quality gate is reported via its own check.
88-
continue-on-error: true
97+
with:
98+
scannerVersion: 8.1.0.6389
8999
env:
90100
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91101
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)