Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ When choosing between approaches, prioritize:

- **Vendoring**: Go deps are vendored. `make build`/`make test` pass `-mod=vendor` via `GOFLAGS`; `go get` is still fine but follow with `go mod vendor`.
- **License headers**: every source file needs an Apache-2.0 header. `make license-fmt` (which runs as part of `make fmt`) shells out to [`addlicense`](https://github.com/google/addlicense) with `scripts/license-header.tmpl` — don't copy-paste headers by hand. It only **adds** headers to files that lack one; it never rewrites an existing header, so the copyright year is the year of first publication and is not bumped on edit (matching Google/Kubernetes practice). Files carrying a generated-code marker (`// Code generated … DO NOT EDIT.`) are skipped, which is a content check, not a filename check: a hand-written `zz_generated.*` would still get a header, and a generated file without the marker would too. `make license-header-check` is the CI gate; it fails if a tracked source file has no header, or has one that isn't `SPDX-License-Identifier: Apache-2.0`. New Go files get `//` line comments rather than the `/* */` block used by older files: a block comment above a `//go:build` constraint is not legal, so gofmt hoists the constraint and the two tools fight forever.
- **Commits**: Conventional Commits format, with DCO sign-off (`git commit -s`). No pseudonyms.
- **Commits**: Conventional Commits format. Every commit must be both signed off and cryptographically signed: `git commit -s -S`. `-s` adds the DCO `Signed-off-by` trailer, `-S` attaches the GPG/SSH signature that `main`'s `required_signatures` ruleset and the Commit Requirements workflow check for. They are independent, so neither flag substitutes for the other, and both are needed on amends too (`git commit --amend -s -S --no-edit`). Signing needs an unsandboxed shell. No pseudonyms.
- **Docs are part of every PR.** If your change alters user-visible behavior (CRD field, CLI command/flag, env var, annotation, metric, lifecycle semantics, install/upgrade flow) or an architectural concept captured in `docs/`, update the affected doc page **in the same PR** — not a follow-up. If a doc page is wrong or stale because of your change, fix it. If your change makes an existing doc obsolete, delete the stale section rather than leaving two sources of truth. **A behavior-changing PR without a corresponding `docs/` update will be rejected in review** — treat this as a blocking requirement, not a nicety. Docs-only changes are fine on their own, but code changes without docs are not.
- **`RELEASE_NOTES.md` is not a changelog, and most PRs do not belong in it.** Each component's `CHANGELOG.md` is generated from commit history and already records every change, so a hand-written note is duplication unless the reader has to **do** something or will be **surprised**: an action required at upgrade time, a deprecation with a deadline, a behavior they will notice and did not ask for, a new knob worth discovering. A bug fix that restores intended behavior needs no entry, however involved the fix was. Default to not adding one; the commit message and the linked issue carry the reasoning. Every entry that is only narrative makes the entries that matter harder to find.
- **Container runtime**: the operator Makefile defaults to `podman` locally, `docker` in CI. Override via `DOCKER_CMD=docker`.
Expand Down
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Checklist

- [ ] I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/skyhook/blob/main/CONTRIBUTING.md).
- [ ] My commits are signed off (`git commit -s`) per the [DCO](https://developercertificate.org/).
- [ ] I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/nodewright/blob/main/CONTRIBUTING.md).
- [ ] My commits are signed off per the [DCO](https://developercertificate.org/) **and** cryptographically signed: `git commit -s -S`.
- [ ] New or existing tests cover these changes.
- [ ] The documentation is up to date with these changes.
13 changes: 9 additions & 4 deletions .github/dco.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Configuration for the DCO bot (https://github.com/probot/dco), which enforces
# the Developer Certificate of Origin sign-off documented in CONTRIBUTING.md.
# Configuration for the DCO bot (https://github.com/probot/dco), kept in case the
# app is installed on this repository. It is currently not reporting any checks,
# so the sign-off requirement documented in CONTRIBUTING.md is enforced by
# .github/workflows/commit-requirements.yaml instead, which also checks the
# cryptographic signature the app does not look at.

# Require all commits to be signed off, except organization members and bots.
# Require every commit to be signed off, organization members included. Setting
# this to false exempts members, which is where most of the missing sign-offs on
# this repository have come from.
require:
members: false
members: true
241 changes: 241 additions & 0 deletions .github/workflows/commit-requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: Commit Requirements

# Every commit must carry a DCO sign-off (`git commit -s`) and a verified
# cryptographic signature (`git commit -S`), both documented in CONTRIBUTING.md.
# Neither was actually checked before this workflow: `.github/dco.yml` only
# configures the probot DCO app, which is not reporting on this repository, and
# the `required_signatures` rule on `main` is satisfied by the signature GitHub
# puts on the squash/merge commit it creates, not by the contributor's commits.
#
# This job reports; it does not gate. It deliberately publishes no `ci-gate`
# check, so a red run here is visible without wedging the merge button. Promote
# it by adding a `ci-gate` job (see commit-linting.yaml) once the open-PR
# backlog is clean.
#
# pull_request_target is required to comment on pull requests from forks, which
# is where the violations come from. It is safe here for the usual reason: the
# job never checks out or executes the contributor's code, it only reads commit
# metadata through the API.

on:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
commit-requirements:
name: Sign-off and signature
runs-on: ubuntu-latest
permissions:
pull-requests: write
timeout-minutes: 5
steps:
- name: Check commits and report
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const MARKER = '<!-- commit-requirements -->';
const CONTRIBUTING = `https://github.com/${context.repo.owner}/${context.repo.repo}/blob/main/CONTRIBUTING.md#developer-certificate-of-origin-and-commit-signing`;
const { owner, repo } = context.repo;
const number = context.payload.pull_request.number;

const commits = await github.paginate(github.rest.pulls.listCommits, {
owner, repo, pull_number: number, per_page: 100,
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// This endpoint tops out at 250 commits. Reporting success on a
// truncated list would clear a pull request nobody fully checked, so
// say so and fail instead.
const expectedCommits = context.payload.pull_request.commits;
const truncated =
typeof expectedCommits === 'number' && commits.length < expectedCommits;

// Bots cannot run `git commit -s -S`; Renovate and Dependabot commits
// are signed by GitHub's own key and carry no sign-off by design.
//
// Keyed on the GitHub identity the API resolved, never on `commit.author`.
// The latter is git metadata the committer sets freely, so matching a
// `[bot]` name or noreply address there would let anyone skip both checks
// with a one-line `git config`. Dependabot and the github-actions app that
// runs Renovate here both resolve to `author.type === 'Bot'`.
const isBot = (c) => c.author?.type === 'Bot';

// Only the trailer block counts, matching `git interpret-trailers`:
// the last paragraph, and never a single-paragraph message. Scanning
// every line would accept a `Signed-off-by:` quoted in prose while git
// itself sees no trailer at all.
//
// Presence only, deliberately not matched against the commit author's
// email. GitHub hands out `NNN+user@users.noreply.github.com` aliases,
// so a contributor who signs off with their real address trips an
// author/trailer mismatch through no fault of their own. Flagging that
// is noise, and a check people learn to ignore enforces nothing.
const hasSignOff = (message) => {
const paragraphs = (message ?? '')
.replace(/\r/g, '')
.split(/\n[ \t]*\n/)
.filter((p) => p.trim().length > 0);
if (paragraphs.length < 2) return false;
// Anchored at column 0 and the paragraph is not trimmed: git does not
// treat an indented line as a trailer, so neither may this.
return paragraphs[paragraphs.length - 1]
.split('\n')
.some((line) => /^Signed-off-by:\s*.+<.+>\s*$/i.test(line));
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.

const checked = commits.filter((c) => !isBot(c));

const violations = [];
for (const c of checked) {

const problems = [];

if (!hasSignOff(c.commit.message)) {
problems.push('no `Signed-off-by` trailer (`git commit -s`)');
}

if (c.commit.verification?.verified !== true) {
const reason = c.commit.verification?.reason ?? 'unknown';
problems.push(`signature not verified: \`${reason}\` (\`git commit -S\`)`);
}

if (problems.length > 0) {
violations.push({ sha: c.sha, subject: c.commit.message.split('\n')[0], problems });
}
}

// Match the author as well as the marker. MARKER is an HTML comment, so
// anyone can paste it into a comment of their own; keying on the body
// alone would make a later run edit that comment instead of this
// workflow's, and the job holds `pull-requests: write`.
const existing = (
await github.paginate(github.rest.issues.listComments, {
owner, repo, issue_number: number, per_page: 100,
})
).find(
(comment) =>
comment.user?.login === 'github-actions[bot]' && comment.body?.includes(MARKER),
);

const upsert = async (body) => {
if (existing) {
await github.rest.issues.updateComment({
owner, repo, comment_id: existing.id, body: `${MARKER}\n${body}`,
});
} else {
await github.rest.issues.createComment({
owner, repo, issue_number: number, body: `${MARKER}\n${body}`,
});
}
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if (truncated) {
const body = [
'### ⚠️ Could not check every commit',
'',
`GitHub returned ${commits.length} of this pull request's ${expectedCommits} commits, so the sign-off and signature check is incomplete and is not reporting a pass.`,
'',
'The pull request commits endpoint returns at most 250 commits. Splitting this into smaller pull requests, or rebasing to reduce the commit count, lets the check cover everything.',
'',
`The requirements themselves are unchanged and are described in [CONTRIBUTING.md](${CONTRIBUTING}).`,
].join('\n');
await upsert(body);
core.setFailed(
`Commit list truncated: got ${commits.length} of ${expectedCommits} commits.`,
);
return;
}

if (violations.length === 0) {
core.info(`All ${checked.length} non-bot commit(s) are signed off and signed.`);
if (existing) {
await upsert('✅ Every non-bot commit on this pull request is now signed off and signed. Thanks!');
}
return;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

// The head ref is attacker-chosen and lands in bash blocks a maintainer
// is invited to copy-paste. `git check-ref-format` permits `;`, `$(...)`,
// backticks, `&&` and `|` in a branch name, so this must be quoted.
const shellQuote = (v) => "'" + String(v).replace(/'/g, "'\\''") + "'";
const headRef = shellQuote(context.payload.pull_request.head.ref);

const rows = violations
.map((v) => `| \`${v.sha.slice(0, 8)}\` | ${v.subject} | ${v.problems.join('<br>')} |`)
.join('\n');

await upsert([
'### ❌ Some commits are missing a sign-off or a signature',
'',
'Every commit in this repository must be **signed off** (`-s`, the [DCO](https://developercertificate.org/) certification that you wrote the patch) **and cryptographically signed** (`-S`, proving the commit came from you). They are independent; you need both, on every commit.',
'',
'| Commit | Subject | Problem |',
'| --- | --- | --- |',
rows,
'',
'<details>',
'<summary>How to fix</summary>',
'',
'One-time setup, so you only ever need `-s` from here on:',
'',
'```bash',
'# Commit identity, used in the Signed-off-by trailer.',
'# Use an address GitHub has verified on your account.',
'git config user.name "Your Name"',
'git config user.email "your.email@example.com"',
'',
'# Signing key, separate from the identity above. For SSH:',
'git config gpg.format ssh',
'git config user.signingkey ~/.ssh/id_ed25519.pub',
'',
'# Sign every commit from now on',
'git config commit.gpgsign true',
'```',
'',
'The key must also be registered with GitHub: see [generating a GPG or SSH signing key](https://docs.github.com/en/authentication/managing-commit-signature-verification).',
'',
'To fix the most recent commit:',
'',
'```bash',
'git commit --amend -s -S --no-edit',
'git push --force-with-lease origin ' + headRef,
'```',
'',
'To fix every commit on the branch at once. Check for merge commits first, because a plain rebase drops them:',
'',
'```bash',
'git log --oneline --merges origin/main..HEAD # empty output means linear',
'',
'# Linear branch:',
"git rebase --exec 'git commit --amend -s -S --no-edit' origin/main",
'',
'# Branch with merge commits, preserving them:',
"git rebase --rebase-merges --exec 'git commit --amend -s -S --no-edit' origin/main",
'```',
'',
'Confirm the rewrite changed nothing but the signatures before pushing:',
'',
'```bash',
'git range-diff @{u}...HEAD',
'git push --force-with-lease origin ' + headRef,
'```',
'',
'Re-signing rewrites every commit, which outdates inline review comments. If the PR is already under review, leave a note saying you force-pushed.',
'',
'</details>',
'',
`Full details are in [CONTRIBUTING.md](${CONTRIBUTING}). This check reports but does not block your merge; a maintainer will still ask you to fix it.`,
].join('\n'));

core.setFailed(
`${violations.length} of ${checked.length} non-bot commit(s) are missing a sign-off or a verified signature.`,
);
2 changes: 1 addition & 1 deletion .github/workflows/welcome.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
`Welcome to NodeWright, @${creator}! Thanks for your first pull request.`,
'',
'Before review, please ensure:',
`- All commits are signed off per the [DCO](https://github.com/${context.repo.owner}/${context.repo.repo}/blob/main/CONTRIBUTING.md) (\`git commit -s\`)`,
`- All commits are signed off **and** signed: \`git commit -s -S\` (see [CONTRIBUTING.md](https://github.com/${context.repo.owner}/${context.repo.repo}/blob/main/CONTRIBUTING.md#developer-certificate-of-origin-and-commit-signing))`,
'- Commits follow [Conventional Commits](https://www.conventionalcommits.org/)',
'- CI checks pass (tests, lint, security scan)',
'- The PR description explains the *why* behind your changes',
Expand Down
Loading