Skip to content

chore: add NVIDIA SPDX license header pre-commit hook - #422

Merged
rapids-bot[bot] merged 5 commits into
rapidsai:mainfrom
cmatzenbach:pre-commit-license-headers
Jul 28, 2026
Merged

chore: add NVIDIA SPDX license header pre-commit hook#422
rapids-bot[bot] merged 5 commits into
rapidsai:mainfrom
cmatzenbach:pre-commit-license-headers

Conversation

@cmatzenbach

Copy link
Copy Markdown
Contributor

Description

Adds a .pre-commit-config.yaml that uses the rapidsai/pre-commit-hooks verify-copyright hook to automatically insert and maintain NVIDIA SPDX license headers on commit.

Related Issues

Closes #224

Testing

pre-commit run verify-copyright --all-files reports no changes

@cmatzenbach cmatzenbach added improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: 189b8b78-f1f2-47a4-9e5b-fa80a7d05658

📥 Commits

Reviewing files that changed from the base of the PR and between 9f6c363 and 83a6872.

⛔ Files ignored due to path filters (1)
  • pixi.lock is excluded by !**/*.lock, !pixi.lock
📒 Files selected for processing (3)
  • .github/workflows/license-check.yml
  • .pre-commit-config.yaml
  • pixi.toml

📝 Walkthrough

Walkthrough

Adds pre-commit configuration and dependency support for NVIDIA Apache-2.0 SPDX headers, then updates the license-check workflow to run verify-copyright across all files.

Changes

Copyright checks

Layer / File(s) Summary
Configure SPDX header checks
.pre-commit-config.yaml, pixi.toml
Adds the verify-copyright hook with SPDX and fix options, exclusions, extension-based file matching, and the pre-commit dependency.
Run SPDX checks in CI
.github/workflows/license-check.yml
Sets up pixi and replaces the shell-based scan with verify-copyright --all-files.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: dhruv9vats, mbrobbel

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding an NVIDIA SPDX license header pre-commit hook.
Description check ✅ Passed The description includes purpose, related issue, and testing, which fits the template well.
Linked Issues check ✅ Passed The PR replaces the custom license checker with the standardized rapidsai pre-commit hook as requested in #224.
Out of Scope Changes check ✅ Passed The changes stay focused on license-header enforcement and the supporting CI/dependency updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.pre-commit-config.yaml (1)

19-28: 🔒 Security & Privacy | 🔵 Trivial

Run this check in CI as well as developer-local pre-commit.

This configuration only enables a local hook; if the custom checker is being removed, ensure CI runs pre-commit run verify-copyright --all-files. Otherwise contributors can bypass the check by not installing or skipping pre-commit. (pre-commit.com)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.pre-commit-config.yaml around lines 19 - 28, Ensure CI also runs the
verify-copyright hook across all files, using the repository’s existing
pre-commit configuration, while preserving the developer-local hook setup in
.pre-commit-config.yaml.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.pre-commit-config.yaml:
- Around line 29-31: Update the files pattern used by verify-copyright to
preserve coverage for all tracked repository file types, including *.cpp, *.h,
CMakeLists.txt, and pyproject.toml; preferably remove the override to inherit
upstream coverage, or extend it with those types.

---

Nitpick comments:
In @.pre-commit-config.yaml:
- Around line 19-28: Ensure CI also runs the verify-copyright hook across all
files, using the repository’s existing pre-commit configuration, while
preserving the developer-local hook setup in .pre-commit-config.yaml.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: ba3dd184-821e-411b-ae32-7d25ade1f78c

📥 Commits

Reviewing files that changed from the base of the PR and between 9cf2204 and 9009784.

📒 Files selected for processing (1)
  • .pre-commit-config.yaml

Comment thread .pre-commit-config.yaml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

🟠 Other critical/major comments (1)
.pre-commit-config.yaml-34-37 (1)

34-37: ⚠️ Potential issue | 🟠 Major

The files override still skips tracked pyproject.toml.

Because pyproject.toml matches none of these alternatives, verify-copyright --all-files will not check it. Remove the override to inherit upstream coverage, or add pyproject\.toml$ and any other required tracked file types.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.pre-commit-config.yaml around lines 34 - 37, Update the pre-commit files
filter to include pyproject.toml, or remove the override so upstream coverage
applies; ensure verify-copyright --all-files checks this tracked file and other
required file types.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Other critical/major comments:
In @.pre-commit-config.yaml:
- Around line 34-37: Update the pre-commit files filter to include
pyproject.toml, or remove the override so upstream coverage applies; ensure
verify-copyright --all-files checks this tracked file and other required file
types.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: 92adfd37-e0d0-44f8-8735-a96172b4e264

📥 Commits

Reviewing files that changed from the base of the PR and between 9009784 and e823fbb.

📒 Files selected for processing (1)
  • .pre-commit-config.yaml

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.pre-commit-config.yaml (1)

34-38: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Restore coverage for all tracked file types.

pre-commit run ... --all-files still applies this files regex, so omitted extensions are never checked. The pattern appears to miss types such as .hpp, .cc, .cxx, .hh, .cu, .cuh, .cmake, CMakeLists_standalone.txt, .pyx, .pxd, pyproject.toml, meta.yaml, and setup.cfg. Remove the override if the hook defaults cover them, or extend it to match the repository’s complete tracked-file set.

#!/usr/bin/env bash
set -euo pipefail

git ls-files | grep -E \
  '(\.(cc|cxx|hh|hpp|cu|cuh|cmake|pyx|pxd)$|(^|/)(CMakeLists_standalone\.txt|meta\.yaml|pyproject\.toml|setup\.cfg)$)'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.pre-commit-config.yaml around lines 34 - 38, Update the files regex in the
pre-commit configuration so all tracked source and configuration types are
covered during --all-files runs. Prefer removing the custom files override if
the hook defaults provide complete coverage; otherwise extend the pattern to
include .hpp, .cc, .cxx, .hh, .cu, .cuh, .cmake, .pyx, .pxd,
CMakeLists_standalone.txt, meta.yaml, pyproject.toml, and setup.cfg while
preserving existing matches.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In @.pre-commit-config.yaml:
- Around line 34-38: Update the files regex in the pre-commit configuration so
all tracked source and configuration types are covered during --all-files runs.
Prefer removing the custom files override if the hook defaults provide complete
coverage; otherwise extend the pattern to include .hpp, .cc, .cxx, .hh, .cu,
.cuh, .cmake, .pyx, .pxd, CMakeLists_standalone.txt, meta.yaml, pyproject.toml,
and setup.cfg while preserving existing matches.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: 4dc4a55b-ddd4-45b5-8815-b1a78f58c51a

📥 Commits

Reviewing files that changed from the base of the PR and between e823fbb and 9f6c363.

📒 Files selected for processing (2)
  • .github/workflows/license-check.yml
  • .pre-commit-config.yaml

@johanpel johanpel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related: #404

Comment thread .github/workflows/license-check.yml Outdated
Comment on lines +19 to +25
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.x"
- name: Check SPDX license headers
run: |
# ts-bindings are auto-generated by ts-rs from Rust structs
missing=()
while IFS= read -r file; do
if ! grep -q "SPDX-License-Identifier" "$file"; then
missing+=("$file")
fi
done < <(git ls-files -- '*.ts' '*.tsx' '*.rs' '*.proto' '*.css' \
':!examples/simulator/server/ts-bindings/')

if [[ ${#missing[@]} -gt 0 ]]; then
echo "The following files are missing an SPDX license header:"
printf ' %s\n' "${missing[@]}"
echo ""
echo "Add the following header to the top of each file:"
echo " // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved."
echo " // SPDX-License-Identifier: Apache-2.0"
exit 1
fi

echo "All $(git ls-files -- '*.ts' '*.tsx' '*.rs' '*.proto' '*.css' \
':!examples/simulator/server/ts-bindings/' | wc -l | tr -d ' ') files have SPDX license headers."
pip install pre-commit
pre-commit run verify-copyright --all-files

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the rest of the checks, let's use Pixi.
This lets us pin pre-commit through its lock file for maximum reproducibility.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use pixi instead of pip

fi

echo "All $(git ls-files -- '*.ts' '*.tsx' '*.rs' '*.proto' '*.css' | wc -l | tr -d ' ') files have SPDX license headers."
run: pixi run pre-commit run verify-copyright --all-files

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complains about a misplaced comma in some files, otherwise looking great --> 2026, NVIDIA vs 2026 NVIDIA

-// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
All rights reserved.
+// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES.
All rights reserved.

@johallar johallar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running the pre-commit command auto fixes the header typos, then all good!

@cmatzenbach

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 7d76d79 into rapidsai:main Jul 28, 2026
20 checks passed
@cmatzenbach
cmatzenbach deleted the pre-commit-license-headers branch July 28, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: use precommit hook for license checks

3 participants