-
Notifications
You must be signed in to change notification settings - Fork 138
Add CI job to verify all Rust files have license headers #512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
03cc1e9
Add script and CI job to check license headers in Rust files
Copilot 6bc0bb7
Add license headers to files that were missing them
Copilot 6e6760a
Add just target for checking license headers
Copilot c80eb8c
Fix Label Checker test and improve license header script
Copilot e7e7ab3
Add license headers to files in src/hyperlight_guest_capi/
Copilot 78dfcbc
Add license header to idtr.rs and fix imports
Copilot 36260d1
Update README with DCO sign-off information
Copilot b8fb4af
Add documentation for DCO compliance
Copilot d51042f
Update documentation on GPG signing and DCO requirements
Copilot 33d19fc
Fix markdown linting issues in CONTRIBUTING.md and add markdownlint c…
Copilot 3ea4801
Address review feedback: update copyright year to 2025, simplify docs…
Copilot bea43ab
Remove commit signing docs and simplify references per review feedback
Copilot e9609f8
Revert GH PR workflow to use ./dev/check-license-headers.sh
simongdavies 2baf424
Update copyright year to 2025 in all remaining Rust files
Copilot c6b3669
Fix PR review issues: restore original files and update workflow
Copilot 32bfa78
Update ValidatePullRequest.yml to use script directly instead of just…
Copilot 998bece
Revert copyright year changes for files with existing license headers
Copilot bbaf29e
Merge branch 'main' into copilot/fix-502
jsturtevant 5b2389d
Merge remote-tracking branch 'upstream/main' into copilot/fix-502
jsturtevant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,14 @@ jobs: | |
- name: Spell Check Repo | ||
uses: crate-ci/[email protected] | ||
|
||
license-headers: | ||
name: check license headers | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check License Headers | ||
run: ./dev/check-license-headers.sh | ||
|
||
# Gate PR merges on this specific "join-job" which requires all other | ||
# jobs to run first. We need this job since we cannot gate on particular jobs | ||
# in the workflow, since they can sometimes be skipped (e.g. if the PR only touches docs). | ||
|
@@ -77,6 +85,7 @@ jobs: | |
- rust | ||
- fuzzing | ||
- spelling | ||
- license-headers | ||
if: always() | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
# This script checks for the presence of the required license header in Rust source files. | ||
|
||
# Get the repository root | ||
REPO_ROOT="$(git rev-parse --show-toplevel)" | ||
cd "$REPO_ROOT" || exit 1 | ||
|
||
# Define the license header pattern to look for | ||
LICENSE_PATTERN="Copyright .* The Hyperlight Authors..*Licensed under the Apache License, Version 2.0" | ||
|
||
# Define the full license header for files that need it | ||
LICENSE_HEADER='/* | ||
Copyright 2025 The Hyperlight Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
' | ||
|
||
# Initialize a variable to track missing headers | ||
MISSING_HEADERS=0 | ||
MISSING_FILES="" | ||
|
||
# Find all Rust files, excluding target directory | ||
while IFS= read -r file; do | ||
# Skip auto-generated files | ||
if grep -q "@generated" "$file" || grep -q "Automatically generated" "$file"; then | ||
continue | ||
fi | ||
|
||
# Check if the file has the license header (allowing for multi-line matching) | ||
if ! grep -q -z "$LICENSE_PATTERN" "$file"; then | ||
echo "Missing or invalid license header in $file" | ||
MISSING_FILES="$MISSING_FILES\n $file" | ||
MISSING_HEADERS=$((MISSING_HEADERS + 1)) | ||
fi | ||
done < <(find src -name "*.rs" -type f) | ||
|
||
if [ $MISSING_HEADERS -gt 0 ]; then | ||
echo "Found $MISSING_HEADERS files with missing or invalid license headers:" | ||
echo -e "$MISSING_FILES" | ||
echo "" | ||
echo "Please add the following license header to these files:" | ||
echo "$LICENSE_HEADER" | ||
echo "You can also run: just check-license-headers to verify your changes." | ||
exit 1 | ||
else | ||
echo "All Rust files have the required license header" | ||
exit 0 | ||
fi |
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.