Skip to content

feat(pr-checks): frozen-files fails a pull request that changes a file frozen on the base branch - #63

Draft
PiquelChips wants to merge 1 commit into
feat/pr-check-lint-exceptionsfrom
feat/pr-check-frozen-files
Draft

PiquelChips wants to merge 1 commit into
feat/pr-check-lint-exceptionsfrom
feat/pr-check-frozen-files

Conversation

@PiquelChips

Copy link
Copy Markdown
Member

What and why

An applied migration must never change: piqueld and sourceorigin both say so in prose, and an edited migration breaks every database that already ran it. A repository check can't enforce this. On main it would compare HEAD with itself, and a shallow checkout lacks the merge base. A pull request has exactly the comparison needed, so this adds frozen-files (PQ2) to the pull request checks of #21.

  • What it checks: a file matching a glob of the new frozen-files input, such as crates/*/migrations/*.sql, that exists on the base branch must not be modified, have its mode changed, be renamed or be deleted.
    • Adding a file there is fine: that's how a new migration lands.
    • A rename is matched on its old path.
    • The changed files and their statuses come from pulls.listFiles.
    • Globs read as picomatch reads them, dotfiles included: **, *, ?, {a,b} and […]/[!…].
  • A deliberate change passes the same gate as lint-exceptions: an approver's approval of the latest commit, or the approved-exception label. That logic moves from lint-exceptions to PullRequest.approval, so both checks share it.
  • Fix: the finding says to put the change in a new file, such as a new migration, or to ask for the approval.
  • A repository with no frozen-files input passes.
  • The crate's README lists the check and the input, and its example caller passes frozen-files: crates/*/migrations/*.sql.

Testing

  • 5 new Node tests (52 in all):

    • modify, delete and rename each fail, a rename at its old path;
    • added files, other files, and a rename into the frozen directory pass;
    • no input means no check;
    • glob cases;
    • the approval and label waiver.

    The existing lint-exceptions approval tests now cover the shared PullRequest.approval.

  • just check-changed feat/pr-check-lint-exceptions passes.

  • Dogfood: this pull request's own PR run. This repository freezes nothing, so the check passes trivially there.

Checklist

  • The crate's README (its documentation on docs.rs) shows the change, and a repository's xtask can still follow it.
  • A change to the public API is noted for the next release, with what each repository's xtask must change. (No API change. piqueld and sourceorigin pass frozen-files with their migration globs.)
  • just check-changed passes.

Note

Written by Claude Opus 5.5 in Claude Code (via T3 Code)

…e frozen on the base branch

frozen-files (PQ2) matches the changed files against the globs of the new
frozen-files input, such as applied migrations: modifying, renaming or
deleting one needs the owner's approval or the approved-exception label,
as a lint exception does. The approval moves to PullRequest, which both
checks share.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant