From ce89fb2751c08d4b87dace547633c91475a15cc6 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sun, 28 Nov 2021 19:03:30 +0100 Subject: [PATCH] CICD: Add check for accidental inclusion of GPL:ed code --- .github/workflows/CICD.yml | 9 +++++++++ tests/scripts/license-checks.sh | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 tests/scripts/license-checks.sh diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index a4107768..b871d6b9 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -27,6 +27,15 @@ jobs: - uses: actions/checkout@v2 - run: cargo fmt -- --check + license_checks: + name: License checks + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + submodules: true # we especially want to perform license checks on submodules + - run: tests/scripts/license-checks.sh + min_version: name: Minimum supported rust version runs-on: ubuntu-20.04 diff --git a/tests/scripts/license-checks.sh b/tests/scripts/license-checks.sh new file mode 100755 index 00000000..4de9f2b0 --- /dev/null +++ b/tests/scripts/license-checks.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -o errexit -o nounset -o pipefail + +# Make sure that we don't accidentally include GPL licenced files +gpl_term="General Public License" +gpl_excludes=( + # Snippet expands to GPL, but is not under GPL + ":(exclude)assets/syntaxes/01_Packages/Matlab/Snippets/Octave-function.sublime-snippet" + + # 'gpl_term' matches itself :D + ":(exclude)tests/scripts/license-checks.sh" + + # Contains a reference to GPL, but is not under GPL + ":(exclude)tests/syntax-tests/source/Java Server Page (JSP)/LICENSE.md" +) +gpl_occurances=$(git grep --recurse-submodules "${gpl_term}" -- "${gpl_excludes[@]}" || true) + +if [ -z "${gpl_occurances}" ]; then + echo "PASS: No files under GPL were found" +else + echo "FAIL: GPL:ed code is not compatible with bat, but occurances of '${gpl_term}' were found:" + echo "${gpl_occurances}" + exit 1 +fi