Skip to content

Commit 7774f6b

Browse files
committed
Add license checks to CI
1 parent 1d95ceb commit 7774f6b

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/license.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
LICENSE_HEADER="\
2+
// Copyright (C) 2025 Category Labs, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>."
16+
17+
# Check for two newlines after the license header
18+
LICENSE_HEADER_LEN=$(("${#LICENSE_HEADER}" + 2))
19+
20+
exit_code=0
21+
22+
for file in $(git ls-files -- '*.rs' '*.h' '*.hpp' '*.c' '*.cpp'); do
23+
contents=$(head -c $LICENSE_HEADER_LEN "$file")
24+
25+
if [ "$contents" == "$LICENSE_HEADER" ]; then
26+
continue
27+
fi
28+
29+
exit_code=$((exit_code + 1))
30+
31+
echo "$file" >&2
32+
done
33+
34+
exit $exit_code
35+

.github/workflows/license.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: License
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
workflow_call:
10+
11+
jobs:
12+
check-license:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
- name: Check licenses
19+
run: .github/workflows/license.sh
20+

0 commit comments

Comments
 (0)