Skip to content

fix(scala-ci): install the sbt launcher from a pinned-hash download with a stable-path cache - #50

Merged
monsieurleberre merged 1 commit into
devfrom
fix/scala-ci-sbt-launcher-cache
Nov 6, 2026
Merged

monsieurleberre merged 1 commit into
devfrom
fix/scala-ci-sbt-launcher-cache

Conversation

@monsieurleberre

Copy link
Copy Markdown
Contributor

Why

On self-hosted ephemeral runners, sbt/setup-sbt's own cache never hits. Each job gets a fresh $RUNNER_TOOL_CACHE, and that path is part of the actions/cache version. So every job downloads sbt again, and setup-sbt then bootstraps ampel from GitHub releases to verify the signature. That bootstrap fails intermittently. The two errors seen so far are ampel-v1.3.6.provenance.json: context deadline exceeded and compiling policy: unable to parse a policy, group or policySet from data. Either one fails the build-and-test job, even though ampel runs in monitor-only mode (fail: false).

What

In scala-ci.yaml, the sbt/setup-sbt step is replaced by:

  • actions/cache/restore of a fixed ~/.cache/sbt-launcher, keyed scala-ci-sbt-launcher-<runner.environment>-<os>-<arch>-<version>. actions/cache stores the path relative to the workspace, and hosted and self-hosted runners lay it out at different depths, so the runner environment is part of the key;
  • a presence check: the install runs whenever sbt/bin/sbt is missing after the restore, not on cache-hit alone;
  • when the launcher is missing, one curl --fail --location download of sbt-<version>.zip from the sbt release, with connect and total timeouts. The zip is hashed from stdin, so a Windows backslash path can't corrupt the output, and checked against a pinned SHA-256 and the step fails closed, on every OS, where ampel only monitored on Linux. Then it is unzipped, using POSIX paths via cygpath -u on Windows;
  • actions/cache/save right after an install, and only then,, so a later build failure still leaves the launcher cached;
  • the launcher's bin directory added to PATH, using cygpath -w on Windows.

The pinned hash for sbt 2.0.12 is 73f9c4a10584cde3d37d773e2b38d2fc4348c6cef8d88da8b7dd41e7d5f614d7. It matches a local shasum -a 256 of the download, the release's published sbt-2.0.12.zip.sha256, and the GitHub release-asset digest.

Inputs, outputs and secrets are unchanged, so this is a contract-compatible change on v2. The setup-sbt sbt 2.x disk-cache step is dropped; the CHANGELOG notes the drop.

Verified in a consumer

An earlier revision of this change (without the environment-aware key and the stdin hash) was probed in a consumer:

  • Run 1: Cache not found for input keys: sbt-launcher-Linux-X64-2.0.12. The download and hash check passed, and Cache saved with key: sbt-launcher-Linux-X64-2.0.12. The job is green.
  • Run 2, after an empty commit: Cache hit for: sbt-launcher-Linux-X64-2.0.12. Download and save were skipped, and the job is green.

Only the Linux shard ran in that consumer. The Windows and macOS paths have not run on a real runner yet.

The download step was also re-run in ubuntu:24.04 with real and wrong hashes, on plain and backslash temp paths: real hashes install, wrong hashes exit 1 with nothing installed.

actionlint is clean.

@monsieurleberre

Copy link
Copy Markdown
Contributor Author

Consumer probe of head 50d0bd6, all build-and-test green:

  • Self-hosted Linux, miss: Cache not found for input keys: scala-ci-sbt-launcher-self-hosted-Linux-X64-2.0.12. Download, hash check and save passed, then Cache saved with key: scala-ci-sbt-launcher-self-hosted-Linux-X64-2.0.12.
  • Self-hosted Linux, next run: Cache hit for: scala-ci-sbt-launcher-self-hosted-Linux-X64-2.0.12. Download and save were skipped.
  • Full hosted matrix (ubuntu amd64/arm64, windows-amd64, macos arm64/amd64): each was a cold miss that downloaded, verified, saved its own github-hosted-… key and built green. This was the first real Windows run of the stdin hash and the cygpath path handling.

An independent review found no P0/P1.

@monsieurleberre
monsieurleberre marked this pull request as ready for review November 6, 2026 11:21
@monsieurleberre
monsieurleberre enabled auto-merge (squash) November 6, 2026 11:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T11:23:01.480413Z 50d0bd6 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@monsieurleberre
monsieurleberre merged commit b8f0c2b into dev Nov 6, 2026
2 checks passed
@monsieurleberre
monsieurleberre deleted the fix/scala-ci-sbt-launcher-cache branch November 6, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant