Files
jobboard/deploy/test-commit.sh
T

26 lines
1.2 KiB
Bash

#!/bin/sh
# Test one commit in a throwaway worktree, with the checkout's Linux .venv.
# 1-test-and-promote.sh runs this from the checkout root. PYTHON, when set (the
# PYTHON line of release.env), names the interpreter instead of .venv/bin/python.
# The gates are this project's: roledesk has no `frontend/`, so there is no npm
# step, and ruff and mypy stay commented out as the release has run them so far.
# Usage: sh deploy/test-commit.sh <commit> (from the checkout root)
# sh deploy/test-commit.sh --here (the working tree as it is, no worktree: bin/check.sh)
set -eu
root=$(pwd)
python="${PYTHON:-$root/.venv/bin/python}"
[ -x "$python" ] || { echo "no interpreter at $python - run uv sync --all-extras, or set PYTHON in deploy/release.env" >&2; exit 1; }
target="${1:?usage: sh deploy/test-commit.sh <commit>|--here}"
if [ "$target" = "--here" ]; then
tree="$root"
else
base=$(mktemp -d /tmp/release-test-XXXXXXXX)
tree="$base/tree"
trap 'git -C "$root" worktree remove --force "$tree" 2>/dev/null; rm -rf "$base"' EXIT
git worktree add --detach "$tree" "$target" >/dev/null
fi
cd "$tree"
"$python" -m pytest -q
# "$python" -m ruff check .
# "$python" -m mypy --cache-dir "$root/.mypy_cache"