Skip to content

fix(build-dependency-cache): save with the region the restore ran with (SC-88184) - #22

Merged
samidalouche merged 1 commit into
mainfrom
fix/sc-88184/build-dependency-cache-save-with-the-restores-region
Nov 24, 2026
Merged

samidalouche merged 1 commit into
mainfrom
fix/sc-88184/build-dependency-cache-save-with-the-restores-region

Conversation

@samidalouche

Copy link
Copy Markdown
Contributor

Story

SC-88184: CI, keep sbt's, mise's and uv's caches in S3. A fix to #20.

What and why

cache-sbt and cache-uv save from their post step. Post steps run in the reverse order of their steps, so in a job that configures AWS credentials after the cache step, the save runs after configure-aws-credentials' cleanup. That cleanup sets AWS_REGION and AWS_DEFAULT_REGION to "" (GitHub Actions can't unset a variable), and the aws CLI takes "" as the region:

sbt dependency cache: couldn't save, so other runs restore an older one: couldn't check
s3://…/aws-to-snowflake-monitoring/8b3ed52c….tar.zst: Invalid endpoint: https://s3..amazonaws.com

That's every save in narrative-snowflake-data-plane's aws-to-snowflake-monitoring-test and data-plane-snowflake-test, and narrative-connectors' global-dependency-graph. The jobs still pass, since a failed save only warns, but they'd never save a new archive.

  • The restore keeps the region it ran with in the step's state ($GITHUB_STATE), which the runner hands to the post step as STATE_AWS_REGION and STATE_AWS_DEFAULT_REGION.
  • The save sets each back when it's empty, and leaves a region that's still set alone.
  • Credentials need nothing: the CLI skips the empty ones the cleanup leaves and falls back to the runner's instance role, the same one the restore used before configure-aws-credentials ran.

Testing

  • tests/s3-cache.test.js: the restore keeps the region, keeps nothing without one, and warns when it can't write the state; the save gets a blanked region back and keeps one still set.
  • With the environment the cleanup leaves, aws s3api head-object fails with Invalid endpoint: https://s3..amazonaws.com when the region is empty, and goes on to look for credentials once it's set.
  • After the release, the consumers' first push to main should log sbt dependency cache: saved … (or … is already saved) in those three jobs.

🤖 Generated with Claude Code

…h (SC-88184)

cache-sbt and cache-uv save from their post step, and post steps run in the reverse order of their steps, so in a job
that configures AWS credentials after the cache step, the save runs after configure-aws-credentials' post step. That
step sets AWS_REGION and AWS_DEFAULT_REGION to "", since GitHub Actions can't unset a variable, and the aws CLI takes ""
as the region. Every save in such a job failed, after narrative-snowflake-data-plane#395 moved to these actions:

  sbt dependency cache: couldn't save, so other runs restore an older one: couldn't check
  s3://…/aws-to-snowflake-monitoring/8b3ed52c….tar.zst: Invalid endpoint: https://s3..amazonaws.com

The restore didn't, as it ran before configure-aws-credentials. It's the case in narrative-snowflake-data-plane's
aws-to-snowflake-monitoring-test and data-plane-snowflake-test, and narrative-connectors' global-dependency-graph.

- s3-cache.js: the restore keeps AWS_REGION and AWS_DEFAULT_REGION in the step's state, which the runner hands to the
  post step as STATE_<name>, and the save sets each back when it's empty. A region still set is left alone. Failing to
  keep it only warns, since a save in a job without configure-aws-credentials doesn't need it.
- The credentials that post step blanks are left as they are: the CLI skips empty ones and falls back to the runner's
  instance role, the one the restore used. With an empty region, `aws s3api head-object` fails with the error above;
  with the region set, it goes on to look for credentials.
- tests/s3-cache.test.js: the restore keeps the region, keeps nothing without one and warns when it can't; the save
  gets a blanked region back and keeps one still set.
- README.md says why the save needs it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@samidalouche
samidalouche merged commit 602f352 into main Nov 24, 2026
3 checks passed
@samidalouche
samidalouche deleted the fix/sc-88184/build-dependency-cache-save-with-the-restores-region branch November 24, 2026 21:15
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