Skip to content

Commit 6abae5c

Browse files
Copilotsimongdaviesmarossetjsturtevant
authored
Add CI job to verify all Rust files have license headers (#512)
* Add script and CI job to check license headers in Rust files Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Add license headers to files that were missing them Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Add just target for checking license headers Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Fix Label Checker test and improve license header script Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Add license headers to files in src/hyperlight_guest_capi/ Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Add license header to idtr.rs and fix imports Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Update README with DCO sign-off information Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Add documentation for DCO compliance Signed-off-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Update documentation on GPG signing and DCO requirements Signed-off-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Fix markdown linting issues in CONTRIBUTING.md and add markdownlint config Co-authored-by: marosset <18291632+marosset@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Address review feedback: update copyright year to 2025, simplify docs, use just in CI, remove markdownlint config - Remove .markdownlint.json file as it wasn't being used - Update copyright year from 2024 to 2025 in license header check script and all files with license headers - Simplify docs/commit-signing.md to remove duplication and reference GitHub's documentation - Update CONTRIBUTING.md to reference GitHub docs instead of duplicating GPG setup instructions - Update CI workflow to use `just check-license-headers` for consistency Co-authored-by: jsturtevant <648372+jsturtevant@users.noreply.github.com> * Remove commit signing docs and simplify references per review feedback - Remove docs/commit-signing.md file as requested - Update CONTRIBUTING.md to point to GitHub's documentation instead - Restore the credit comment in CONTRIBUTING.md - Remove commit signing section from README.md Signed-off-by: Copilot AI <copilot@github.com> Co-authored-by: jsturtevant <648372+jsturtevant@users.noreply.github.com> * Revert GH PR workflow to use ./dev/check-license-headers.sh Cannot use the just command since just is not available on this runner Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Update copyright year to 2025 in all remaining Rust files Complete the copyright year update that was started in commit 3ea4801 but only partially finished. This updates all remaining Rust files from "Copyright 2024" to "Copyright 2025" for consistency across the codebase. Signed-off-by: Copilot AI <copilot@example.com> Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com> * Fix PR review issues: restore original files and update workflow Co-authored-by: jsturtevant <648372+jsturtevant@users.noreply.github.com> * Update ValidatePullRequest.yml to use script directly instead of just command Co-authored-by: jsturtevant <648372+jsturtevant@users.noreply.github.com> * Revert copyright year changes for files with existing license headers Files that already had license headers should not have their copyright years modified. This commit reverts all copyright year changes from 2025 back to 2024 for files that already had license headers, while preserving the license headers that were legitimately added to files that were completely missing them. Signed-off-by: Copilot AI <copilot@example.com> Co-authored-by: jsturtevant <648372+jsturtevant@users.noreply.github.com> --------- Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> Signed-off-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: simongdavies <1397489+simongdavies@users.noreply.github.com> Co-authored-by: marosset <18291632+marosset@users.noreply.github.com> Co-authored-by: jsturtevant <648372+jsturtevant@users.noreply.github.com> Co-authored-by: Simon Davies <simongdavies@users.noreply.github.com> Co-authored-by: James Sturtevant <jsturtevant@gmail.com>
1 parent a68ff5e commit 6abae5c

File tree

18 files changed

+335
-7
lines changed

18 files changed

+335
-7
lines changed

.github/workflows/ValidatePullRequest.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ jobs:
6767
- name: Spell Check Repo
6868
uses: crate-ci/typos@v1.32.0
6969

70+
license-headers:
71+
name: check license headers
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v4
75+
- name: Check License Headers
76+
run: ./dev/check-license-headers.sh
77+
7078
# Gate PR merges on this specific "join-job" which requires all other
7179
# jobs to run first. We need this job since we cannot gate on particular jobs
7280
# in the workflow, since they can sometimes be skipped (e.g. if the PR only touches docs).
@@ -77,6 +85,7 @@ jobs:
7785
- rust
7886
- fuzzing
7987
- spelling
88+
- license-headers
8089
if: always()
8190
runs-on: ubuntu-latest
8291
steps:

CONTRIBUTING.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This project welcomes contributions. Most contributions require you to signoff o
44
the Developer Certificate of Origin (DCO). When you submit a pull request, a DCO-bot will automatically determine
55
whether you need to provide signoff for your commit. Please follow the instructions provided by DCO-bot, as pull
66
requests cannot be merged until the author(s) have provided signoff to fulfill the DCO requirement.
7-
You may find more information on the DCO requirements [below](#developer-certificate-of-origin-signing-your-work).
7+
You may find more information on the DCO requirements [below](#developer-certificate-of-origin-and-gpg-signing).
88

99
## Issues
1010

@@ -31,20 +31,28 @@ All contributions come through pull requests. To submit a proposed change, we re
3131
- Code changes require tests
3232
- Make sure to run the linters to check and format the code
3333
4. Update relevant documentation for the change
34-
5. Commit with [DCO sign-off](#developer-certificate-of-origin-signing-your-work) and open a PR
34+
5. Commit with [DCO sign-off](#developer-certificate-of-origin-and-gpg-signing) and open a PR
3535
6. Wait for the CI process to finish and make sure all checks are green
3636
7. A maintainer of the project will be assigned, and you can expect a review within a few days
3737

3838
#### Use work-in-progress PRs for early feedback
3939

4040
A good way to communicate before investing too much time is to create a "Work-in-progress" PR and share it with your reviewers. The standard way of doing this is to add a "[WIP]" prefix in your PR's title and open the pull request as a draft.
4141

42-
### Developer Certificate of Origin: Signing your work
42+
### Developer Certificate of Origin and GPG Signing
4343

4444
#### Every commit needs to be signed
4545

46+
This project requires two types of signatures on all commits:
47+
48+
1. **Developer Certificate of Origin (DCO) Sign-off**: A text attestation that you have the right to submit the code
49+
2. **GPG Signature**: A cryptographic signature verifying your identity
50+
51+
**For DCO Sign-offs:**
52+
4653
The Developer Certificate of Origin (DCO) is a lightweight way for contributors to certify that they wrote or otherwise have the right to submit the code they are contributing to the project. Here is the full text of the [DCO](https://developercertificate.org/), reformatted for readability:
47-
```
54+
55+
```text
4856
By making a contribution to this project, I certify that:
4957
5058
(a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
@@ -70,18 +78,41 @@ Git even has a `-s` command line option to append this automatically to your com
7078
git commit -s -m 'This is my commit message'
7179
```
7280

73-
Each Pull Request is checked whether or not commits in a Pull Request do contain a valid Signed-off-by line.
81+
**For GPG Signatures:**
82+
83+
GPG signatures verify the identity of the committer. For detailed setup instructions, see GitHub's documentation on [signing commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits).
84+
85+
Quick setup:
7486

75-
#### I didn't sign my commit, now what?!
87+
```sh
88+
git config --global user.signingkey YOUR_KEY_ID
89+
git config --global commit.gpgsign true
90+
```
91+
92+
**For both DCO sign-off and GPG signature in one command:**
93+
94+
```sh
95+
git commit -S -s -m 'This is my signed and signed-off commit message'
96+
```
97+
98+
For detailed instructions on setting up GPG signing, see [GitHub's documentation on signing commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits).
99+
100+
Each Pull Request is checked to ensure all commits contain valid DCO sign-offs and GPG signatures.
101+
102+
#### I didn't sign my commit, now what?
76103

77104
No worries - You can easily replay your changes, sign them and force push them!
78105

106+
**For adding both DCO sign-off and GPG signature:**
107+
79108
```sh
80109
git checkout <branch-name>
81-
git commit --amend --no-edit --signoff
110+
git commit --amend --no-edit -S -s
82111
git push --force-with-lease <remote-name> <branch-name>
83112
```
84113

114+
For more detailed instructions on setting up GPG signing, see [GitHub's documentation on signing commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits).
115+
85116
*Credit: This doc was cribbed from Dapr.*
86117

87118
### Rust Analyzer

Justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ fmt-check:
131131
cargo +nightly fmt --manifest-path src/tests/rust_guests/dummyguest/Cargo.toml -- --check
132132
cargo +nightly fmt --manifest-path src/hyperlight_guest_capi/Cargo.toml -- --check
133133

134+
check-license-headers:
135+
./dev/check-license-headers.sh
136+
134137
fmt-apply:
135138
cargo +nightly fmt --all
136139
cargo +nightly fmt --manifest-path src/tests/rust_guests/callbackguest/Cargo.toml

dev/check-license-headers.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
# This script checks for the presence of the required license header in Rust source files.
3+
4+
# Get the repository root
5+
REPO_ROOT="$(git rev-parse --show-toplevel)"
6+
cd "$REPO_ROOT" || exit 1
7+
8+
# Define the license header pattern to look for
9+
LICENSE_PATTERN="Copyright .* The Hyperlight Authors..*Licensed under the Apache License, Version 2.0"
10+
11+
# Define the full license header for files that need it
12+
LICENSE_HEADER='/*
13+
Copyright 2025 The Hyperlight Authors.
14+
15+
Licensed under the Apache License, Version 2.0 (the "License");
16+
you may not use this file except in compliance with the License.
17+
You may obtain a copy of the License at
18+
19+
http://www.apache.org/licenses/LICENSE-2.0
20+
21+
Unless required by applicable law or agreed to in writing, software
22+
distributed under the License is distributed on an "AS IS" BASIS,
23+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24+
See the License for the specific language governing permissions and
25+
limitations under the License.
26+
*/
27+
28+
'
29+
30+
# Initialize a variable to track missing headers
31+
MISSING_HEADERS=0
32+
MISSING_FILES=""
33+
34+
# Find all Rust files, excluding target directory
35+
while IFS= read -r file; do
36+
# Skip auto-generated files
37+
if grep -q "@generated" "$file" || grep -q "Automatically generated" "$file"; then
38+
continue
39+
fi
40+
41+
# Check if the file has the license header (allowing for multi-line matching)
42+
if ! grep -q -z "$LICENSE_PATTERN" "$file"; then
43+
echo "Missing or invalid license header in $file"
44+
MISSING_FILES="$MISSING_FILES\n $file"
45+
MISSING_HEADERS=$((MISSING_HEADERS + 1))
46+
fi
47+
done < <(find src -name "*.rs" -type f)
48+
49+
if [ $MISSING_HEADERS -gt 0 ]; then
50+
echo "Found $MISSING_HEADERS files with missing or invalid license headers:"
51+
echo -e "$MISSING_FILES"
52+
echo ""
53+
echo "Please add the following license header to these files:"
54+
echo "$LICENSE_HEADER"
55+
echo "You can also run: just check-license-headers to verify your changes."
56+
exit 1
57+
else
58+
echo "All Rust files have the required license header"
59+
exit 0
60+
fi

src/hyperlight_common/src/outb.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2025 The Hyperlight Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
use core::convert::TryFrom;
218

319
use anyhow::{anyhow, Error};

src/hyperlight_guest_bin/src/exceptions/idtr.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
Copyright 2025 The Hyperlight Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
use core::mem::size_of;
118
use core::ptr::addr_of;
219

320
use crate::exceptions::idt::{init_idt, IdtEntry, IDT};

src/hyperlight_guest_capi/build.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2025 The Hyperlight Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
use std::env;
218

319
fn main() {

src/hyperlight_guest_capi/src/dispatch.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2025 The Hyperlight Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
use alloc::boxed::Box;
218
use alloc::slice;
319
use alloc::vec::Vec;

src/hyperlight_guest_capi/src/error.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2025 The Hyperlight Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
use core::ffi::c_char;
218

319
use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode;

src/hyperlight_guest_capi/src/flatbuffer.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2025 The Hyperlight Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
use alloc::boxed::Box;
218
use core::ffi::{c_char, CStr};
319

0 commit comments

Comments
 (0)