All checks were successful
PR checks / checks (pull_request) Successful in 39s
All changes now land via PR. New .forgejo/workflows/pr-checks.yml runs on every PR to master and (1) fails code PRs that lack a test change, (2) blocks new app-code type errors. Unit tests are advisory until the baseline is green; lint is omitted (it needs an interactive ESLint migration). PR template carries the docs/tests checklist. Also makes the autofix watcher require a test (issue-12 style) + doc updates in every fix, so its PRs satisfy the new gate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
66 lines
2.7 KiB
YAML
66 lines
2.7 KiB
YAML
name: PR checks
|
|
|
|
# Enforces the contribution policy on every PR into master:
|
|
# - code changes must ship with tests (docs/config/automation are exempt)
|
|
# - no new type errors in application code
|
|
# - unit tests are reported (advisory until the baseline is green)
|
|
# Runs on the pms1 host runner. See automation/README.md > "Contribution policy".
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
checks:
|
|
runs-on: host
|
|
steps:
|
|
- name: Checkout PR
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Policy — code changes must include tests
|
|
run: |
|
|
set -uo pipefail
|
|
base="${GITHUB_BASE_REF:-master}"
|
|
git fetch origin "$base" --depth=200 -q
|
|
changed=$(git diff --name-only "origin/$base...HEAD")
|
|
printf 'Changed files:\n%s\n\n' "$changed"
|
|
|
|
# "Code" = app source (pages, API routes, lib, components, hooks).
|
|
# Tests, prisma, config, docs, automation and .forgejo are exempt.
|
|
code=$(printf '%s\n' "$changed" | grep -E '^App/(app|lib|components|hooks)/' \
|
|
| grep -vE '(\.test\.|\.spec\.|/tests/)' || true)
|
|
tests=$(printf '%s\n' "$changed" | grep -E '(\.test\.|\.spec\.|/tests/)' || true)
|
|
|
|
if [ -n "$code" ] && [ -z "$tests" ]; then
|
|
echo "::error::Code changed but no test files changed."
|
|
echo "Every code PR must add or update tests (model: the claude/issue-12 integration test)."
|
|
echo "If a test is genuinely not applicable, say why in the PR description so a reviewer can override."
|
|
printf '\nCode files without accompanying tests:\n%s\n' "$code"
|
|
exit 1
|
|
fi
|
|
echo "OK — test-presence policy satisfied."
|
|
|
|
- name: No new type errors in application code
|
|
run: |
|
|
set -uo pipefail
|
|
export NVM_DIR="$HOME/.nvm"; . "$NVM_DIR/nvm.sh"
|
|
cd App
|
|
pnpm install --frozen-lockfile
|
|
pnpm db:generate # prisma client types (no DB needed)
|
|
pnpm type-check > /tmp/tc.txt 2>&1 || true
|
|
# Gate on application-code errors only; the test suite has a known
|
|
# pre-existing type-mismatch baseline that is tracked separately.
|
|
app_errors=$(grep -E 'error TS' /tmp/tc.txt | grep -vE '/tests/|\.test\.|\.spec\.' || true)
|
|
if [ -n "$app_errors" ]; then
|
|
echo "::error::Type errors in application code:"; printf '%s\n' "$app_errors"
|
|
exit 1
|
|
fi
|
|
echo "OK — no type errors in application code."
|
|
|
|
- name: Unit tests (advisory)
|
|
continue-on-error: true
|
|
run: |
|
|
export NVM_DIR="$HOME/.nvm"; . "$NVM_DIR/nvm.sh"
|
|
cd App && pnpm test
|