Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Adds license check in CI

Commit
d913837a5dd40a2a5bdc30d7ce6482d0a626746b
Author
George Xanthakis ·
Parents
a9941d42315b

Files · Download .tar.gz

Changes

 .github/workflows/validate-header-guards.yml |  3 +++
 tools/scripts/checkLicense.py                | 32 ++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/.github/workflows/validate-header-guards.yml b/.github/workflows/validate-header-guards.yml
index 6aa905a3..c7a43f1d 100644
--- a/.github/workflows/validate-header-guards.yml
+++ b/.github/workflows/validate-header-guards.yml
@@ -34,3 +34,6 @@ jobs:
       - name: checknames
         run: |
           python tools/scripts/checkDuplicateFilenames.py
+      - name: checklicense
+        run: |
+          python tools/scripts/checkLicense.py
diff --git a/tools/scripts/checkLicense.py b/tools/scripts/checkLicense.py
new file mode 100644
index 00000000..3c2a14f4
--- /dev/null
+++ b/tools/scripts/checkLicense.py
@@ -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)