-
Notifications
You must be signed in to change notification settings - Fork 412
chore(ci): make sccache fail gracefully #4208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| name: Probe sccache backend | ||
| description: > | ||
| Verify the sccache backend is reachable; if not, unset RUSTC_WRAPPER so | ||
| the job runs without sccache rather than failing. Handles transient | ||
| outages of GHA cache (Blacksmith proxy 502, GitHub cache hiccups, etc.) | ||
| without requiring a re-run. | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Probe sccache backend | ||
| # Skip on Windows: our Windows runners are self-hosted hetz with | ||
| # local-disk sccache (no GHA backend → no 502s to handle), and | ||
| # `shell: bash` on those runners resolves to the WSL launcher | ||
| # which fails outright. Probe only matters where SCCACHE_GHA_ENABLED | ||
| # is in play, i.e. Linux self-hosted (Blacksmith) and ubuntu-latest. | ||
| if: env.RUSTC_WRAPPER == 'sccache' && runner.os != 'Windows' | ||
| shell: bash | ||
| env: | ||
| # Cap each --start-server attempt at 5s in case sccache hangs on | ||
| # backend init. Empirically 502s from Blacksmith's GHA proxy | ||
| # already fail in ~5s; this just bounds pathological hangs. | ||
| # Two attempts × 5s = ~10s worst case. Portable across | ||
| # Linux/macOS/Windows bash (no coreutils `timeout` needed). | ||
| SCCACHE_STARTUP_NOTIFY_TIMEOUT: "5" | ||
| run: | | ||
| # If the sccache binary isn't installed (e.g. mozilla-actions/sccache-action | ||
| # failed to download from GitHub releases), bail out fast. | ||
| if ! command -v sccache >/dev/null 2>&1; then | ||
| echo "::warning::sccache binary not found (install likely failed); running this job without sccache" | ||
| echo "RUSTC_WRAPPER=" >> "$GITHUB_ENV" | ||
| echo "SCCACHE_GHA_ENABLED=" >> "$GITHUB_ENV" | ||
| exit 0 | ||
| fi | ||
| # sccache --start-server triggers a backend probe (.sccache_check | ||
| # read). On failure (e.g. Blacksmith's GHA cache proxy returning | ||
| # 502 Bad Gateway), the daemon won't start and every rustc call | ||
| # fails. One quick retry, then fall through to plain rustc — | ||
| # slower, but the job will still succeed. | ||
| for attempt in 1 2; do | ||
| if sccache --start-server >/dev/null 2>&1; then | ||
| echo "sccache backend OK (attempt $attempt)" | ||
| exit 0 | ||
| fi | ||
| echo "sccache start failed (attempt $attempt/2)" | ||
| done | ||
| echo "::warning::sccache backend unreachable; running this job without sccache" | ||
| # mozilla-actions/sccache-action exports these via $GITHUB_ENV — override. | ||
| echo "RUSTC_WRAPPER=" >> "$GITHUB_ENV" | ||
| echo "SCCACHE_GHA_ENABLED=" >> "$GITHUB_ENV" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the right way to clear an env variable? :O
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well 2 things happening here:
a) if it was set before you kinda need to unset it so this would be bash wise wrong
b) this is github actions and they have their funny github_env thing which I'd rather not touch more than needed and it doesn't have proper unset semantics