Skip to content

feat(ci): require bash >= 4.2 in the pre-commit hook scripts - #3837

Open
ethanlin01x wants to merge 4 commits into
apache:masterfrom
ethanlin01x:feat/bash-version-gate
Open

feat(ci): require bash >= 4.2 in the pre-commit hook scripts#3837
ethanlin01x wants to merge 4 commits into
apache:masterfrom
ethanlin01x:feat/bash-version-gate

Conversation

@ethanlin01x

Copy link
Copy Markdown
Contributor

Which issue does this PR address?

Related: #3694

Rationale

Without a declared minimum, every hook script has to be written against bash 3.2 and carry portable fallbacks (#3694). Checking the version once, up front, means anyone writing a hook script from now on can use modern bash without thinking about it.

What changed?

  1. scripts/ci/lib/init.sh checks for bash >= 4.2 and is sourced by the 13 script-backed hooks, so a future check reaches all of them from one place.
  2. The 16 scripts on #!/bin/bash are normalized to #!/usr/bin/env bash first, since on macOS the former is always the system bash 3.2 and no brew install bash can override it.

Local Execution

  • Passed
  • Pre-commit hooks ran

AI Usage

If AI tools were used, please answer:

  1. Which tools? Claude Code
  2. Scope of usage? Implementation
  3. How did you verify the generated code works correctly? Ran the hooks under both bash 3.2 and bash 5,
  4. Can you explain every line of the code if asked? Yes.

On macOS `#!/bin/bash` always resolves to the system bash 3.2, so a script
pinned to it cannot pick up a newer bash a contributor installed. Resolving
bash from PATH instead is a prerequisite for gating on a minimum version.

Scripts that only ever run inside one image keep the absolute path.
Supporting bash 3.2 means writing every hook script against a shell that
predates mapfile and associative arrays, and the fallbacks it forces are
harder to read than what they replace. Kubernetes solved this by refusing
to run and pointing macOS users at `brew install bash`. Do the same here.

The check lives in a sourced lib rather than a single leading hook so that
it also covers running a script straight from the CLI. Sourcing it runs the
check, following hack/lib/init.sh, so a second check reaches all thirteen
hooks by being added in one place.

The error names the resolved interpreter, because a git GUI can hand a hook
a PATH where /bin still wins.
@ethanlin01x
ethanlin01x marked this pull request as ready for review August 7, 2026 15:40
@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.84%. Comparing base (01a64b2) to head (f34fcff).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3837      +/-   ##
============================================
- Coverage     76.58%   75.84%   -0.74%     
  Complexity     1046     1046              
============================================
  Files          1347     1337      -10     
  Lines        171018   169763    -1255     
  Branches     142372   142442      +70     
============================================
- Hits         130967   128750    -2217     
- Misses        36233    37132     +899     
- Partials       3818     3881      +63     
Components Coverage Δ
Rust Core 75.77% <ø> (-0.01%) ⬇️
Java SDK 63.67% <ø> (ø)
C# SDK 71.13% <ø> (-1.16%) ⬇️
Python SDK 88.70% <ø> (ø)
PHP SDK 82.97% <ø> (ø)
Node SDK 96.20% <ø> (-0.08%) ⬇️
Go SDK 41.43% <ø> (-27.75%) ⬇️
see 78 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ethanlin01x

Copy link
Copy Markdown
Contributor Author

/request-review @hubcio

@github-actions
github-actions Bot requested a review from hubcio August 7, 2026 15:49
@ethanlin01x

Copy link
Copy Markdown
Contributor Author

/request-review @numinnex

@github-actions
github-actions Bot requested a review from numinnex August 7, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant