Skip to content

Commit df287d6

Browse files
Copilotsimongdavies
andcommitted
Fix Label Checker test and improve license header script
Co-authored-by: simongdavies <[email protected]>
1 parent 7f87a55 commit df287d6

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

.github/workflows/PRLabelChecker.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- name: Ensure exactly one "kind/*" label is applied
1616
run: |
17-
# Count the number of "kind/*" labels directly from the PR labels
18-
PR_NUMBER=${{ github.event.pull_request.number }}
19-
KIND_LABEL_COUNT=$(gh pr view "$PR_NUMBER" --json labels -q '.labels.[].name' | grep -c '^kind/')
17+
# Count the number of "kind/*" labels using GitHub API via github.event
18+
LABELS=$(echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -r '.[].name')
19+
KIND_LABEL_COUNT=$(echo "$LABELS" | grep -c "^kind/" || true)
2020
2121
if [[ "$KIND_LABEL_COUNT" -eq 1 ]]; then
2222
echo "✅ Exactly one 'kind/*' label is applied."
@@ -25,5 +25,3 @@ jobs:
2525
echo "❌ PR must have exactly one 'kind/*' label, but found $KIND_LABEL_COUNT."
2626
exit 1
2727
fi
28-
env:
29-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

dev/check-license-headers.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ cd "$REPO_ROOT" || exit 1
88
# Define the license header pattern to look for
99
LICENSE_PATTERN="Copyright .* The Hyperlight Authors..*Licensed under the Apache License, Version 2.0"
1010

11+
# Define the full license header for files that need it
12+
LICENSE_HEADER='/*
13+
Copyright 2024 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+
1130
# Initialize a variable to track missing headers
1231
MISSING_HEADERS=0
1332
MISSING_FILES=""
@@ -30,6 +49,10 @@ done < <(find src -name "*.rs" -type f)
3049
if [ $MISSING_HEADERS -gt 0 ]; then
3150
echo "Found $MISSING_HEADERS files with missing or invalid license headers:"
3251
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."
3356
exit 1
3457
else
3558
echo "All Rust files have the required license header"

0 commit comments

Comments
 (0)