Skip to content

Require a change record on the first hop - #63

Merged
dijaropacity merged 3 commits into
devfrom
dijar/change-record-guard
Oct 27, 2026
Merged

dijaropacity merged 3 commits into
devfrom
dijar/change-record-guard

Conversation

@dijaropacity

@dijaropacity dijaropacity commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Linear: DEVOPS-162

Summary

  • Pull requests into the first branch must name a real Linear issue, use nolinear/<reason> with a description, or come from Dependabot.
  • The issue key is checked against the Linear API. LINEAR_API_KEY has to be available to this repository or the check fails closed. The GitHub Linear app does not provide that lookup.
  • staging into main records a staging test when the repository variable REQUIRE_STAGING_TEST is true. Editing the description re-runs the check.

This does not change the org ruleset. guard stays the only required check until this file is on the default branch of every release-pipeline repo. After that, refs/heads/dev and the staging-test check can be added to Branch Flow Guard Status Check.

This revision

The check is now .github/scripts/branch_flow_guard.py, checked out from the default branch and run by the workflow in two modes, with .github/scripts/test_branch_flow_guard.py (15 offline cases, python3 -m unittest discover -s .github/scripts) and .github/PULL_REQUEST_TEMPLATE/to-main.md for the staging record (?template=to-main.md on a staging into main pull request). Reviewed on sdk#901: Linear matches the branch name first with the issue key as fallback, back-merges need no ticket, dev/staging/main are trusted only from this repository, Dependabot is recognised by author, transient API errors are retried, and the staging record is tied to the head SHA.

Test plan

  • A pull request into the first branch from a real Linear branch passes guard
  • A branch named with a fake key such as ENG-999999-fake fails guard
  • nolinear/reason with an empty description fails, and adding a description passes on the next run
  • A promotion from the previous branch still passes guard
  • Where REQUIRE_STAGING_TEST is true, staging into main fails staging-test until the attestation block is filled in

A pull request into the first branch has to name a real Linear issue, use nolinear/ with a description, or come from Dependabot. Image repos also record the staging test on the way to main.
A dependabot/ branch only skips the Linear check when Dependabot opened the pull request. Staging fields need real text, and the checkbox accepts a Windows line ending.
DEVOPS-162

The workflow now checks out .github/scripts/branch_flow_guard.py from the
default branch and runs it in two modes. The script reads the pull request
live from the GitHub API (base, head, head SHA, author, description) and:

- lets Linear match the branch name first (issueVcsBranchSearch), then falls
  back to the issue key, and fails closed only when both fail
- treats back-merges (main into dev, main into staging, staging into dev) as
  needing no ticket
- accepts dev, staging, and main only from this repository, not from forks
- recognises Dependabot by the pull request author, not the branch name
- retries transient Linear and GitHub errors, and fails on auth errors
- parses the staging record (Staging URL, Exercised, Result, Tested commit,
  ticked box) in the common Markdown forms and ties it to the head SHA

.github/PULL_REQUEST_TEMPLATE/to-main.md holds the staging record fields, used
with ?template=to-main.md on a staging -> main pull request.
.github/scripts/test_branch_flow_guard.py has the 15 offline cases; run with
python3 -m unittest discover -s .github/scripts
@dijaropacity
dijaropacity merged commit b5632c9 into dev Oct 27, 2026
@dijaropacity
dijaropacity deleted the dijar/change-record-guard branch October 27, 2026 12:06
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