Skip to content

check:affected: a changed test file must run the test-file size ratchet #3787

Open

Description

@thymikee

Purpose

pnpm check:affected --run passed on #3732 at 63c6a66, but CI Coverage failed scripts/__tests__/test-file-size-ratchet.test.ts: packages/platform-apple/src/lifecycle.test.ts grew from 970 to 1,006 lines, past the 1,000-line tripwire. The local gate selects tests through Vitest's module graph (vitest related). The ratchet doesn't import the files it measures; it walks the tree and reads line counts. So no change to a test file ever selects it, and the failure reaches CI one review round late.

Required behavior

  • When a change adds or modifies a file the ratchet measures (*.test.ts, *.test.tsx or *.test.mjs under src/, packages/, test/ or scripts/, excluding node_modules, dist, dist-types and .tmp), the affected plan selects the ratchet test, with a reason that names the triggering file.
  • Express it as a selection rule in scripts/check-affected/model.ts, the same way other text-read gates are declared there. Don't special-case it in run.ts.
  • Keep a single definition of which files the ratchet measures. The selection rule and the ratchet test must read the same pattern and roots, so they can't drift. Put the shared definition where both can import it.
  • A change that touches no test file doesn't select the ratchet.

Completion

  • A model.test.ts case: a changed test file selects the ratchet check and gives the triggering reason, and a non-test change doesn't. It fails before the change and passes after.
  • Planting a 1,001-line new test file in a scratch checkout makes pnpm check:affected --run fail locally on the ratchet.
  • pnpm check:affected --run --head <sha> passes on the final commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions