← Back to Pull requests

ci(bazel): pin the bazelisk digests instead of querying the releases API #3828

Closed
unknown closed this pull request without merging on Oct 01, 2026 18:04 UTC
View on GitHub
unknown unknown commented on Sep 30, 2026 08:13 UTC
Author

Description

Second step of the Bazel maintainability series (after #3827).

install-bazel did not download Bazelisk directly: it first called
api.github.com/repos/bazelbuild/bazelisk/releases/tags/$BAZELISK_VERSION,
hand-parsed the JSON with a while read loop to find the asset digest, and only
then downloaded. That API is rate limited per IP for unauthenticated callers, so
on a busy runner the request comes back 403, the digest string ends up empty and
the step dies with a download failure that has nothing to do with the change
under test. GITHUB_TOKEN is passed when it happens to be in the environment,
but most of the jobs that run this script do not export one.

This PR pins the digests next to the version, downloads the asset directly and
verifies it locally, so the install no longer depends on a network API call at
all. The version itself is unchanged (v1.29.0).

Three pre-existing problems fall out of the rewrite:

The digest was never actually enforced. .ci/env/bazelisk.sh ran
echo "$SHA256" | sha256sum --check and ignored the exit status. The script is
sourced by most of its callers, so it cannot use set -e either. A mismatch
printed FAILED into the log and the build went on and used the binary. The
check is now explicit and removes the file before exiting non-zero.
nightly-test.yml lost the PATH export. That workflow runs the script
rather than sourcing it, so the export PATH=... at the end went to a
subshell; the job worked only because the runner image already had a bazel
on PATH. Both scripts now also append the install directory to GITHUB_PATH.
The Windows jobs pinned Bazelisk a second time. WindowsBazel and
WindowsBazelReleaseAll each declared their own BAZELISK_VERSION (which had
drifted to v1.28.1, one release behind the shell script) and inlined the
download in four lines of PowerShell. They now call .ci/env/bazelisk.ps1,
which publishes BAZELISK_VERSION and BAZELISK_EXE back as pipeline
variables via ##vso[task.setvariable], so the version lives in exactly one
place per platform and the Cache@2 keys keep working unchanged.

bazelisk.ps1 picks its output channel from the environment: GITHUB_PATH under
GitHub Actions, the two ##vso variables under Azure (TF_BUILD), and the
process PATH otherwise, which makes it usable for local reproduction.

Trade-off to be aware of

Renovate bumps BAZELISK_VERSION / $bazeliskVersion but cannot compute the
release asset digests, so a Renovate version bump will now fail install-bazel
until the digests are updated in the same PR. That is deliberate — a loud,
self-explanatory failure is better than the silent unverified install we had —
and the error message quotes the exact command that prints the new digests:

gh release view <version> -R bazelbuild/bazelisk \
  --json assets --jq '.assets[] | "\(.name) \(.digest)"'

Changes

| File | Change |
| --- | --- |
| .ci/env/bazelisk.sh | Pinned amd64/arm64 digests, direct download, enforced hash check, GITHUB_PATH |
| .ci/env/bazelisk.ps1 | Pinned digest, direct download, Get-FileHash check, GITHUB_PATH / ##vso / PATH |
| .ci/pipeline/ci.yml | Both Windows Bazel jobs delegate to the script; duplicated BAZELISK_
variables dropped |
| .gitignore | Ignore the bazel/ install directory the scripts create |

No behavioural change to the Bazel build itself.

Validation

Linux, in a scratch directory:

happy path, sourced — exit 0, BAZEL_VERSION=9.2.0, bazel/bin/bazel
installed, GITHUB_PATH file contains the install directory;
failure path with a deliberately zeroed digest — FAILED, the :error:
message naming the script to fix, exit 1, and no binary left behind (the old
script installed it);

  • the pinned bazelisk-linux-amd64 digest re-derived with sha256sum on the

  • downloaded asset, independently of the release metadata.

    The Windows digest and the ##vso variable publication are what WindowsBazel
    and WindowsBazelReleaseAll on this PR exercise; there is no Windows host
    available locally.

    ---

  • I have reviewed my changes thoroughly before submitting this pull request.

  • I have commented my code, particularly hard-to-understand areas.

  • I have updated the documentation or contribution guidelines as needed.

  • I have added tests that reproduce the issue or verify the new functionality.

  • All new and existing tests pass.
  • 🤖 Generated with Claude Code

    Diff: 583 lines (+437 / -146) across 7 files Reviewer: icfaust Review duration: 2030m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 583 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.381
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3828"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.9% (MEDIUM) · Higher = larger blast radius
    49.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.7% · Safe to merge
    19.7%