Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(contrib): check DCO with the trusted base tree [I1]

Corey Olsonbfe947aaf0f0
diff --git a/.github/workflows/dco.yml b/.github/workflows/dco.yml
index bace0d9a..da85c54e 100644
--- a/.github/workflows/dco.yml
+++ b/.github/workflows/dco.yml
@@ -16,8 +16,17 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
+ path: contribution
+ persist-credentials: false
+ # Trust the complete base tree, including the checker's relative imports.
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ github.event.pull_request.base.sha || github.event.before != '0000000000000000000000000000000000000000' && github.event.before || github.sha }}
+ path: trusted-dco
+ persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '22.13'
- name: Check every new non-merge commit
- run: node bin/check-signoffs.js
+ working-directory: contribution
+ run: node "$GITHUB_WORKSPACE/trusted-dco/bin/check-signoffs.js"
diff --git a/test/workflows.test.js b/test/workflows.test.js
index c953b261..9973501d 100644
--- a/test/workflows.test.js
+++ b/test/workflows.test.js
@@ -70,8 +70,15 @@ function contributorWorkflows() {
assert.match(dco, /\n {2}pull_request:\n/u, 'the DCO workflow runs on pull requests');
assert.match(dco, /\n dco:\n {4}name: DCO\n/u, 'the pull-request check is named DCO');
assert.match(dco, /\n {10}fetch-depth: 0\n/u, 'the checker receives the full pull-request history');
- assert.match(dco, /run: node bin\/check-signoffs\.js\n/u,
- 'the DCO workflow runs the repository sign-off checker');
+ assert.equal([...dco.matchAll(/uses: actions\/checkout@v4/gu)].length, 2,
+ 'contribution history and trusted implementation use separate checkouts');
+ assert.match(dco, /path: contribution\n {10}persist-credentials: false\n/u);
+ assert.match(dco, /ref: \$\{\{ github\.event\.pull_request\.base\.sha \|\| github\.event\.before != '0{40}' && github\.event\.before \|\| github\.sha \}\}\n {10}path: trusted-dco\n {10}persist-credentials: false\n/u,
+ 'PRs use the exact base SHA, pushes use before, and only an initial push falls back to HEAD');
+ assert.match(dco, /working-directory: contribution\n {8}run: node "\$GITHUB_WORKSPACE\/trusted-dco\/bin\/check-signoffs\.js"\n/u,
+ 'the trusted entry point checks history from the contribution working directory');
+ assert.match(dco, /permissions:\n {2}contents: read\n/u);
+ assert.doesNotMatch(dco, /pull_request_target/u, 'PR work never gains a privileged event context');
}
test('the named DCO check runs for pull requests [I1]', contributorWorkflows);