Repository navigation
feat(spdx-check): fail when a file loses a copyright notice - #4
Merged
SDAChess merged 1 commit intoDec 2, 2026
Merged
Conversation
Projects that stop requiring copyright lines in new files still need to keep the notices existing files carry, but nothing caught a pull request that deleted one. A new base input names a revision, usually the pull request's base. The check then also fails, with an annotation per notice, when a checked file's header (or its .license sidecar) has lost an SPDX-FileCopyrightText notice it had at that revision. Notices may change comment style. Deleted files are not tracked. Signed-off-by: Kris Hicks <khicks@nvidia.com>
5 tasks done
SDAChess
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
baseinput tospdx-check. When it is set, the check also fails if a checked file's header has lost anSPDX-FileCopyrightTextnotice that it had atbase.OpenShell is moving its License Headers check to this action as part of the CNCF donation: new files carry only the SPDX license identifier, and existing copyright notices must stay. CNCF's copyright notice guidance says "you should not change or remove someone else's copyright notice unless they have expressly permitted you to do so." Today nothing catches a PR that deletes one.
Changes
spdx-check/copyright.mjsreads the notices in the first 10 lines of each checked file (or its.licensesidecar) atbasewith onegit grep, and compares them with the current header. Notices may change comment style (#,//,/* */,<!-- -->).basefails with an annotation saying to fetch it.base, behavior is unchanged.fetch-depth: 0requirement.Testing
node --test "spdx-check/test/*.test.mjs": 53 pass, including 10 new tests for kept, removed, restyled, sidecar, deleted, excluded and below-line-10 notices, an unknown base, and the summary.npx prettier@3.10.1 --check .Not handled: a file renamed and stripped of its notice in the same PR, since the old path no longer exists.