Skip to content

Update containers against worktrees#1075

Draft
zancas wants to merge 6 commits into
devfrom
update_containers_against_worktrees
Draft

Update containers against worktrees#1075
zancas wants to merge 6 commits into
devfrom
update_containers_against_worktrees

Conversation

@zancas

@zancas zancas commented Apr 28, 2026

Copy link
Copy Markdown
Member

This eliminates unnecessary builds in worktrees that don't contain standard .git sub-directories.

@zancas zancas requested a review from nachog00 April 28, 2026 18:56
zancas added 5 commits April 30, 2026 09:23
… vars

  container-test bind-mounts the host workspace into /home/container_user/zaino.
  In a git worktree, the workspace's .git is a file containing
  `gitdir: <host-only-path>`, which the container cannot resolve. So
  `git rev-parse HEAD` from inside the build script returns empty, and
  the binary's GIT_COMMIT / BRANCH metadata silently becomes "" on every
  container build.

  Capture both values on the host before `podman run` (with `unknown`
  fallback for repos detached from a checkout) and forward them via
  `-e GIT_COMMIT=…` / `-e BRANCH=…`. Update zaino-state/build.rs to
  prefer the env values and shell out to git only as a fallback for
  direct host invocations of `cargo build`. Add corresponding
  `cargo:rerun-if-env-changed=` directives so cargo invalidates the
  crate only when these values actually change.

  This addresses the in-container half of the spurious-recompile cascade.
  The host-worktree half (`cargo:rerun-if-changed=../../.git/HEAD`
  resolving to a non-existent path because `.git` is a file in worktrees)
  is handled in the follow-up commit.

  Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…recompile

  `cargo:rerun-if-changed=../../.git/HEAD` is correct for a regular
  clone but wrong for a git worktree, where `.git` is a file (the
  gitdir-pointer) rather than a directory. The hardcoded path resolves
  to a non-existent location, which cargo treats as always-changed,
  forcing zaino-state (and everything that depends on it — zaino-serve,
  zainod) to recompile on every cargo invocation.

  Replace the static path with a `git_path("HEAD")` helper that calls
  `git rev-parse --git-path HEAD`. Returns:
    - `.git/HEAD` for a regular clone,
    - `<main>/.git/worktrees/<name>/HEAD` for a worktree,
    - None when git can't resolve the repo (e.g. bind-mounted workspace
      inside a container with no access to the host gitdir) — in which
      case the directive is skipped and the cargo:rerun-if-env-changed=
      directives added in the previous commit handle invalidation.

  After this commit, `cargo nextest run` on an unmodified worktree
  completes with no `Compiling` lines, matching the regular-clone
  behavior.

  Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
  Replace `portpicker::pick_unused_port()` (random sampling in 15000..25000,
  ~10k-port range) with `zcash_local_net::network::pick_unused_port`, which
  delegates to the kernel for an ephemeral port. The portpicker range
  suffered birthday-paradox collisions under parallel test load, surfacing
  as `ConnectionRefused` flakes on `zebrad::get::*` and
  `zebra::lightwallet_indexer::*`.

  To pick up the helper, switch `zingo_test_vectors` and `zcash_local_net`
  from git deps to path deps against a sibling `../../../infras/dev`
  checkout, and have `Makefile.toml` conditionally bind-mount that
  checkout into the test container when it exists on the host.

  Drop the now-unused `portpicker` from the workspace and from
  `zaino-testutils`, and retype `make_uri` to take a plain `u16`.

  Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

  If you'd rather a terse one-liner in the repo's build(scope): ... style:

  test(integration): switch to local infras checkout + kernel-assigned ports

  Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zancas zancas force-pushed the update_containers_against_worktrees branch from 7ceade6 to fbffdc8 Compare April 30, 2026 16:34
@zancas zancas marked this pull request as draft April 30, 2026 16:35
@zancas

zancas commented Apr 30, 2026

Copy link
Copy Markdown
Member Author

This is blocked on publication of infrastructure.

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