From 0ea5b923f49be6529a32150b52495b2650393873 Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Wed, 24 Jan 2024 19:50:01 +0800 Subject: [PATCH 01/16] add auto copyright scripts Signed-off-by: YanxuanLiu --- .pre-commit-config.yaml | 23 ++++++++++++++++++ CONTRIBUTING.md | 47 +++++++++++++++++++++++++++++++++++++ scripts/auto-copyrighter.sh | 41 ++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100755 scripts/auto-copyrighter.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7393ff4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +repos: + - repo: local + hooks: + - id: auto-copyrighter + name: Update copyright year + entry: scripts/auto-copyrighter.sh + language: script + pass_filenames: true + verbose: true \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f122e96..13135bb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -131,5 +131,52 @@ By making a contribution to this project, I certify that: this project or the open source license(s) involved. ``` +### Pre-commit hooks + +We provide a basic config `.pre-commit-config.yaml` for [pre-commit](https://pre-commit.com/) to +automate some aspects of the development process. As a convenience you can enable automatic +copyright year updates by following the installation instructions on the +[pre-commit homepage](https://pre-commit.com/). + +To this end, first install `pre-commit` itself using the method most suitable for your development +environment. Then you will need to run `pre-commit install` to enable it in your local git +repository. Using `--allow-missing-config` will make it easy to work with older branches +that do not have `.pre-commit-config.yaml`. + +```bash +pre-commit install --allow-missing-config +``` + +and setting the environment variable: + +```bash +export SPARK_RAPIDS_BENCHMARKS_AUTO_COPYRIGHTER=ON +``` +The default value of `SPARK_RAPIDS_BENCHMARKS_AUTO_COPYRIGHTER` is `OFF`. + +When automatic copyright updater is enabled and you modify a file with a prior +year in the copyright header it will be updated on `git commit` to the current year automatically. +However, this will abort the [commit process](https://github.com/pre-commit/pre-commit/issues/532) +with the following error message: +``` +Update copyright year....................................................Failed +- hook id: auto-copyrighter +- duration: 0.01s +- files were modified by this hook +``` +You can confirm that the update has actually happened by either inspecting its effect with +`git diff` first or simply re-executing `git commit` right away. The second time no file +modification should be triggered by the copyright year update hook and the commit should succeed. + +There is a known issue for macOS users if they use the default version of `sed`. The copyright update +script may fail and generate an unexpected file named `source-file-E`. As a workaround, please +install GNU sed + +```bash +brew install gnu-sed +# and add to PATH to make it as default sed for your shell +export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" +``` + ## Attribution Portions adopted from https://github.com/NVIDIA/spark-rapids/blob/main/CONTRIBUTING.md diff --git a/scripts/auto-copyrighter.sh b/scripts/auto-copyrighter.sh new file mode 100755 index 0000000..04e4c30 --- /dev/null +++ b/scripts/auto-copyrighter.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (c) 2024, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +SPARK_RAPIDS_BENCHMARKS_AUTO_COPYRIGHTER=${SPARK_RAPIDS_BENCHMARKS_AUTO_COPYRIGHTER:-OFF} + +case "$SPARK_RAPIDS_BENCHMARKS_AUTO_COPYRIGHTER" in + + OFF) + echo "Copyright updater is DISABLED. Automatic Copyright Updater can be enabled/disabled by setting \ +SPARK_RAPIDS_BENCHMARKS_AUTO_COPYRIGHTER=ON or SPARK_RAPIDS_BENCHMARKS_AUTO_COPYRIGHTER=OFF, \ +correspondingly" + exit 0 + ;; + + ON) + ;; + + *) + echo "Invalid value of SPARK_RAPIDS_BENCHMARKS_AUTO_COPYRIGHTER=$SPARK_RAPIDS_BENCHMARKS_AUTO_COPYRIGHTER. + Only ON or OFF are allowed" + exit 1 + ;; +esac + +set -x +echo "$@" | xargs -L1 sed -i -E \ + "s/Copyright *\(c\) *([0-9,-]+)*-([0-9]{4}), *NVIDIA *CORPORATION/Copyright (c) \\1-`date +%Y`, NVIDIA CORPORATION/; /`date +%Y`/! s/Copyright *\(c\) ([0-9]{4}), *NVIDIA *CORPORATION/Copyright (c) \\1-`date +%Y`, NVIDIA CORPORATION/" \ No newline at end of file From 2acb003f9fd53dddc3d0e69b2fc20781dd2979f0 Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 12:06:09 +0800 Subject: [PATCH 02/16] add license head check Signed-off-by: YanxuanLiu --- .github/workflows/license-check.json | 7 +++++ .github/workflows/license-header-check.yml | 34 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .github/workflows/license-check.json create mode 100644 .github/workflows/license-header-check.yml diff --git a/.github/workflows/license-check.json b/.github/workflows/license-check.json new file mode 100644 index 0000000..b2c30d8 --- /dev/null +++ b/.github/workflows/license-check.json @@ -0,0 +1,7 @@ +[ + { + "include": ["**/**"], + "exclude": [], + "license": "LICENSE" + } +] \ No newline at end of file diff --git a/.github/workflows/license-header-check.yml b/.github/workflows/license-header-check.yml new file mode 100644 index 0000000..4f6eec8 --- /dev/null +++ b/.github/workflows/license-header-check.yml @@ -0,0 +1,34 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A workflow to check license header of files + +name: Check License Headers + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + check-headers: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Check license headers + uses: viperproject/check-license-header@v2 + with: + path: . + config: .github/license-check.json + strict: true \ No newline at end of file From 81ae16be22ca9c98f2f0dce5bc95bd1ef8446214 Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 12:10:56 +0800 Subject: [PATCH 03/16] change json path Signed-off-by: YanxuanLiu --- .github/workflows/license-header-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/license-header-check.yml b/.github/workflows/license-header-check.yml index 4f6eec8..cd85161 100644 --- a/.github/workflows/license-header-check.yml +++ b/.github/workflows/license-header-check.yml @@ -30,5 +30,5 @@ jobs: uses: viperproject/check-license-header@v2 with: path: . - config: .github/license-check.json + config: .github/workflow/license-check.json strict: true \ No newline at end of file From f377082cd45d71e30fbbd2d650170080e68b7b36 Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 12:12:33 +0800 Subject: [PATCH 04/16] fix path Signed-off-by: YanxuanLiu --- .github/workflows/license-header-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/license-header-check.yml b/.github/workflows/license-header-check.yml index cd85161..0bf6db5 100644 --- a/.github/workflows/license-header-check.yml +++ b/.github/workflows/license-header-check.yml @@ -30,5 +30,5 @@ jobs: uses: viperproject/check-license-header@v2 with: path: . - config: .github/workflow/license-check.json + config: .github/workflows/license-check.json strict: true \ No newline at end of file From ef456cd198bc7d5252b58bb3f683d161fd7e6d23 Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 12:53:37 +0800 Subject: [PATCH 05/16] change license config to regex Signed-off-by: YanxuanLiu --- .github/workflows/license-check.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/license-check.json b/.github/workflows/license-check.json index b2c30d8..151c57a 100644 --- a/.github/workflows/license-check.json +++ b/.github/workflows/license-check.json @@ -2,6 +2,6 @@ { "include": ["**/**"], "exclude": [], - "license": "LICENSE" + "license": "%regexp:^Licensed under the Apache License%" } ] \ No newline at end of file From b8452f9af78a981ead0a13dcb5565cf3afe1d290 Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 13:21:15 +0800 Subject: [PATCH 06/16] add slash Signed-off-by: YanxuanLiu --- .github/workflows/license-check.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/license-check.json b/.github/workflows/license-check.json index 151c57a..a8d80c7 100644 --- a/.github/workflows/license-check.json +++ b/.github/workflows/license-check.json @@ -2,6 +2,6 @@ { "include": ["**/**"], "exclude": [], - "license": "%regexp:^Licensed under the Apache License%" + "license": "\\%regexp:\\^Licensed under the Apache License\\%" } ] \ No newline at end of file From 8224bb101ae98e4e08a6ee3f199bd077e46e1ae2 Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 13:27:16 +0800 Subject: [PATCH 07/16] change back to license tt Signed-off-by: YanxuanLiu --- .github/workflows/license-check.json | 7 ------- .github/workflows/license-check/license-check.json | 7 +++++++ .github/workflows/license-check/license.test | 11 +++++++++++ .github/workflows/license-header-check.yml | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) delete mode 100644 .github/workflows/license-check.json create mode 100644 .github/workflows/license-check/license-check.json create mode 100644 .github/workflows/license-check/license.test diff --git a/.github/workflows/license-check.json b/.github/workflows/license-check.json deleted file mode 100644 index a8d80c7..0000000 --- a/.github/workflows/license-check.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "include": ["**/**"], - "exclude": [], - "license": "\\%regexp:\\^Licensed under the Apache License\\%" - } -] \ No newline at end of file diff --git a/.github/workflows/license-check/license-check.json b/.github/workflows/license-check/license-check.json new file mode 100644 index 0000000..83f44bd --- /dev/null +++ b/.github/workflows/license-check/license-check.json @@ -0,0 +1,7 @@ +[ + { + "include": ["**/**"], + "exclude": [], + "license": "license.txt" + } +] \ No newline at end of file diff --git a/.github/workflows/license-check/license.test b/.github/workflows/license-check/license.test new file mode 100644 index 0000000..2808da5 --- /dev/null +++ b/.github/workflows/license-check/license.test @@ -0,0 +1,11 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. \ No newline at end of file diff --git a/.github/workflows/license-header-check.yml b/.github/workflows/license-header-check.yml index 0bf6db5..1e36a49 100644 --- a/.github/workflows/license-header-check.yml +++ b/.github/workflows/license-header-check.yml @@ -30,5 +30,5 @@ jobs: uses: viperproject/check-license-header@v2 with: path: . - config: .github/workflows/license-check.json + config: .github/workflows/license-check/license-check.json strict: true \ No newline at end of file From 3fda5e34903f0f3f164b6443684eaaa58836fbaa Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 13:28:36 +0800 Subject: [PATCH 08/16] change license path Signed-off-by: YanxuanLiu --- .github/workflows/license-check/license-check.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/license-check/license-check.json b/.github/workflows/license-check/license-check.json index 83f44bd..c7fc8c9 100644 --- a/.github/workflows/license-check/license-check.json +++ b/.github/workflows/license-check/license-check.json @@ -2,6 +2,6 @@ { "include": ["**/**"], "exclude": [], - "license": "license.txt" + "license": ".github/workflows/license-check/license.txt" } ] \ No newline at end of file From ce1316c284bd0a13f821c9a36129f8f8c04424ac Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 13:29:37 +0800 Subject: [PATCH 09/16] file name Signed-off-by: YanxuanLiu --- .github/workflows/license-check/{license.test => license.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/license-check/{license.test => license.txt} (100%) diff --git a/.github/workflows/license-check/license.test b/.github/workflows/license-check/license.txt similarity index 100% rename from .github/workflows/license-check/license.test rename to .github/workflows/license-check/license.txt From 864b6ec16d0056b5219196ce0af3fca40167c33a Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 13:33:53 +0800 Subject: [PATCH 10/16] change license content Signed-off-by: YanxuanLiu --- .github/workflows/license-check/license.txt | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/license-check/license.txt b/.github/workflows/license-check/license.txt index 2808da5..7cd02b4 100644 --- a/.github/workflows/license-check/license.txt +++ b/.github/workflows/license-check/license.txt @@ -1,11 +1 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. \ No newline at end of file +Licensed under the Apache License, Version 2.0 (the "License"); From 2aa3d116ac065291480a5e97b9c3ae1025fc5ffc Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 13:44:13 +0800 Subject: [PATCH 11/16] change license content Signed-off-by: YanxuanLiu --- .github/workflows/license-check/license-Apache.txt | 1 + .github/workflows/license-check/license-check.json | 2 +- .github/workflows/license-check/license.txt | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/license-check/license-Apache.txt delete mode 100644 .github/workflows/license-check/license.txt diff --git a/.github/workflows/license-check/license-Apache.txt b/.github/workflows/license-check/license-Apache.txt new file mode 100644 index 0000000..6bbcbcb --- /dev/null +++ b/.github/workflows/license-check/license-Apache.txt @@ -0,0 +1 @@ +Licensed under the Apache License \ No newline at end of file diff --git a/.github/workflows/license-check/license-check.json b/.github/workflows/license-check/license-check.json index c7fc8c9..f4603be 100644 --- a/.github/workflows/license-check/license-check.json +++ b/.github/workflows/license-check/license-check.json @@ -2,6 +2,6 @@ { "include": ["**/**"], "exclude": [], - "license": ".github/workflows/license-check/license.txt" + "license": ".github/workflows/license-check/license-Apache.txt" } ] \ No newline at end of file diff --git a/.github/workflows/license-check/license.txt b/.github/workflows/license-check/license.txt deleted file mode 100644 index 7cd02b4..0000000 --- a/.github/workflows/license-check/license.txt +++ /dev/null @@ -1 +0,0 @@ -Licensed under the Apache License, Version 2.0 (the "License"); From a4fd525574661cacd2a37577705c09918c98a79a Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 13:48:00 +0800 Subject: [PATCH 12/16] add exclude for md Signed-off-by: YanxuanLiu --- .github/workflows/license-check/license-check.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/license-check/license-check.json b/.github/workflows/license-check/license-check.json index f4603be..a328dff 100644 --- a/.github/workflows/license-check/license-check.json +++ b/.github/workflows/license-check/license-check.json @@ -1,7 +1,7 @@ [ { "include": ["**/**"], - "exclude": [], + "exclude": ["**/.md"], "license": ".github/workflows/license-check/license-Apache.txt" } ] \ No newline at end of file From 9073d2066e4e4d82d37c4b4a19e913537a37af7b Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 13:50:50 +0800 Subject: [PATCH 13/16] change include and exclude Signed-off-by: YanxuanLiu --- .github/workflows/license-check/license-check.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/license-check/license-check.json b/.github/workflows/license-check/license-check.json index a328dff..ffbc80e 100644 --- a/.github/workflows/license-check/license-check.json +++ b/.github/workflows/license-check/license-check.json @@ -1,7 +1,7 @@ [ { - "include": ["**/**"], - "exclude": ["**/.md"], + "include": ["**/*"], + "exclude": ["*.md"], "license": ".github/workflows/license-check/license-Apache.txt" } ] \ No newline at end of file From 2c388c559c5a25c268efa0937827d0f47014c43f Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 25 Jan 2024 14:04:36 +0800 Subject: [PATCH 14/16] exclude all md Signed-off-by: YanxuanLiu --- .github/workflows/license-check/license-check.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/license-check/license-check.json b/.github/workflows/license-check/license-check.json index ffbc80e..21e7136 100644 --- a/.github/workflows/license-check/license-check.json +++ b/.github/workflows/license-check/license-check.json @@ -1,7 +1,7 @@ [ { "include": ["**/*"], - "exclude": ["*.md"], + "exclude": ["**/*.md"], "license": ".github/workflows/license-check/license-Apache.txt" } ] \ No newline at end of file From 93ef44555b7082f0c6eb3b778ab7909087ae7179 Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Tue, 30 Jan 2024 15:02:59 +0800 Subject: [PATCH 15/16] add python script Signed-off-by: YanxuanLiu --- .../license-check/license-Apache.txt | 1 - .../license-check/license-check.json | 7 -- .../workflows/license-check/license-check.py | 67 +++++++++++++++++++ .github/workflows/license-header-check.yml | 11 ++- 4 files changed, 72 insertions(+), 14 deletions(-) delete mode 100644 .github/workflows/license-check/license-Apache.txt delete mode 100644 .github/workflows/license-check/license-check.json create mode 100644 .github/workflows/license-check/license-check.py diff --git a/.github/workflows/license-check/license-Apache.txt b/.github/workflows/license-check/license-Apache.txt deleted file mode 100644 index 6bbcbcb..0000000 --- a/.github/workflows/license-check/license-Apache.txt +++ /dev/null @@ -1 +0,0 @@ -Licensed under the Apache License \ No newline at end of file diff --git a/.github/workflows/license-check/license-check.json b/.github/workflows/license-check/license-check.json deleted file mode 100644 index 21e7136..0000000 --- a/.github/workflows/license-check/license-check.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "include": ["**/*"], - "exclude": ["**/*.md"], - "license": ".github/workflows/license-check/license-Apache.txt" - } -] \ No newline at end of file diff --git a/.github/workflows/license-check/license-check.py b/.github/workflows/license-check/license-check.py new file mode 100644 index 0000000..65b593c --- /dev/null +++ b/.github/workflows/license-check/license-check.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +# Copyright (c) 2024, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""A license header check +The tool checks if all files in the repo contain the license header. +NOTE: this script is for github actions only, you should not use it anywhere else. +""" +import os +import sys +import glob +from argparse import ArgumentParser + +# Configs of the license header check +includes = ['**/*'] +excludes = ['**/*.md'] +LICENSE_PATTERN = "Licensed under the Apache License" + +def filterFiles(repo_path): + files = [] + files_excluded = [] + os.chdir(repo_path) + for pattern in includes: + files.extend([ f for f in glob.glob(repo_path + '/' + pattern, recursive=True) if os.path.isfile(f)]) + for pattern in excludes: + files_excluded.extend([ f for f in glob.glob(repo_path + '/' + pattern, recursive=True) if os.path.isfile(f)]) + return list(set(files) - set(files_excluded)), list(set(files_excluded)) + +def checkLicenseHeader(files): + no_license_files = [] + for file in files: + with open(file, 'r') as f: + print("Checking file: {}".format(file)) + content = f.read() + if LICENSE_PATTERN not in content: + no_license_files.append(file) + return no_license_files + +if __name__ == '__main__': + try: + repo_path = '.' + files, files_excluded = filterFiles(repo_path) + no_license_files = checkLicenseHeader(files) + warning_message = "" + for file in files_excluded: + warning_message += "WARNING: {} is excluded from this check.\n".format(file) + print(warning_message) + if no_license_files: + error_message = "" + for file in no_license_files: + error_message += "ERROR: {} does not contain license header.\n".format(file) + raise Exception(error_message) + except Exception as e: + print(e) + sys.exit(1) \ No newline at end of file diff --git a/.github/workflows/license-header-check.yml b/.github/workflows/license-header-check.yml index 1e36a49..45a3bff 100644 --- a/.github/workflows/license-header-check.yml +++ b/.github/workflows/license-header-check.yml @@ -26,9 +26,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Check license headers - uses: viperproject/check-license-header@v2 - with: - path: . - config: .github/workflows/license-check/license-check.json - strict: true \ No newline at end of file + + - name: license-check job + run: | + set -x + python3 .github/workflows/license-check/license-check.py From ed8bc99039fb9a3d97e5f7944db8c62dd6b8772b Mon Sep 17 00:00:00 2001 From: YanxuanLiu Date: Thu, 1 Feb 2024 09:52:51 +0800 Subject: [PATCH 16/16] add more excludes Signed-off-by: YanxuanLiu --- .github/workflows/license-check/license-check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/license-check/license-check.py b/.github/workflows/license-check/license-check.py index 65b593c..d9e6d69 100644 --- a/.github/workflows/license-check/license-check.py +++ b/.github/workflows/license-check/license-check.py @@ -25,7 +25,7 @@ # Configs of the license header check includes = ['**/*'] -excludes = ['**/*.md'] +excludes = ['**/*.md', 'NOTICE', 'TPC EULA.txt', '**/*.patch'] LICENSE_PATTERN = "Licensed under the Apache License" def filterFiles(repo_path):