From 9e40ec7ee146eadfcea66bf82da2f2ad96703fdf Mon Sep 17 00:00:00 2001 From: Jan Michalski Date: Tue, 19 Mar 2024 15:02:05 -0400 Subject: [PATCH 1/5] common: check_license remove unused code Signed-off-by: Jan Michalski --- utils/check_license/check-headers.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/utils/check_license/check-headers.sh b/utils/check_license/check-headers.sh index c3fd36a9bed..3b0fe72bc7f 100755 --- a/utils/check_license/check-headers.sh +++ b/utils/check_license/check-headers.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2016-2023, Intel Corporation +# Copyright 2016-2024, Intel Corporation # check-headers.sh - check copyright and license in source files @@ -26,7 +26,6 @@ shift PATTERN=`mktemp` TMP=`mktemp` TMP2=`mktemp` -TEMPFILE=`mktemp` rm -f $PATTERN $TMP $TMP2 if [ "$1" == "-h" -o "$1" == "--help" ]; then @@ -99,9 +98,6 @@ for file in $FILES ; do # git is called with -C flag so filepaths should be relative to SOURCE_ROOT src_path="${SOURCE_ROOT}/$file" [ ! -f $src_path ] && continue - # ensure that file is UTF-8 encoded - ENCODING=`file -b --mime-encoding $src_path` - iconv -f $ENCODING -t "UTF-8" $src_path > $TEMPFILE if ! grep -q "SPDX-License-Identifier: $LICENSE" $src_path; then echo "$src_path:1: no $LICENSE SPDX tag found " >&2 @@ -179,7 +175,7 @@ s/.*Copyright \([0-9]\+\),.*/\1-\1/' $src_path` RV=1 fi done -rm -f $TMP $TMP2 $TEMPFILE +rm -f $TMP $TMP2 $(dirname "$0")/check-ms-license.pl $FILES From 8792d61ddadab35ce4e3dd23c2be2916049a8547 Mon Sep 17 00:00:00 2001 From: Jan Michalski Date: Tue, 19 Mar 2024 15:31:19 -0400 Subject: [PATCH 2/5] common: check_license fix the year's line number Signed-off-by: Jan Michalski --- utils/check_license/check-headers.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/check_license/check-headers.sh b/utils/check_license/check-headers.sh index 3b0fe72bc7f..6fc14cd56f5 100755 --- a/utils/check_license/check-headers.sh +++ b/utils/check_license/check-headers.sh @@ -146,7 +146,7 @@ for file in $FILES ; do s/.*Copyright \([0-9]\+\)-\([0-9]\+\),.*/\1-\2/ s/.*Copyright \([0-9]\+\),.*/\1-\1/' $src_path` if [ -z "$YEARS" ]; then - echo >&2 "$src_path:1: No copyright years found" + echo >&2 "$src_path:2: No copyright years found" RV=1 continue fi @@ -167,7 +167,7 @@ s/.*Copyright \([0-9]\+\),.*/\1-\1/' $src_path` else NEW=$COMMIT_FIRST-$COMMIT_LAST fi - echo "$file:1: error: wrong copyright date: (is: $YEARS, should be: $NEW)" >&2 + echo "$file:2: error: wrong copyright date: (is: $YEARS, should be: $NEW)" >&2 RV=1 fi else From e17af64826b628d8c0802d7bd3b449675e94cc74 Mon Sep 17 00:00:00 2001 From: Jan Michalski Date: Tue, 19 Mar 2024 15:33:41 -0400 Subject: [PATCH 3/5] common: check_license fix single year range error message --- utils/check_license/check-headers.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/check_license/check-headers.sh b/utils/check_license/check-headers.sh index 6fc14cd56f5..b863a386efa 100755 --- a/utils/check_license/check-headers.sh +++ b/utils/check_license/check-headers.sh @@ -167,6 +167,9 @@ s/.*Copyright \([0-9]\+\),.*/\1-\1/' $src_path` else NEW=$COMMIT_FIRST-$COMMIT_LAST fi + if [ $HEADER_FIRST == $HEADER_LAST ]; then + YEARS=$HEADER_LAST + fi echo "$file:2: error: wrong copyright date: (is: $YEARS, should be: $NEW)" >&2 RV=1 fi From 9edb75776fba296303ff98797dd0daac22dcfdb8 Mon Sep 17 00:00:00 2001 From: Jan Michalski Date: Tue, 19 Mar 2024 16:24:23 -0400 Subject: [PATCH 4/5] common: allow check_license to apply proposed changes - assuming the source is not dirty Signed-off-by: Jan Michalski --- utils/check_license/check-headers.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/utils/check_license/check-headers.sh b/utils/check_license/check-headers.sh index b863a386efa..e53f1baa4ce 100755 --- a/utils/check_license/check-headers.sh +++ b/utils/check_license/check-headers.sh @@ -46,6 +46,12 @@ else SHALLOW_CLONE=0 fi +if [ $($GIT diff | wc -l) -gt 0 ]; then + DIRTY_SOURCE=1 +else + DIRTY_SOURCE=0 +fi + VERBOSE=0 CHECK_ALL=0 while [ "$1" != "" ]; do @@ -171,6 +177,9 @@ s/.*Copyright \([0-9]\+\),.*/\1-\1/' $src_path` YEARS=$HEADER_LAST fi echo "$file:2: error: wrong copyright date: (is: $YEARS, should be: $NEW)" >&2 + if [ $DIRTY_SOURCE -eq 0 ]; then + sed -i "s/\(Copyright\) $YEARS\(, Intel Corporation\)/\1 $NEW\2/" $src_path + fi RV=1 fi else @@ -187,5 +196,10 @@ if [ $RV -eq 0 ]; then echo "Copyright headers are OK." else echo "Error(s) in copyright headers found!" >&2 + if [ $DIRTY_SOURCE -eq 0 ]; then + echo "Please see the proposed changes to fix the found issues." >&2 + else + echo "Since the source is dirty no changes have been proposed." >&2 + fi fi exit $RV From c045462c1f0fd4791c00b4c91c7bb304a5e55fb8 Mon Sep 17 00:00:00 2001 From: Jan Michalski Date: Tue, 19 Mar 2024 16:52:30 -0400 Subject: [PATCH 5/5] common: Main / Check license add upload step --- .github/workflows/main.yml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 76cafb5b014..e2eef50cc19 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,12 +36,30 @@ jobs: sudo pip install flake8 sudo apt-get install clang-format-14 - - name: Check licenses + - name: Check license + id: check_license + continue-on-error: true env: NDCTL_ENABLE: n # just to speed up the job PMEMOBJ_IGNORE_DIRTY_SHUTDOWN: y # not recommended for production PMEMOBJ_IGNORE_BAD_BLOCKS: y # not recommended for production - run: make -j$(nproc) check-license + run: | + make -j$(nproc) check-license || true + git diff > /tmp/check-license.diff + [ $(cat /tmp/check-license.diff | wc -l ) -gt 0 ] && exit 1 + exit 0 + + - name: Upload check license diff + if: steps.check_license.outcome != 'success' + uses: actions/upload-artifact@v4 + with: + name: check-license.diff + path: /tmp/check-license.diff + + - name: Check license - Exit code + run: | + [ "${{steps.check_license.outcome}}" != "success" ] && exit 1 + exit 0 - name: Check style env: