#!/usr/bin/env bash # A GIT THE SERVER'S TESTS WILL RUN — on a Linux lane, where the Mac's ladder # finds none. # # bash scripts/ci/setup-test-git.sh # # Writes `COTTON_GIT` to `$GITHUB_ENV`. Run by `verify-main.yml`'s `rust` job and # `rust-deep.yml`'s `deep` job before their cargo steps — ONE copy, like # `setup-libclang.sh` and `setup-sccache.sh` beside it. # # THE SILENT SKIP THIS CLOSES. `cotton-server`'s git-backed suites — the smart # HTTP surface (`tests/git_http.rs`), the repository routes # (`tests/repos_routes.rs`), `SpawnedGit` and the `gix` reader # (`src/repos/{git,reader}_tests.rs`) and the WHOLE runner-protocol walk # (`tests/ci_service.rs`) — resolve git through `repos::git::git_candidate()`, # which is the Mac app's ladder: `/opt/homebrew/bin/git`, `/usr/local/bin/git`, # the Command Line Tools' binary, Xcode's. It deliberately does not carry # `/usr/bin/git`, because on macOS that path is the `xcode-select` shim that # raises an install dialog from a GUI app (`cotton-core/src/git.rs`). On the # Linux CI host git IS `/usr/bin/git` and nothing else, so every one of those # suites printed "SKIPPED … no real git on this machine" into captured stdout # and passed — 240-odd cases that had never once run on a PR, found on # 2026-09-22 while adding a runner-heartbeat test that stayed green with its # fix reverted. # # `git_candidate()` now reads `COTTON_GIT` first, through the same refusals a # bare server applies (`git_program()`: absolute, and never the shim by name). # That last refusal is the one rule the server has about git and it is not # relaxed for Linux, so the lane cannot say `/usr/bin/git`: it links the host's # git to a lane-owned path and names THAT. The tests then spawn exactly the git # `command -v git` answers, one symlink removed. # # Nothing is fetched and nothing is pinned — the host's git is the host's, as it # is for every other job that clones. A host with no git at all fails here by # name rather than skipping 240 tests again. set -euo pipefail GITHUB_ENV="${GITHUB_ENV:-/dev/null}" if [ "$(uname -s)" = "Darwin" ]; then # The ladder answers on a Mac; naming a git here would override the Mac's # own choice for no reason. echo "test-git: a Mac — the server's own ladder finds git, nothing to export" exit 0 fi system_git="$(command -v git || true)" if [ -z "$system_git" ]; then echo "::error::scripts/ci/setup-test-git.sh: no git on this host — the server's git-backed tests would SKIP, which is the failure this script exists to make loud." >&2 exit 1 fi bin="$HOME/.cache/cottondb/bin" mkdir -p "$bin" ln -sfn "$system_git" "$bin/git" echo "COTTON_GIT=$bin/git" >> "$GITHUB_ENV" echo "test-git: COTTON_GIT=$bin/git -> $system_git ($("$bin/git" --version)) for the server's git-backed tests"