msbuild
msbuild copied to clipboard
Freeze Functionality
Part of dotnet/msbuild#13589
Context
Replaces the informal "please hold checkins" Teams message with an enforceable branch merge-freeze: the on-duty committer (@dotnet/kitten) can freeze a branch with /freeze <reason> so no new PRs merge until /unfreeze. Enforcement is a required branch-freeze commit status that fails on every PR targeting a frozen branch. Nothing is enforced until an admin opts in (see rollout below), so merging this PR is safe and inert on its own.
Changes Made
- Added
/freezeand/unfreezeslash commands inbranch-freeze-command.yml(issue_commenttrigger), restricted to@dotnet/kittenvia an org-scoped GitHub App token used only for themembers: readmembership check; all repository mutations use the defaultGITHUB_TOKEN. - Added
freeze-command.sh, which parses/freeze [--branch <name>] <reason>//unfreeze [--branch <name>](defaulting tomain) and stores freeze state as an open issue labeledbranch-freezecarrying the whole-line marker<!-- branch-freeze:<branch> -->, reconciling duplicate tracking issues. - Added the reusable
branch-freeze-status.ymlthat posts thebranch-freezecommit status, with three entry points:pull_request_target(single PR, includingeditedto catch retargeting onto a frozen branch), andworkflow_dispatch/workflow_call(bulk re-stamp). - Added the
branch-freeze-statuscomposite action pluspost-freeze-status.sh(single PR) andstamp-open-prs.sh(bulk fan-out, up to 1000 PRs/branch). - Serialized all status writers for a branch under a
branch-freeze-write-<branch>concurrency group so a freeze fan-out can never be overwritten by a concurrent stale per-PR stamp. - Hardened against the
issue_comment/pull_request_targetinjection surface: untrusted comment/PR values are passed as env/positional data (never interpolated into arun:line), PR HEAD is never checked out, the branch name is allow-listed, and the App key is not forwarded to the reusable workflow (GITHUB_TOKENonly). - Added
documentation/branch-freeze.md(usage + admin runbook) and linked it fromdocumentation/README.md.
Testing
- Validated all workflows with
actionlintand all shell scripts withshellcheck. - No automated unit tests added — these are CI workflow/bash scripts; correctness is validated via the end-to-end rollout procedure below. No MSBuild engine code changed, so the product test suite was not run.
Required before this does anything (admin rollout — in order)
Merging the workflows enforces nothing. To turn the feature on, an admin must:
- GitHub App (org owner) — register/identify an App installed on
dotnetwith Organization → Members: Read (the defaultGITHUB_TOKENcannot read team membership). Add repo secretsBRANCH_FREEZE_APP_IDandBRANCH_FREEZE_APP_PRIVATE_KEY. - Label (repo admin) — create the
branch-freezelabel:gh label create branch-freeze -c B60205 -d "Tracks a frozen branch". - Merge this PR. Still inert at this point.
- Seed existing PRs — run
branch-freeze-statusvia Actions → Run workflow withbase_refblank, so every open PR gets a green status before the check is required (otherwise making it required first blocks all open PRs). - End-to-end test on a throwaway branch:
/freeze --branch <test> testing→ redbranch-freeze;/unfreeze --branch <test>→ green. - Make it required — add
branch-freezeto the required status checks of the relevant rulesets (Basic checkin policy, andRelease branchesif desired), pinned to the GitHub Actions app integration id to reject spoofed statuses.
Notes
- Rollback: remove the
branch-freezecontext from the ruleset (enforcement stops immediately), then close any openbranch-freezeissues or re-run the bulk stamp to clear residual statuses. - The blank-
base_refbulk seed is a manual, one-time operation and is not serialized with per-branch/freezeoperations — run it when no/freeze//unfreezeis in flight. - The command and its reason must be on the first line of the comment; subsequent lines are ignored.