#!/usr/bin/env bash
# .github/ci/ gate — the-hcma/repository-helpers convention; run by pre-pr-checks
# and ci.yml (see CONTRIBUTING.md "Governance tooling from repository-helpers").
set -euo pipefail
# Temp files and caches follow $TMPDIR/<project>/<branch>/<tool> (repository-helpers#832).
# CI exports REPOSITORY_HELPERS_DIR through the setup-tmp-layout action; without a clone, run unchanged.
layout_bin="${REPOSITORY_HELPERS_DIR:-$HOME/work/ai/repository-helpers}/scripts/dev/with-tmp-layout"
if [[ -z "${CI_TMP_LAYOUT:-}" ]]; then
  if [[ -x "$layout_bin" ]]; then
    CI_TMP_LAYOUT=1 exec "$layout_bin" uv -- "$layout_bin" pytest -- bash "$0" "$@"
  elif [[ "${GITHUB_ACTIONS:-}" == true ]]; then
    echo 'ERROR: with-tmp-layout missing; add the setup-tmp-layout action step before this one' >&2
    exit 1
  fi
fi
bash .github/ci/setup-python
# CI: mocked / offline only. Live Graph tests run on operator machines
# (BLUMKIN_LIVE=1; see .cursor/rules/local-live-graph-tests.mdc).
# -n auto: pytest-xdist across available cores (#497). Single-process debug:
#   PYTEST_ADDOPTS='-p no:xdist'  or  uv run pytest -m 'not live' -n 0
uv run pytest -m 'not live' -n auto -q
