Skip to content

feat: enable GH action caching#118

Merged
bnusunny merged 4 commits intoaws-actions:mainfrom
frichtarik:cache
Feb 6, 2026
Merged

feat: enable GH action caching#118
bnusunny merged 4 commits intoaws-actions:mainfrom
frichtarik:cache

Conversation

@frichtarik
Copy link
Contributor

@frichtarik frichtarik commented Oct 20, 2025

Which issue(s) does this change fix?

#103

Description

main goal:

  • Enabled cross-runner caching of native installer via GH actions cache
  • Not planning implementation of caching for pip installation - it's much more efficient to switch to native installer instead

side tasks:

  • Updated dependencies
  • simplified logic (fail fast on incorrect params)

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 License.

init

cache

Update setup.js
@frichtarik frichtarik marked this pull request as ready for review October 20, 2025 13:21
@frichtarik frichtarik requested a review from a team as a code owner October 20, 2025 13:21
@frichtarik
Copy link
Contributor Author

GH checks are green https://github.com/frichtarik/setup-sam/pull/1/checks

@frichtarik
Copy link
Contributor Author

Ola, any chance on getting a review ? :)

Copy link

@bnusunny bnusunny left a comment

Choose a reason for hiding this comment

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

Thanks for this PR! Cross-runner caching is a great improvement.

One concern: the cache key doesn't include the runner OS image version:

const cacheKey = `sam-cli-${os.platform()}-${arch}-${version}`;

Since @actions/cache persists across workflow runs, this could cause issues when users run on different runner images. SAM CLI bundles libraries like OpenSSL in dist/_internal/, and when it spawns subprocesses (npm, node, etc.), those processes can pick up the bundled libraries instead of system ones. If the bundled library version doesn't match what the system tools expect, builds fail — see aws/aws-sam-cli#8542 for an example where Node.js fails because it loads SAM CLI's older OpenSSL instead of the system version.

Scenario:

  1. User caches SAM CLI on ubuntu-22.04
  2. GitHub updates ubuntu-latest to ubuntu-24.04 (or user changes their workflow)
  3. Cached SAM CLI's bundled libraries are incompatible with the new runner's system tools

Suggested fix — include the runner image in the cache key:

const imageOS = process.env.ImageOS || "unknown";
const cacheKey = `sam-cli-${os.platform()}-${imageOS}-${arch}-${version}`;

This would produce keys like sam-cli-linux-ubuntu22-x86_64-1.139.0, ensuring cache isolation between different runner images.

@frichtarik frichtarik requested a review from bnusunny February 5, 2026 18:20
@frichtarik
Copy link
Contributor Author

Thanks for this PR! Cross-runner caching is a great improvement.

One concern: the cache key doesn't include the runner OS image version:

const cacheKey = `sam-cli-${os.platform()}-${arch}-${version}`;

Since @actions/cache persists across workflow runs, this could cause issues when users run on different runner images. SAM CLI bundles libraries like OpenSSL in dist/_internal/, and when it spawns subprocesses (npm, node, etc.), those processes can pick up the bundled libraries instead of system ones. If the bundled library version doesn't match what the system tools expect, builds fail — see aws/aws-sam-cli#8542 for an example where Node.js fails because it loads SAM CLI's older OpenSSL instead of the system version.

Scenario:

  1. User caches SAM CLI on ubuntu-22.04
  2. GitHub updates ubuntu-latest to ubuntu-24.04 (or user changes their workflow)
  3. Cached SAM CLI's bundled libraries are incompatible with the new runner's system tools

Suggested fix — include the runner image in the cache key:

const imageOS = process.env.ImageOS || "unknown";
const cacheKey = `sam-cli-${os.platform()}-${imageOS}-${arch}-${version}`;

This would produce keys like sam-cli-linux-ubuntu22-x86_64-1.139.0, ensuring cache isolation between different runner images.

Hi @bnusunny, thank you very much for the review.

Of course you are right, I've adjusted the code and tests accordingly.

Fresh test workflow results can be found here

Looking forward to finishing this.

F.

@bnusunny
Copy link

bnusunny commented Feb 5, 2026

@frichtarik Thanks for the update. Looks good. There is one minor lint error. Once it is fixed, we can merge it.

@frichtarik
Copy link
Contributor Author

@bnusunny I've missed new commit in upstream, now everything should pass.
thx

@bnusunny bnusunny merged commit d78e1a4 into aws-actions:main Feb 6, 2026
31 checks passed
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.

3 participants