Skip to content

feat(build-dependency-cache): share the S3 cache actions for sbt, mise and uv (SC-88184) - #20

Merged
samidalouche merged 1 commit into
mainfrom
feat/sc-88184/build-dependency-cache
Nov 24, 2026
Merged

samidalouche merged 1 commit into
mainfrom
feat/sc-88184/build-dependency-cache

Conversation

@samidalouche

@samidalouche samidalouche commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

SC-88184, in epic 87120; it also covers SC-87870. narrative-marketplace-backend, narrative-connectors and narrative-snowflake-data-plane each carry an identical copy of the action that keeps sbt's dependency caches in S3 rather than GitHub's cache, which our runners reach through a NAT gateway that bills every byte. narrative-marketplace-backend#3556 replaces it with .github/actions/build-dependency-cache: an engine and one action per tool, for sbt, mise's tools and uv's packages. This puts that folder here, file for file, for the three repositories to pin.

Moving parts

What it is Restores Saves
s3_cache.py The archive logic: --kind sbt|mise|uv picks the folders and key files. Callers never run it directly. the exact key, else latest; skips the download when the runner already has the key only a key not saved yet, on a push to main, then points latest at it
cache-sbt (JavaScript) sbt's dependency caches. JavaScript only to get a post step; its scripts start s3_cache.py through s3-cache.js. in its step in its post step, when the job ends with every step passed, in the job that passes save: true
setup-mise (composite) jdx/mise-action with its cache off, and mise's data directory kept in S3. Composite because only a composite action can call mise-action. before mise-action right after the install, after mise prune --yes --tools; its save step's comment explains why first rather than last
cache-uv (JavaScript) uv's cache, one archive per project, keyed on its uv.lock. in its step, before uv sync in its post step, as cache-sbt
  • No action calls another: an action here can only reach a sibling with uses: narrative-io/common-github/<path>@<commit>, and a commit can't name itself; ./<path> would point into the caller's checkout. So they all run s3_cache.py from this repository's checkout the runner made for the action.
  • The bucket stays out of this public repository: all three require url, which callers pass from the organization variable COMMON_GITHUB_BUILD_DEPENDENCY_CACHE, because an action's action.yml can't read vars itself. With it empty, the step fails, so no job runs without its cache unnoticed; trouble reaching S3 still only warns. The README's new "Configure" section says how to set the variable up, without naming the bucket. Callers keep their own kill switches.
  • Docs and tests: build-dependency-cache/README.md explains the archives, use and trust. The folder is a uv project: pytest tests the engine against an S3 kept in memory, node --test the JavaScript, and the build-dependency-cache workflow runs both, with ruff and ty, on pull requests that change the folder. The root's ruff.toml copies narrative-marketplace-backend's rules, and its mise.toml pins uv and node.

The root README lists the folder under a new "Contents" section, and its "Releases" example shows an action pin as well as a workflow pin.

Release and rollout

feat: makes release-please open a release PR for v1.2.0. After it's merged, narrative-marketplace-backend#3560, narrative-connectors#377 and narrative-snowflake-data-plane#395 move their pins from this branch's commit to v1.2.0, and merge.

Testing

  • build-dependency-cache/tests/: 60 pytest tests (the decisions as plain values; sbt, mise and uv saves and restores against an S3 kept in memory: latest fallback, scopes and projects, warm runners, excluded files, a failed extraction, an out-of-HOME data directory, an empty URL that fails the step; a real GNU tar and zstd round trip, which skips on macOS) and 6 node --test tests (only a push to main with save: true saves; the step fails when python3 does) pass, here and in narrative-marketplace-backend's copy, which differs only in the path its pyproject.toml extends ruff's rules from.
  • zizmor 1.32.0 (offline) and actionlint 1.7.12: no findings. shellcheck, prettier and ty: clean.
  • The actions themselves run in the consumers' CI, through the PRs above. Dispatched on their branches, narrative-connectors' s3 and framework tests and narrative-snowflake-data-plane's four test workflows passed: cache-sbt restored connectors' existing 5.47 GiB archive in 14s, and setup-mise and cache-uv found no archive yet, as expected before main saves one.

🤖 Generated with Claude Code

@samidalouche
samidalouche force-pushed the feat/sc-88184/build-dependency-cache branch 2 times, most recently from d2770d1 to 1ac8626 Compare November 24, 2026 17:27
@samidalouche samidalouche changed the title feat(build-dependency-cache): share the S3 cache actions for sbt and mise (SC-88184) feat(build-dependency-cache): share the S3 cache actions for sbt, mise and uv (SC-88184) Nov 24, 2026
@samidalouche
samidalouche force-pushed the feat/sc-88184/build-dependency-cache branch 4 times, most recently from 4add6bd to 5a8123b Compare November 24, 2026 20:35
…e and uv (SC-88184)

narrative-marketplace-backend, narrative-connectors and narrative-snowflake-data-plane each carry an identical copy of
the action that keeps sbt's dependency caches in S3 instead of GitHub's cache, which the runners reach through a NAT
gateway that bills every byte (SC-87124). narrative-marketplace-backend#3556 replaces it with
.github/actions/build-dependency-cache: an engine and one action per tool, adding mise's tools, the bulk of the NAT
traffic left, and uv's packages, which nothing cached in narrative-marketplace-backend and GitHub's cache held in
narrative-snowflake-data-plane. This puts that folder here, file for file, for the three repositories to pin; only
the path its pyproject.toml extends ruff's rules from differs.

- build-dependency-cache/s3_cache.py: the archive logic, with kinds sbt, mise and uv: folders, key files, S3 layout,
  latest, runner markers, saving only on a push to main, and stats in the log.
- build-dependency-cache/cache-sbt and cache-uv: JavaScript actions only to get a post step, which saves when the job
  ends with every step passed, in the job that passes save: true. Their scripts start s3_cache.py through
  build-dependency-cache/s3-cache.js.
- build-dependency-cache/setup-mise: a composite action around jdx/mise-action, with its cache off, that restores
  before it and prunes and saves right after it. It runs s3_cache.py itself: an action here can only reach a sibling
  with `uses: narrative-io/common-github/<path>@<commit>`, and a commit can't name itself.
- All three require url, the base S3 URL, which callers pass from the organization variable
  COMMON_GITHUB_BUILD_DEPENDENCY_CACHE, so the bucket stays out of this public repository. An empty url fails the step,
  so a repository can't run without its cache unnoticed; trouble reaching S3 still only warns. Callers keep their kill
  switches.
- build-dependency-cache is a uv project with tests: pytest checks s3_cache.py's decisions with plain values, and its
  restores and saves against an S3 kept in memory; node's test runner checks s3-cache.js. The build-dependency-cache
  workflow runs them, with ruff and ty, on pull requests that change the folder. ruff.toml copies
  narrative-marketplace-backend's rules, and mise.toml pins the uv and node the tests run with.
- build-dependency-cache/README.md explains the archives, how to use the actions, and what's trusted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@samidalouche
samidalouche force-pushed the feat/sc-88184/build-dependency-cache branch from 5a8123b to 59ed15d Compare November 24, 2026 20:41
@samidalouche
samidalouche merged commit 20c4303 into main Nov 24, 2026
3 checks passed
@samidalouche
samidalouche deleted the feat/sc-88184/build-dependency-cache branch November 24, 2026 20:42
@@ -0,0 +1,124 @@
# build-dependency-cache

@lakinwecker lakinwecker Nov 30, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: We're doing a lot of work here for what devenv almost gives us for free. No change necessary for this PR, just noting that if we were to lean into devenv more heavily we'd get so much more of this out of the box.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear: switching to devenv isn't seemless or painless, just that this kind of caching comes (mostly) for free. :D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If devenv could simplify how we do CI / caching / etc (in ways that are complementary to Dagger?), I'm happy with the direction of devenv-ifying CI.

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.

2 participants