mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Adds license check in CI
This commit is contained in:
parent
a9941d4231
commit
d913837a5d
3
.github/workflows/validate-header-guards.yml
vendored
3
.github/workflows/validate-header-guards.yml
vendored
@ -34,3 +34,6 @@ jobs:
|
|||||||
- name: checknames
|
- name: checknames
|
||||||
run: |
|
run: |
|
||||||
python tools/scripts/checkDuplicateFilenames.py
|
python tools/scripts/checkDuplicateFilenames.py
|
||||||
|
- name: checklicense
|
||||||
|
run: |
|
||||||
|
python tools/scripts/checkLicense.py
|
||||||
|
32
tools/scripts/checkLicense.py
Normal file
32
tools/scripts/checkLicense.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def get_license():
|
||||||
|
with open("src/catch2/catch_all.hpp", "r") as f:
|
||||||
|
license = f.readlines()[0:7]
|
||||||
|
|
||||||
|
return license
|
||||||
|
|
||||||
|
|
||||||
|
def check_license(license):
|
||||||
|
failed = 0
|
||||||
|
base_dir = "src/catch2/"
|
||||||
|
|
||||||
|
# The _ represents the list of directories in base_dir
|
||||||
|
for root, _, files in os.walk(base_dir):
|
||||||
|
for file in files:
|
||||||
|
with open(root + "/" + file, "r") as f:
|
||||||
|
file_license = f.readlines()[0:7]
|
||||||
|
|
||||||
|
if file_license != license:
|
||||||
|
print("File %s does not have license" % file)
|
||||||
|
failed = 1
|
||||||
|
|
||||||
|
return failed
|
||||||
|
|
||||||
|
|
||||||
|
license = get_license()
|
||||||
|
status = check_license(license)
|
||||||
|
sys.exit(status)
|
Loading…
Reference in New Issue
Block a user