Skip to content

feat(spdx-check): fail when a file loses a copyright notice - #4

Merged
SDAChess merged 1 commit into
ai-openshell:mainfrom
krishicks:feat/spdx-check-base/krishicks
Dec 2, 2026
Merged

SDAChess merged 1 commit into
ai-openshell:mainfrom
krishicks:feat/spdx-check-base/krishicks

Conversation

@krishicks

Copy link
Copy Markdown
Contributor

Summary

Adds an optional base input to spdx-check. When it is set, the check also fails if a checked file's header has lost an SPDX-FileCopyrightText notice that it had at base.

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.mjs reads the notices in the first 10 lines of each checked file (or its .license sidecar) at base with one git grep, and compares them with the current header. Notices may change comment style (#, //, /* */, <!-- -->).
  • Each removed notice gets an error annotation on line 1 and a line in the job summary. An unreadable base fails with an annotation saying to fetch it.
  • Without base, behavior is unchanged.
  • The dogfood job passes the PR base, and the README documents the input and its fetch-depth: 0 requirement.

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 .
  • Ran against ai-openshell/openshell with its current include and exclude lists: 1757 files, the same set its Python check uses, in under a second. Deleting one copyright line was reported and exited 1.

Not handled: a file renamed and stripped of its notice in the same PR, since the old path no longer exists.

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>
@SDAChess
SDAChess merged commit 8f4d5a0 into ai-openshell:main Dec 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants