From 30c57fbc4e0c24088beded0a9f6953819d23828a Mon Sep 17 00:00:00 2001 From: 31b4 Date: Wed, 28 Oct 2026 12:33:31 +0100 Subject: [PATCH] Require complete CI on main and document merge enforcement --- .github/rulesets/main-ci.json | 27 +++++++++++++++++++++++++++ AGENTS.md | 2 +- tests/README.md | 23 ++++++++++++++++++++++- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .github/rulesets/main-ci.json diff --git a/.github/rulesets/main-ci.json b/.github/rulesets/main-ci.json new file mode 100644 index 00000000..289fc9b9 --- /dev/null +++ b/.github/rulesets/main-ci.json @@ -0,0 +1,27 @@ +{ + "name": "Require complete CI on main", + "target": "branch", + "enforcement": "active", + "bypass_actors": [], + "conditions": { + "ref_name": { + "include": ["refs/heads/main"], + "exclude": [] + } + }, + "rules": [ + { + "type": "required_status_checks", + "parameters": { + "required_status_checks": [ + { + "context": "CI passed", + "integration_id": 15368 + } + ], + "strict_required_status_checks_policy": true, + "do_not_enforce_on_create": false + } + } + ] +} diff --git a/AGENTS.md b/AGENTS.md index 43d4cb41..52661b88 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -98,7 +98,7 @@ npm test -w api -- src/tests/upcoming-transactions.test.ts - Root `npm run build` builds only the client. Plain `tsc --noEmit` against the client's root tsconfig does not check its referenced projects; use the build above or `(cd client && npx tsc -b)`. - API unit tests live in `api/src/tests/`; client tests are colocated and in `client/src/test/` (Vitest, jsdom, Testing Library); MCP tests are colocated in `mcp/src/`. Cross-workspace tests live in `tests/integration/` and run compiled Workers against disposable shared D1 with signed test JWTs. Keep their runtime flags/dates aligned with the tracked Wrangler examples. See `tests/README.md` for test boundaries and fixtures. -- `.github/workflows/ci.yml` runs workflow validation, all workspace suites, a second client suite on Node 26, deployment tests, API/MCP types, client build/lint, and integration tests. `CI passed` fails if any prerequisite fails, is cancelled, or is skipped. Unit/report artifacts do not require production credentials. +- `.github/workflows/ci.yml` runs workflow validation, all workspace suites, a second client suite on Node 26, deployment tests, API/MCP types, client build/lint, and integration tests. `CI passed` fails if any prerequisite fails, is cancelled, or is skipped. Unit/report artifacts do not require production credentials. The active main-branch ruleset in `.github/rulesets/main-ci.json` requires `CI passed` from GitHub Actions with no bypass actors, including administrators, and strict up-to-date checks. Wait for the complete aggregate result before merging; include new required CI jobs in its `needs` list. GitHub stores rulesets separately, so editing the policy file alone does not update live enforcement. - Client lint has a clean baseline under its enabled rules; several legacy typing/React rules remain disabled in `client/eslint.config.js`. Do not introduce additional rule exclusions to pass CI. Generated `dist/` and `dev-dist/` are ignored. - For financial behavior changes, test balance deltas, posted/pending/cancelled transitions, locks on affected accounts, linked transfers, repeated confirmation, currency conversion, and MCP projection isolation as applicable. Use existing regression suites as starting points. - For UI changes, check desktop/mobile layouts, privacy modes, themes, empty/loading/error states, and failed saves. For SQL changes, also validate against a disposable local database; unit mocks are insufficient. diff --git a/tests/README.md b/tests/README.md index e371d9e4..00500c00 100644 --- a/tests/README.md +++ b/tests/README.md @@ -30,7 +30,28 @@ npm run test:integration -- -t 'rolls back' The workflow runs on pull requests and pushes to `main` and `epic/**`, merge queues, and manual dispatch. It cancels superseded runs, uses timeouts and read-only repository permissions, pins Actions to commits, and uploads JUnit reports for seven days. Failed integration tests print the harness's Worker logs. Reports use synthetic fixtures only. -Require **CI passed** in GitHub branch protection or a ruleset to make these checks block merging. Adding the workflow does not itself change repository protection settings. The original four check names are retained for existing rules. +### Merge enforcement + +The main-branch ruleset **Require complete CI on main** requires **CI passed** from GitHub Actions (application ID `15368`). It has no bypass actors, so administrators also wait for CI. Strict checks require the PR branch to include the latest `main`; update an out-of-date branch and wait for the new run. Failed, cancelled, skipped or unfinished prerequisites cannot produce a successful aggregate result. Adding a CI job also requires adding it to the aggregate job’s `needs` list. + +The source policy is [`.github/rulesets/main-ci.json`](../.github/rulesets/main-ci.json). GitHub stores the effective rules separately from Git: editing that file alone does not apply a settings change. Audit the live rules with: + +```bash +gh api repos/apptrackit/finance/rules/branches/main +gh api repos/apptrackit/finance/rulesets +# Inspect the matching ID to verify enforcement, branch scope, and bypass_actors: +gh api repos/apptrackit/finance/rulesets/RULESET_ID +``` + +This CI-only ruleset is separate from the existing review/force-push/deletion protection. In particular, making CI mandatory for administrators does not change the existing administrator review exemption. The original check names are retained for compatibility. + +A green individual job is insufficient. PR #188’s Node 26 client job failed before the PR merged, but the repository previously required no status checks. That incident was a missing merge gate, rather than a missing test. + +### CI and local deployment boundaries + +Run deployment with the Node 22 runtime pinned in `.node-version`, the same runtime used for primary CI and real Worker/D1 integration. CI additionally exercises the client suite on Node 26; it does not establish support for running the full Worker toolchain on every newer runtime. Use `npm ci` after switching runtimes or updating the lockfile so the installation matches CI. + +Deployment still reruns the selected workspace tests, typechecks, Worker bundles and client build before remote mutations. These overlap the required CI checks; local uncommitted changes, a different runtime, local configuration or a different dependency installation can still change the result. CI’s synthetic configurations and disposable D1 database cannot prove production credentials, Cloudflare availability, quotas, custom domains or remote migration state. Those remain deployment checks; a successful CI run is not permission to bypass them. ## Integration design