Skip to content

Commit b6131bd

Browse files
authored
Merge pull request #29 from JPHutchins/feature/matrix-fs-isolation
PoC: isolate camas matrix cells in git worktrees (fixes pyrefly fs race)
2 parents 5e18105 + 45d4650 commit b6131bd

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

tasks.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,37 @@
2626
all = Sequential(fix, Parallel(typecheck, coverage))
2727
check = Parallel(format_check, lint, typecheck, test)
2828

29+
# Per-cell filesystem isolation. This is a rare workaround, NOT something camas
30+
# requires — the matrix / cwd / env primitives below are general; we just
31+
# compose them here to dodge one flaky type-checker.
32+
#
33+
# `check` runs five type-checkers, and the matrix fans it across six Python
34+
# versions in parallel: ~6 `uv sync`s and ~30 checkers pound ONE working tree at
35+
# once. pyrefly globs `**/*.py*` over the whole tree and intermittently reads a
36+
# file that a sibling cell's `uv sync` is mid-way through deleting under its
37+
# `.venv`, dying with "No such file or directory (os error 2)" and flaking CI.
38+
# That race is pyrefly's, not ours; the fix is simply to stop sharing the tree.
39+
#
40+
# So each cell runs in a throwaway `git worktree` — a sibling dir holding only
41+
# tracked files, with its own `.venv` — and no two cells ever touch the same
42+
# path. `rm -rf` then `add --force` is idempotent and safe to run concurrently
43+
# across cells (no `git worktree prune`, which would race a sibling mid-rebuild).
44+
# Worktrees check out HEAD, so commit locally before running the matrix if you
45+
# want it to cover your working changes.
46+
#
47+
# The dir name has no leading dot on purpose: pyrefly skips hidden directories,
48+
# so a `.`-prefixed worktree silently matches zero files and "passes" vacuously.
49+
_worktree = "../camas-matrix/{PY}"
50+
2951
matrix = Sequential(
30-
Task("uv sync"),
31-
check,
32-
env={"UV_PROJECT_ENVIRONMENT": ".venv-{PY}", "UV_PYTHON": "{PY}"},
52+
Task(f"rm -rf {_worktree}"),
53+
Task(f"git worktree add --force --detach {_worktree} HEAD"),
54+
Sequential(
55+
Task("uv sync"),
56+
check,
57+
cwd=_worktree,
58+
env={"UV_PYTHON": "{PY}"},
59+
),
3360
matrix={
3461
"PY": tuple(
3562
stripped

0 commit comments

Comments
 (0)