|
| 1 | +name: Probe sccache backend |
| 2 | +description: > |
| 3 | + Verify the sccache backend is reachable; if not, unset RUSTC_WRAPPER so |
| 4 | + the job runs without sccache rather than failing. Handles transient |
| 5 | + outages of GHA cache (Blacksmith proxy 502, GitHub cache hiccups, etc.) |
| 6 | + without requiring a re-run. |
| 7 | +
|
| 8 | +runs: |
| 9 | + using: composite |
| 10 | + steps: |
| 11 | + - name: Probe sccache backend |
| 12 | + # Skip on Windows: our Windows runners are self-hosted hetz with |
| 13 | + # local-disk sccache (no GHA backend → no 502s to handle), and |
| 14 | + # `shell: bash` on those runners resolves to the WSL launcher |
| 15 | + # which fails outright. Probe only matters where SCCACHE_GHA_ENABLED |
| 16 | + # is in play, i.e. Linux self-hosted (Blacksmith) and ubuntu-latest. |
| 17 | + if: env.RUSTC_WRAPPER == 'sccache' && runner.os != 'Windows' |
| 18 | + shell: bash |
| 19 | + env: |
| 20 | + # Cap each --start-server attempt at 5s in case sccache hangs on |
| 21 | + # backend init. Empirically 502s from Blacksmith's GHA proxy |
| 22 | + # already fail in ~5s; this just bounds pathological hangs. |
| 23 | + # Two attempts × 5s = ~10s worst case. Portable across |
| 24 | + # Linux/macOS/Windows bash (no coreutils `timeout` needed). |
| 25 | + SCCACHE_STARTUP_NOTIFY_TIMEOUT: "5" |
| 26 | + run: | |
| 27 | + # If the sccache binary isn't installed (e.g. mozilla-actions/sccache-action |
| 28 | + # failed to download from GitHub releases), bail out fast. |
| 29 | + if ! command -v sccache >/dev/null 2>&1; then |
| 30 | + echo "::warning::sccache binary not found (install likely failed); running this job without sccache" |
| 31 | + echo "RUSTC_WRAPPER=" >> "$GITHUB_ENV" |
| 32 | + echo "SCCACHE_GHA_ENABLED=" >> "$GITHUB_ENV" |
| 33 | + exit 0 |
| 34 | + fi |
| 35 | + # sccache --start-server triggers a backend probe (.sccache_check |
| 36 | + # read). On failure (e.g. Blacksmith's GHA cache proxy returning |
| 37 | + # 502 Bad Gateway), the daemon won't start and every rustc call |
| 38 | + # fails. One quick retry, then fall through to plain rustc — |
| 39 | + # slower, but the job will still succeed. |
| 40 | + for attempt in 1 2; do |
| 41 | + if sccache --start-server >/dev/null 2>&1; then |
| 42 | + echo "sccache backend OK (attempt $attempt)" |
| 43 | + exit 0 |
| 44 | + fi |
| 45 | + echo "sccache start failed (attempt $attempt/2)" |
| 46 | + done |
| 47 | + echo "::warning::sccache backend unreachable; running this job without sccache" |
| 48 | + # mozilla-actions/sccache-action exports these via $GITHUB_ENV — override. |
| 49 | + echo "RUSTC_WRAPPER=" >> "$GITHUB_ENV" |
| 50 | + echo "SCCACHE_GHA_ENABLED=" >> "$GITHUB_ENV" |
0 commit comments