Skip to content

Port upstream changes from bazel-contrib/setup-bazel v0.9.0 to v0.19.0#30

Open
bruce-y wants to merge 4 commits intomainfrom
feature/port-upstream-v0.19.0
Open

Port upstream changes from bazel-contrib/setup-bazel v0.9.0 to v0.19.0#30
bruce-y wants to merge 4 commits intomainfrom
feature/port-upstream-v0.19.0

Conversation

@bruce-y
Copy link
Copy Markdown

@bruce-y bruce-y commented Mar 26, 2026

This PR ports all behavioral improvements from upstream bazel-contrib/setup-bazel (v0.9.0 through v0.19.0) into the fork while preserving the Blacksmith sticky disk integration and CommonJS module system. The upstream migrated to ESM, so this is a manual port of the logic changes rather than a git merge.

How it works:

  • Three new action inputs: cache-save (gate cache saving, useful for PRs), module-root (monorepo support by prefixing all file patterns), and output-base (configurable Bazel output base with smart Windows C:/D: detection)
  • config.js now adds arch to cache keys for multi-arch correctness, parses repository-cache as YAML (enabling list syntax), uses common scope for repository_cache bazelrc flag, derives Windows disk/repo paths from output-base, uses RUNNER_TEMP for Google credentials, includes repository cache files in the disk cache key, and exports BAZELISK_GITHUB_TOKEN for authenticated Bazelisk downloads
  • index.js replaces the setTimeout(delay, callback) pattern in restoreCache with proper await setTimeout(delay) + try/catch/finally for error resilience, parallelizes external cache manifest restores with Promise.all, reads the GitHub token from BAZELISK_GITHUB_TOKEN env var, and adds Windows .exe extension when caching the bazel binary
  • post.js gates external cache saving behind config.cacheSave (sticky disk cleanup always runs regardless)
  • action.yml adds post-if: "!cancelled()" so cleanup runs even on job cancellation

The dependency versions stay on their current CJS-compatible majors (@actions/core v1, @actions/github v6, etc.) since the upstream bumped to ESM-only major versions that would break the @connectrpc/@buf gRPC packages. The behavioral changes we're porting don't depend on those API changes. The dist/ bundles will need rebuilding in CI — the source changes are committed here, and CI will flag if the dist is stale.

bruce-y and others added 4 commits March 26, 2026 19:12
Port behavioral improvements from upstream while preserving the Blacksmith
sticky disk integration and CommonJS module system.

New action inputs:
- cache-save: disable cache saving (e.g. on PRs)
- module-root: support monorepo layouts
- output-base: configurable Bazel output base

Key changes:
- Add arch to cache key for multi-arch correctness
- Parse repository-cache as YAML for list support
- Use common scope for repository_cache bazelrc flag
- Prefix file patterns with module-root for monorepo support
- Use RUNNER_TEMP for Google credentials temp dir
- Include repository cache files in disk cache key
- Export BAZELISK_GITHUB_TOKEN for Bazelisk downloads
- Improve restoreCache with try/catch/finally error handling
- Parallelize external cache manifest restores
- Add Windows .exe extension for cached bazel binary
- Gate external cache saving on cache-save input
- Add post-if to ensure cleanup runs on cancellation
- Derive Windows disk/repo paths from output-base
- Bump version to 0.19.0, Node to 24.14.0, checkout to v6

Co-authored-by: Codesmith <codesmith@blacksmith.sh>
Co-authored-by: Codesmith <codesmith@blacksmith.sh>
The dist bundles were rebuilt locally without the Buf registry packages
(which require BUF_TOKEN auth), causing @connectrpc/connect to be
replaced with @@NotFound stubs that crash at runtime.

Reverts dist/ to the last known working state and changes CI to:
- Auto-commit rebuilt dist instead of failing on differences
- Check out the actual branch head (not merge commit) so push works
- Run setup-bazel matrix jobs after test to use fresh dist
- Pass ref to setup-bazel checkout so it picks up auto-committed dist

Co-authored-by: Codesmith <codesmith@blacksmith.sh>
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

using: node24
main: dist/main/index.js
post: dist/post/index.js
post-if: "!cancelled()"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

post-if prevents cleanup on job cancellation

Medium Severity

Adding post-if: "!cancelled()" actually prevents the post script from running on job cancellation. The default behavior (no post-if) is equivalent to always(), which runs on success, failure, and cancellation. The new !cancelled() condition excludes cancellation, meaning cleanupStickyDisks() in post.js won't execute when a job is cancelled. This contradicts the PR description's claim that "sticky disk cleanup always runs regardless" and could lead to leaked sticky disk resources on cancelled jobs.

Fix in Cursor Fix in Web

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