From 0264c4d64c82ae74a54b85d274eec5084c2c0abf Mon Sep 17 00:00:00 2001 From: mlevesquedion Date: Wed, 21 Feb 2024 09:19:55 -0800 Subject: [PATCH] Exclude MLIR bytecode files from license check (#2025) Also, don't add an extra line between each skip, and use the same message for each type of skipped file (easier to read). I tested the script locally by creating files with various suffixes and confirmed that the skipped suffixes are indeed skipped (and files with a non-skipped suffix are not skipped). --- .../github_actions/lint_check_license.sh | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/build_tools/github_actions/lint_check_license.sh b/build_tools/github_actions/lint_check_license.sh index 940c0d46f87..1eaa68e3d9c 100755 --- a/build_tools/github_actions/lint_check_license.sh +++ b/build_tools/github_actions/lint_check_license.sh @@ -44,22 +44,24 @@ echo "Checking the following files for licenses: $(printf "%s\n" "${CHANGED_FILES[@]}")" echo +SKIPPED_SUFFIXES=( + MODULE.bazel.lock + .mlir + .mlir.bc + .md +) + UNLICENSED_FILES=() for file in "${CHANGED_FILES[@]}"; do - if [[ "$file" == MODULE.bazel.lock ]]; then - echo "Skipping generated file: $file" - echo - continue - fi - if [[ "$file" = *.mlir ]]; then - echo "Skipping MLIR assembly file: $file" - echo - continue - fi - if [[ "$file" = *.md ]]; then - echo "Skipping Markdown file: $file" - echo - continue + skip=0 + for suffix in "${SKIPPED_SUFFIXES[@]}"; do + if [[ "$file" = *$suffix ]]; then + skip=1 + fi + done + if (( skip )); then + echo "Skipping file: $file" + continue; fi if ! head -20 "$file" | grep "Copyright" &>/dev/null; then UNLICENSED_FILES+=("$file")