File tree Expand file tree Collapse file tree 4 files changed +78
-0
lines changed Expand file tree Collapse file tree 4 files changed +78
-0
lines changed Original file line number Diff line number Diff line change 6767 - name : Spell Check Repo
68686969
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).
7785 - rust
7886 - fuzzing
7987 - spelling
88+ - license-headers
8089 if : always()
8190 runs-on : ubuntu-latest
8291 steps :
Original file line number Diff line number Diff line change 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+ # Initialize a variable to track missing headers
12+ MISSING_HEADERS=0
13+ MISSING_FILES=" "
14+
15+ # Find all Rust files, excluding target directory
16+ while IFS= read -r file; do
17+ # Skip auto-generated files
18+ if grep -q " @generated" " $file " || grep -q " Automatically generated" " $file " ; then
19+ continue
20+ fi
21+
22+ # Check if the file has the license header (allowing for multi-line matching)
23+ if ! grep -q -z " $LICENSE_PATTERN " " $file " ; then
24+ echo " Missing or invalid license header in $file "
25+ MISSING_FILES=" $MISSING_FILES \n $file "
26+ MISSING_HEADERS=$(( MISSING_HEADERS + 1 ))
27+ fi
28+ done < <( find src -name " *.rs" -type f)
29+
30+ if [ $MISSING_HEADERS -gt 0 ]; then
31+ echo " Found $MISSING_HEADERS files with missing or invalid license headers:"
32+ echo -e " $MISSING_FILES "
33+ exit 1
34+ else
35+ echo " All Rust files have the required license header"
36+ exit 0
37+ fi
Original file line number Diff line number Diff line change 1+ /*
2+ Copyright 2024 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/// An utility macro to execute a macro for each tuple of parameters
218/// up to 32 parameters. This is useful to implement traits on functions
319/// for may parameter tuples.
Original file line number Diff line number Diff line change 1+ /*
2+ Copyright 2024 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+
117use std:: io:: Write ;
218
319use tempfile:: NamedTempFile ;
You can’t perform that action at this time.
0 commit comments