chore: vendor bats test helpers instead of git submodules#859
Conversation
Greptile SummaryThis PR vendors the bats-core, bats-assert, bats-file, and bats-support test helpers directly into the repository, eliminating all git submodule usage. All CI workflows, the Nix flake, the Confidence Score: 5/5Safe to merge — purely mechanical removal of git submodules in favour of vendored copies with no logic changes. All findings are informational. Every submodule reference has been consistently removed across CI workflows, flake.nix, mise-tasks, and contributor docs. The vendored files replace the submodules at the same paths, so test execution paths are unchanged. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Developer clones repo] --> B["git clone https://github.com/jdx/hk.git"]
B --> C[test/bats/ already present\nbats-core vendored]
B --> D[test/test_helper/ already present\nbats-assert, bats-file, bats-support vendored]
C --> E[mise run test:bats]
D --> E
CI[CI Workflow] --> F["actions/checkout\nno submodules flag needed"]
F --> E
subgraph Before
G["git clone --recurse-submodules ..."] --> H["mise run init\ngit submodule update --init --recursive"]
H --> I[test helpers available]
end
subgraph After
B
C
D
end
Reviews (3): Last reviewed commit: "chore: vendor bats test helpers instead ..." | Re-trigger Greptile |
There was a problem hiding this comment.
Code Review
This pul l request vendors the bats-core testing framework and its helper libraries (bats-assert, bats-file, and bats-support) directly into the repository, removing the previous reliance on Git submodules. The review identified several technical issues within the vendored scripts: a bug in bats-exec-suite that incorrectly bundles com m and flags when running in parallel, a failure in the process-tracking logic of bats-exec-test that breaks timeouts, a regression in log filename form atting that introduces spaces, and a syntax error in the regex assertion logic. These issues should be addressed to ensure the testing infrastructure rem ains reliable and portable.
| # shellcheck disable=SC2086,SC2068 | ||
| # we need to handle the quoting of ${flags[@]} ourselves, | ||
| # because parallel can only quote it as one | ||
| "${parallel_binary_name}" --keep-order --jobs "$num_jobs" -- "bats-exec-file" "$(printf "%q " "${flags[@]}")" "{#}" "{}" "$TESTS_LIST_FILE" <<< "$(printf "%s\n" "${BATS_UNIQUE_TEST_FILENAMES[@]}")" 2>&1 || bats_exec_suite_status=1 |
There was a problem hiding this comment.
Bundling the flags array into a single quoted string using printf "%q " before passing it to parallel will cause all flags to be treated as a single argument by the worker processes. This will break option parsing in bats-exec-file. The flags should be passed as separate arguments to allow parallel to handle them correctly.
"${parallel_binary_name}" --keep-order --jobs "$num_jobs" -- "bats-exec-file" "${flags[@]}" "{#}" "{}" "$TESTS_LIST_FILE" <<< "$(printf "%s\n" "${BATS_UNIQUE_TEST_FILENAMES[@]}")" 2>&1 || bats_exec_suite_status=1
| printf "%d\n" "${row[$pid_col]}" | ||
| fi | ||
| done | ||
| } < <(ps -ef "$parent_pid") |
There was a problem hiding this comment.
The command ps -ef "$parent_pid" will only return information about the parent process itself on most systems, not its children. Since the subsequent loop checks for processes whose PPID matches $parent_pid, it will fail to find any child processes. This breaks the timeout mechanism which relies on identifying and killing child processes. It should be ps -ef to scan the full process list.
} < <(ps -ef)
| export BATS_RUNLOG_FILE='/dev/null' | ||
| else | ||
| # use UTC (-u) to avoid problems with TZ changes | ||
| BATS_RUNLOG_DATE=$(date -u '+%Y-%m-%d %H:%M:%S UTC') |
There was a problem hiding this comment.
The date format used for log filenames contains spaces and special characters. This can lead to issues with filename handling in scripts and is a regression from the upstream bats-core format (%Y-%m-%dT%H:%M:%S). It is safer to avoid spaces in filenames to ensure portability and prevent potential parsing errors in other shell utilities.
BATS_RUNLOG_DATE=$(date -u +%Y-%m-%dT%H:%M:%S)
| local -r value="${1}" | ||
| local -r pattern="${2}" | ||
|
|
||
| if [[ '' =~ ${pattern} ]]; (( ${?} == 2 )); then |
There was a problem hiding this comment.
There is a semicolon instead of a logical OR (||) between the regex test and the exit status check. This is inconsistent with the implementation in refute_regex.bash and appears to be a typo introduced during vendoring. Using || ensures that the error block is only entered if the regex evaluation fails with an exit status of 2 (invalid regex).
if [[ '' =~ ${pattern} ]] || (( ${?} == 2 )); then
d81ae2d to
3db4dc0
Compare
Inline bats-core, bats-assert, bats-file, and bats-support into the repo instead of pulling them in as git submodules. This removes the need for `git clone --recurse-submodules` (or `mise-tasks/init`) and drops the `submodules: recursive` checkout step from every CI workflow. - Remove `.gitmodules` and delete the submodule gitlinks; commit the vendored source directly under `test/bats` and `test/test_helper/*`. - Remove `mise-tasks/init` (only ran `git submodule update`). - Strip `submodules: recursive` / `self.submodules = true` from workflows, `flake.nix`, and `CONTRIBUTING.md`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
3db4dc0 to
124429e
Compare
### 🐛 Bug Fixes - **(git)** skip untracked scan when HK_STASH_UNTRACKED=false by [@jdx](https://github.com/jdx) in [#861](#861) - **(run)** add post-commit and pre-rebase subcommands by [@jdx](https://github.com/jdx) in [#858](#858) ### 📚 Documentation - **(install)** recommend global hooks as primary setup path by [@jdx](https://github.com/jdx) in [#855](#855) - add cross-site announcement banner by [@jdx](https://github.com/jdx) in [#857](#857) - respect banner expires field by [@jdx](https://github.com/jdx) in [#862](#862) ### 🔍 Other Changes - vendor bats test helpers instead of git submodules by [@jdx](https://github.com/jdx) in [#859](#859) ### 📦️ Dependency Updates - bump communique to 1.0.3 by [@jdx](https://github.com/jdx) in [#863](#863) - update anthropics/claude-code-action digest to e58dfa5 by [@renovate[bot]](https://github.com/renovate[bot]) in [#864](#864) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk release bookkeeping only: version numbers, generated CLI/docs, and lockfile dependency bumps with no runtime logic changes. > > **Overview** > **Release prep for `v1.44.1`.** Updates `Cargo.toml`/`Cargo.lock` (including `libc`) and all version references in generated CLI docs (`docs/cli/*`, `hk.usage.kdl`). > > Refreshes documentation examples to reference the new `v1.44.1` Pkl package URLs and adds the `1.44.1` entry to `CHANGELOG.md`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d7637d4. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: mise-en-dev <[email protected]>
Summary
--recurse-submodulesormise run init.submodules: recursivefrom every CI workflow (ci, docs, release, release-plz, autofix) and removesself.submodules = truefromflake.nix..gitmodulesandmise-tasks/init; updatesCONTRIBUTING.mdclone instructions.Test plan
mise run test:batsruns end-to-end locally🤖 Generated with Claude Code
Note
Medium Risk
Moderate risk because it replaces submodule-based test dependencies with vendored copies and updates CI/automation checkout behavior, which can break test execution or licensing/packaging expectations, but it does not change production runtime code.
Overview
Removes git submodule usage for Bats-based tests and vendors the Bats tooling and helper libraries directly into
test/, eliminating the need for--recurse-submodulesduring cloning.Updates automation to match this new layout: all GitHub Actions workflows drop
submodules: recursive,flake.nixno longer enables submodules,misebuild no longer depends on aninittask, and contributor docs are updated;.gitmodulesandmise-tasks/initare deleted accordingly.Reviewed by Cursor Bugbot for commit 124429e. Bugbot is set up for automated code reviews on this repo. Configure here.