Green-lights the test suite so the PR checks can enforce it:
- Fix the NextAuth v5 auth() mock typing across all integration tests (cast to a
simple async fn so mockResolvedValue accepts the session) — clears ~86 errors.
- Fix stale test values: intent 'resubmit'->'submit' / 'save'->'draft'; ParsedImportLine
.description -> .name; approvepo -> approvePo; add missing beforeEach/beforeAll imports.
- permissions: MANAGER *can* process_payment (intentional since e1340b9) — update the
stale assertion.
- po-import-parser: skip the Sample_PO.xlsx fixture tests when the file is absent (it
lives outside the repo); synthetic-workbook tests still cover the parser.
type-check is now 0 errors and unit tests pass (167 passed, 13 skipped). pr-checks.yml
flips type-check (whole project) and unit tests to HARD gates.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
58 lines
2.3 KiB
YAML
58 lines
2.3 KiB
YAML
name: PR checks
|
|
|
|
# Enforces the contribution policy on every PR into master (all gates hard):
|
|
# - code changes must ship with tests (docs/config/automation are exempt)
|
|
# - type-check is clean across the whole project (tests included)
|
|
# - unit tests pass
|
|
# 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: Type-check (no errors)
|
|
run: |
|
|
set -e
|
|
export NVM_DIR="$HOME/.nvm"; . "$NVM_DIR/nvm.sh"
|
|
cd App
|
|
pnpm install --frozen-lockfile
|
|
pnpm db:generate # prisma client types (no DB connection needed)
|
|
pnpm type-check # whole project, tests included — must be clean
|
|
|
|
- name: Unit tests
|
|
run: |
|
|
set -e
|
|
export NVM_DIR="$HOME/.nvm"; . "$NVM_DIR/nvm.sh"
|
|
cd App && pnpm test # jsdom unit tests, no DB — must pass
|