Skip to content

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

Closed
monsieurleberre wants to merge 1 commit into
devfrom
fix/124-scala-ci-sbt-launcher-cache
Closed

monsieurleberre wants to merge 1 commit into
devfrom
fix/124-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 sbt-launcher-<os>-<arch>-<version>;
  • on a miss, one curl --fail --location download of sbt-<version>.zip from the sbt release, with connect and total timeouts. The zip is checked against a pinned SHA-256 and the step fails closed, on every OS, where ampel only monitored on Linux. Then it is unzipped;
  • on a miss, actions/cache/save right after the install, 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

A draft PR pointed one consumer's scala-ci call at this branch:

  • 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.

actionlint is clean.

@monsieurleberre

Copy link
Copy Markdown
Contributor Author

Superseded by #50, which carries the review fixes on a fresh branch.

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