Skip to content

Commit a33aea0

Browse files
authored
Merge pull request #2619 from modelcontextprotocol/v2/chore/2616-dco-on-v2-main
ci: run the DCO check on every v2 PR now, before push, and after merge (#2616)
2 parents de88759 + 8448039 commit a33aea0

8 files changed

Lines changed: 315 additions & 58 deletions

File tree

‎.claude/skills/pr-flow/SKILL.md‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,38 @@ previous one, not all cut from `v2/main`.
9595

9696
**The `DCO` check fails the PR on any unsigned commit.** It is this repo's own
9797
job (`.github/workflows/dco.yml` → `scripts/dco-check.mjs`, #2566), run on every
98-
PR targeting `v2/main`, and it requires each commit to carry a `Signed-off-by: Name <email>`
98+
v2 PR, stacked PRs included, and it requires each commit to carry a `Signed-off-by: Name <email>`
9999
trailer whose name **and** email match either the commit's author or its
100-
committer (case-insensitively). Its only exemptions are merge commits and
100+
committer (case-insensitively). One relaxation: a commit GitHub itself
101+
committed (`GitHub <noreply@github.com>`, as on a squash merge, whose author
102+
name GitHub takes from the profile) passes on an author **email** match alone.
103+
Its only exemptions are merge commits and
101104
bot-authored commits; there is no partial credit — one unsigned commit out of six
102105
fails the whole check, and the job's output names each offending commit and the
103106
repair below.
104107

105108
⚠️ **It is a merge gate only because it is a _required_ status check** — a
106109
ruleset setting, not something the workflow file can declare. The job runs on
107-
`pull_request_target`, so its workflow is read from `main`: it reports on PRs
108-
only once a milestone merge has carried it there (#2566). The probot DCO app
110+
`pull_request`, from the PR's own ref, so it reports on every v2 PR — stacked
111+
ones included, any `v2/**` base — with no wait for a
112+
milestone merge (#2616). A second job, `DCO (v2/main push)`,
113+
re-runs the check over every push that lands on `v2/main` — a backstop for
114+
anything that merged without a passing PR check — so a red there means an
115+
unsigned commit is already on the branch. The probot DCO app
109116
it replaced was never required, so when the app was suspended its check simply
110117
stopped appearing (after #1981) and nothing went red for two months. If the
111118
`DCO` check is ever missing from a PR, treat that as the outage it is.
112119

113-
**Check before you push** — the same script runs locally against the range the
114-
PR will show:
120+
**Check before you push.** `npm run local:gate` already does it: its
121+
`local:dco` stage runs the same script over `origin/v2/main..HEAD` (minus
122+
anything already on `origin/main`), right after
123+
`local:validate`. On a **stacked** branch that range covers the whole stack,
124+
parents included, which is stricter than the child PR's own check (that one
125+
runs against the parent's branch). To check on its own, against the range the
126+
PR will show, pass the PR's actual base:
115127

116128
```sh
117-
npm run dco:check -- --base origin/v2/main
129+
npm run dco:check -- --base origin/v2/main # or origin/<parent branch> when stacked
118130
```
119131

120132
**Prevent it with `git commit -s`.** Two things that look like automation and are
@@ -136,6 +148,12 @@ git rebase --rebase-merges --signoff origin/v2/main # the base the PR targets
136148
git push --force-with-lease
137149
```
138150

151+
⚠️ **On a stacked branch, rebase against the parent branch, never
152+
`origin/v2/main`.** A `--signoff` rebase onto `origin/v2/main` rewrites every
153+
parent commit too, which forks the child from its parent and breaks the stack.
154+
If the unsigned commit is in the parent, repair the parent's own branch first,
155+
then rebase the child onto the repaired parent.
156+
139157
`--rebase-merges` keeps any merge commit on the branch — without it the rebase
140158
flattens them, silently dropping a conflict resolution that lives only in the
141159
merge. Use `--force-with-lease` rather than `--force`, and only rewrite when you are the

‎.claude/skills/pre-push-gate/SKILL.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,23 @@ stale install otherwise passes every check and fails later as a behavioral test
9898
reporting the *old* dependency's behavior as a product bug (#2494). Don't
9999
"fix" that test.
100100

101+
### `local:dco`
102+
103+
A commit in `origin/v2/main..HEAD` (minus anything already on `origin/main`)
104+
has no `Signed-off-by:` trailer matching its
105+
author or committer (#2616). The output names each commit and prints the
106+
repair. Repair and prevention (`git commit -s`, the `--signoff` rebase) are
107+
step 3 of `/pr-flow`.
108+
109+
If it lists commits you never made, check which case you are in:
110+
111+
- **A stacked branch** (cut from another feature branch): `origin/v2/main..HEAD`
112+
covers the whole stack, parent commits included. Fetching changes nothing.
113+
An unsigned parent commit is repaired on the parent's own branch first, and
114+
the child is then rebased onto the repaired parent (`/pr-flow` step 3).
115+
- **Not stacked**: your `origin/v2/main` is probably behind what the branch was
116+
cut from. `git fetch origin v2/main` and re-run.
117+
101118
### `verify:action-pins`
102119

103120
A job that holds a credential (`id-token`/`packages: write`, a non-default

‎.github/workflows/dco.yml‎

Lines changed: 100 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,74 @@
33
# The app was suspended and its check silently stopped appearing after #1981
44
# (2026-08-12). Nothing went red, because it was never a required check — so
55
# for two months "the DCO check is a hard merge gate" was true only by habit.
6-
# This job is the repo-owned replacement: `scripts/dco-check.mjs` fails the PR
7-
# unless every commit in it carries a `Signed-off-by:` matching its author or
8-
# committer (merge and bot-authored commits exempt — the app's rule).
6+
# This workflow is the repo-owned replacement: `scripts/dco-check.mjs` fails
7+
# unless every commit in a range carries a `Signed-off-by:` matching its
8+
# author or committer (merge and bot-authored commits exempt — the app's rule).
99
#
10-
# ⚠️ A job only GATES when its check is required. Making `DCO` a required
11-
# status check is a ruleset change in repo settings (one covering `v2/main`
12-
# does not exist yet), not something a workflow file can do — without it, this
13-
# job going missing would pass as silently as the app did.
10+
# Two jobs, one script:
1411
#
15-
# Its own workflow because it needs the PR's base, which `main.yml` (push
16-
# only) never sees.
12+
# - `DCO` — on every v2 PR, over the PR's commits. This is the
13+
# one to make a REQUIRED status check (a ruleset change in repo settings,
14+
# not something this file can do — without it, the job going missing
15+
# passes as silently as the app did).
16+
# - `DCO (v2/main push)` — a backstop over every push that lands on
17+
# `v2/main`, for whatever reached the branch without a passing PR check
18+
# while this file and the script stayed intact: an admin merge, a direct
19+
# push, a merge made while the PR check was red or missing. NOT a PR that
20+
# edited the check itself (below).
21+
# It reports when the commit lands, not one milestone later — it cannot
22+
# un-merge anything, but an unsigned commit found the same day is still
23+
# cheap to deal with.
1724
#
18-
# ⚠️ `pull_request_target`, deliberately — a check that gates a PR must not run
19-
# code the PR can change. Under `pull_request` both this file and the script
20-
# come from the PR's merge ref, so a PR could rewrite either to pass itself.
21-
# `pull_request_target` takes the workflow from the repo's DEFAULT branch
22-
# (`main`), and the job checks out the PR's base (`v2/main`) for the script —
23-
# both already-merged code. The PR's commits are only FETCHED: `git log` reads
24-
# their metadata and nothing from the PR is ever executed, which is the
25-
# condition that makes `pull_request_target` safe. Keep it that way: never
26-
# check out, install, build or run the PR head in this job.
25+
# ⚠️ `pull_request`, not `pull_request_target` (#2616). #2603 shipped on
26+
# `pull_request_target` so a PR could not rewrite its own check to pass — but
27+
# GitHub reads `pull_request_target` workflows from the DEFAULT branch
28+
# (`main`), so the check reported on no v2 PR at all until a milestone merge
29+
# carried this file there, and unsigned commits would have surfaced only when
30+
# the milestone PR into `main` was opened. Under `pull_request` the workflow
31+
# runs from the PR's own ref and works the moment it is on `v2/main`, and an
32+
# edit to this file takes effect on the PR that makes it.
2733
#
28-
# ⚠️ Rollout follows from the workflow living on `main`: this file does
29-
# nothing until a milestone merge carries it from `v2/main` to `main`, and a
30-
# later edit to it takes effect only on the next milestone merge. An edit to
31-
# `scripts/dco-check.mjs` takes effect as soon as it merges to `v2/main`. Make
32-
# `DCO` a required check only once this file is on `main` — required before
33-
# then, every v2 PR would wait on a check that never reports.
34+
# The trade-off, accepted deliberately: a PR can now edit this file to pass
35+
# itself. That is tolerable here because PRs are opened by maintainers only
36+
# (AGENTS.md, Contributing) and the check exists to catch a FORGOTTEN signoff,
37+
# not a forged one — the trailer is self-asserted text either way (see the
38+
# header of `scripts/dco-check.mjs`). ⚠️ The push job does NOT cover that
39+
# case: a `push` run also reads this file, and runs the script, from the
40+
# pushed revision — so a PR that edits the check edits the backstop with it.
41+
# Nothing in a workflow the repo's own branches carry can close that; only a
42+
# check read from elsewhere could, which is what `pull_request_target` was and
43+
# what this change gives up. The control for it is review: an edit to this
44+
# file or to `scripts/dco-check.mjs` is in the PR's diff. The PR job keeps the
45+
# trigger safe anyway: it checks out the PR's BASE for the script and only
46+
# FETCHES the PR's commits, reading their metadata with `git log` — nothing
47+
# from the PR is checked out, installed, built or run.
3448
#
35-
# Scoped to `v2/main`. Once on `main` an unscoped trigger would also fire for
36-
# `v1/main` PRs (whose checkout has no script) and for milestone PRs into
37-
# `main` (whose range holds GitHub's squash-merge commits, signed under a
38-
# different name). `edited` re-runs it when a PR is retargeted, since the
39-
# checked range changes with the base even when the head does not.
49+
# The PR job runs on every `v2/**` base — `v2/main` and, since branch names
50+
# carry their version segment, every v2 feature branch — so a stacked PR is
51+
# checked on its own range rather than only once its parent merges (the
52+
# servers repo's #5055 checks stacks too). A positive filter rather than a
53+
# list of exclusions, so the scope is the v2 line by construction: `main`
54+
# (milestone PRs carry GitHub's squash-merge commits and reach back before the
55+
# check existed) and the whole v1 line, `v1/main` and its stacks alike (no copy
56+
# of the script), are out of it without being named. A stacked PR's base must
57+
# be a branch cut after #2603, since the script is read from it. `edited` re-runs the PR job when a PR is retargeted,
58+
# since the checked range changes with the base even when the head does not.
59+
#
60+
# Before either job, `npm run local:gate` runs the same script over
61+
# `origin/v2/main..HEAD`, minus anything already on `origin/main` so it holds
62+
# on a milestone-merge branch too (`local:dco`), so an unsigned commit is normally
63+
# caught before it is pushed at all.
4064
#
4165
# Only `contents: read`, no credential persisted, no secret — so it stays on
4266
# moving action tags (#2235; see verify:action-pins, #2484).
4367
name: DCO
4468

4569
on:
46-
pull_request_target:
70+
pull_request:
4771
types: [opened, synchronize, reopened, edited]
72+
branches: ['v2/**']
73+
push:
4874
branches: [v2/main]
4975

5076
permissions:
@@ -53,14 +79,21 @@ permissions:
5379
jobs:
5480
dco:
5581
name: DCO
82+
if: github.event_name == 'pull_request'
5683
runs-on: ubuntu-latest
84+
# A newer push to the same PR supersedes the range being checked. Job-level
85+
# and PR-keyed on purpose: the push job below must NOT share it, since a
86+
# cancelled push run is a range that is never checked.
87+
concurrency:
88+
group: dco-pr-${{ github.event.pull_request.number }}
89+
cancel-in-progress: true
5790
# A git fetch, a git log and a node script; expected to finish well inside
5891
# a minute. Not yet observed on a runner — revisit with the measured range
5992
# per the rule in main.yml (#2333) once it has a history.
6093
timeout-minutes: 5
6194

6295
steps:
63-
- name: Checkout the base branch (trusted) with full history
96+
- name: Checkout the base branch with full history
6497
uses: actions/checkout@v7
6598
with:
6699
ref: ${{ github.base_ref }}
@@ -87,3 +120,39 @@ jobs:
87120
BASE_REF: ${{ github.base_ref }}
88121
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
89122
run: node scripts/dco-check.mjs --base "origin/$BASE_REF" --head "$HEAD_SHA"
123+
124+
dco-push:
125+
name: DCO (v2/main push)
126+
if: github.event_name == 'push'
127+
runs-on: ubuntu-latest
128+
# Same work as the PR job; same unmeasured budget.
129+
timeout-minutes: 5
130+
131+
steps:
132+
- name: Checkout the pushed commit with full history
133+
uses: actions/checkout@v7
134+
with:
135+
fetch-depth: 0
136+
persist-credentials: false
137+
138+
- name: Setup Node.js
139+
uses: actions/setup-node@v7
140+
with:
141+
node-version: '22.x'
142+
143+
- name: Check every pushed commit is signed off
144+
# `before..after` is exactly what the push added: for a PR merge, the
145+
# merge commit (exempt) plus every commit it brought in. A zero
146+
# `before` means the branch was just created, which leaves no range to
147+
# check. A `before` missing from the history (a force-push that
148+
# rewrote it away) makes `git log` fail and the script exit 2 — loud
149+
# on purpose, since `v2/main` is never meant to be rewritten.
150+
env:
151+
BEFORE: ${{ github.event.before }}
152+
AFTER: ${{ github.event.after }}
153+
run: |
154+
if [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
155+
echo "Branch creation push: no prior commit, nothing to check."
156+
exit 0
157+
fi
158+
node scripts/dco-check.mjs --base "$BEFORE" --head "$AFTER"

0 commit comments

Comments
 (0)