msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Freeze Functionality

Open AlesProkop opened this issue 5 months ago • 0 comments

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 /freeze and /unfreeze slash commands in branch-freeze-command.yml (issue_comment trigger), restricted to @dotnet/kitten via an org-scoped GitHub App token used only for the members: read membership check; all repository mutations use the default GITHUB_TOKEN.
  • Added freeze-command.sh, which parses /freeze [--branch <name>] <reason> / /unfreeze [--branch <name>] (defaulting to main) and stores freeze state as an open issue labeled branch-freeze carrying the whole-line marker <!-- branch-freeze:<branch> -->, reconciling duplicate tracking issues.
  • Added the reusable branch-freeze-status.yml that posts the branch-freeze commit status, with three entry points: pull_request_target (single PR, including edited to catch retargeting onto a frozen branch), and workflow_dispatch / workflow_call (bulk re-stamp).
  • Added the branch-freeze-status composite action plus post-freeze-status.sh (single PR) and stamp-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_target injection surface: untrusted comment/PR values are passed as env/positional data (never interpolated into a run: 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_TOKEN only).
  • Added documentation/branch-freeze.md (usage + admin runbook) and linked it from documentation/README.md.

Testing

  • Validated all workflows with actionlint and all shell scripts with shellcheck.
  • 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:

  1. GitHub App (org owner) — register/identify an App installed on dotnet with Organization → Members: Read (the default GITHUB_TOKEN cannot read team membership). Add repo secrets BRANCH_FREEZE_APP_ID and BRANCH_FREEZE_APP_PRIVATE_KEY.
  2. Label (repo admin) — create the branch-freeze label: gh label create branch-freeze -c B60205 -d "Tracks a frozen branch".
  3. Merge this PR. Still inert at this point.
  4. Seed existing PRs — run branch-freeze-status via Actions → Run workflow with base_ref blank, so every open PR gets a green status before the check is required (otherwise making it required first blocks all open PRs).
  5. End-to-end test on a throwaway branch: /freeze --branch <test> testing → red branch-freeze; /unfreeze --branch <test> → green.
  6. Make it required — add branch-freeze to the required status checks of the relevant rulesets (Basic checkin policy, and Release branches if desired), pinned to the GitHub Actions app integration id to reject spoofed statuses.

Notes

  • Rollback: remove the branch-freeze context from the ruleset (enforcement stops immediately), then close any open branch-freeze issues or re-run the bulk stamp to clear residual statuses.
  • The blank-base_ref bulk seed is a manual, one-time operation and is not serialized with per-branch /freeze operations — run it when no /freeze//unfreeze is in flight.
  • The command and its reason must be on the first line of the comment; subsequent lines are ignored.

AlesProkop avatar Jun 24 '26 08:06 AlesProkop