diff --git a/.github/verify_header.sh b/.github/verify_header.sh
index 42ddc01..d17f64d 100755
--- a/.github/verify_header.sh
+++ b/.github/verify_header.sh
@@ -5,20 +5,32 @@
# SPDX-License-Identifier: BSD-3-Clause
#
+# COPYRIGHT_REGEX is lowercase, because the whole line is
+# converted to lowercase before test against this regex.
+COPYRIGHT_REGEX="(copyright|\(c\))\s*([0-9]{4}(\s*-\s*([0-9]{4}))?)"
+LICENSE_REGEX="SPDX-License-Identifier: BSD-3-Clause$"
YEAR=$(date +"%Y")
-REGEX="Copyright\(c\) [0-9]{4}-([0-9]{4}) |Copyright\(c\) ([0-9]{4}) "
-while read -r line; do
- if [[ "$line" =~ $REGEX ]]; then
- echo ${BASH_REMATCH[0]}
- if [[ $YEAR == ${BASH_REMATCH[1]} || $YEAR == ${BASH_REMATCH[2]} ]]; then
- echo $1 have appropriate license header
- exit 0
- fi
- echo $1 have wrong license header year
- exit 1
- fi
+unset copyright_header license_header
+
+# Read lines until proper copyright and license headers are found.
+while read -r line && [[ ! "$copyright_header" || ! "$license_header" ]]; do
+ if [[ "${line,,}" =~ $COPYRIGHT_REGEX ]]; then
+ # If the fourth regex group (from year range) doesn't exist,
+ # use the second regex group instead (from a single year).
+ copyright_year=${BASH_REMATCH[4]:-${BASH_REMATCH[2]}}
+
+ if [[ $copyright_year == $YEAR ]]; then
+ copyright_header="correct_copyright_header_found"
+ fi
+ elif [[ "$line" =~ $LICENSE_REGEX ]]; then
+ license_header="correct_license_header_found"
+ fi
done < "$1"
-echo $1 does not contain appropriate license header
+# Proper copyright and license info were found - all good.
+[[ "$copyright_header" && "$license_header" ]] && exit 0
+
+[[ ! "$copyright_header" ]] && echo >&2 "error: file '$1' does not contain any appropriate copyright info"
+[[ ! "$license_header" ]] && echo >&2 "error: file '$1' does not contain appropriate license identifier"
exit 1
diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml
index ab4628a..a114262 100644
--- a/.github/workflows/pullrequest.yml
+++ b/.github/workflows/pullrequest.yml
@@ -5,7 +5,8 @@ on:
- master
env:
- EXTENSIONS: "c h cpp py go sh"
+ EXTENSIONS: "c h cpp py go sh mk spec service"
+ FILES: "*Makefile"
jobs:
verify-date:
runs-on: ubuntu-latest
@@ -23,15 +24,16 @@ jobs:
files_to_check=(${{ steps.changed-files.outputs.added_files }})
files_to_check+=(${{ steps.changed-files.outputs.modified_files }})
- for FILE in ${files_to_check[@]}; do
- REGEX=".*\.(.*)"
- if [[ "$FILE" =~ $REGEX ]]
- then
- EXTENSION=${BASH_REMATCH[1]}
- EXTENSIONS_LIST=($EXTENSIONS)
- if [[ " ${EXTENSIONS_LIST[*]} " =~ " ${EXTENSION} " ]]
- then
- .github/verify_header.sh $FILE
- fi
+ for file in ${files_to_check[@]}; do
+ for file_in_list in $FILES; do
+ if [[ "$file" == $file_in_list ]]; then
+ .github/verify_header.sh "$file"
+ continue 2
+ fi
+ done
+
+ extension=${file##*.}
+ if [[ "$EXTENSIONS" =~ $extension ]]; then
+ .github/verify_header.sh "$file"
fi
done
diff --git a/src/utils/utils_generator.c b/src/utils/utils_generator.c
index 32b42a2..47ab7e6 100644
--- a/src/utils/utils_generator.c
+++ b/src/utils/utils_generator.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
#include "utils_generator.h"
/**
diff --git a/tests/unit/tests/concurrency/ocf_cache_line_concurrency.c/ocf_cache_line_concurrency.c b/tests/unit/tests/concurrency/ocf_cache_line_concurrency.c/ocf_cache_line_concurrency.c
index 296fc00..8f7b988 100644
--- a/tests/unit/tests/concurrency/ocf_cache_line_concurrency.c/ocf_cache_line_concurrency.c
+++ b/tests/unit/tests/concurrency/ocf_cache_line_concurrency.c/ocf_cache_line_concurrency.c
@@ -2,6 +2,7 @@
* Copyright(c) 2021-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
+
/*
* src/concurrency/ocf_cache_line_concurrency.c
* ocf_req_async_lock_rd
diff --git a/tests/unit/tests/concurrency/ocf_metadata_concurrency.c/ocf_metadata_concurrency.c b/tests/unit/tests/concurrency/ocf_metadata_concurrency.c/ocf_metadata_concurrency.c
index 34b4f30..30badac 100644
--- a/tests/unit/tests/concurrency/ocf_metadata_concurrency.c/ocf_metadata_concurrency.c
+++ b/tests/unit/tests/concurrency/ocf_metadata_concurrency.c/ocf_metadata_concurrency.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2019-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/concurrency/ocf_metadata_concurrency.c
* ocf_hb_req_prot_lock_rd
diff --git a/tests/unit/tests/engine/engine_common.c/prepare_clines_miss.c b/tests/unit/tests/engine/engine_common.c/prepare_clines_miss.c
index e74b3c6..dfc2ef1 100644
--- a/tests/unit/tests/engine/engine_common.c/prepare_clines_miss.c
+++ b/tests/unit/tests/engine/engine_common.c/prepare_clines_miss.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2020-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/engine/engine_common.c
* ocf_prepare_clines_miss
diff --git a/tests/unit/tests/metadata/metadata_collision.c/metadata_collision.c b/tests/unit/tests/metadata/metadata_collision.c/metadata_collision.c
index 7f83ca9..d15edea 100644
--- a/tests/unit/tests/metadata/metadata_collision.c/metadata_collision.c
+++ b/tests/unit/tests/metadata/metadata_collision.c/metadata_collision.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2019-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/metadata/metadata_collision.c
* ocf_metadata_hash_func
diff --git a/tests/unit/tests/mngt/ocf_mngt_cache.c/ocf_mngt_cache_set_fallback_pt_error_threshold.c b/tests/unit/tests/mngt/ocf_mngt_cache.c/ocf_mngt_cache_set_fallback_pt_error_threshold.c
index 7f3f9b5..17b23f9 100644
--- a/tests/unit/tests/mngt/ocf_mngt_cache.c/ocf_mngt_cache_set_fallback_pt_error_threshold.c
+++ b/tests/unit/tests/mngt/ocf_mngt_cache.c/ocf_mngt_cache_set_fallback_pt_error_threshold.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2019-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
*src/mngt/ocf_mngt_cache.c
* ocf_mngt_cache_set_fallback_pt_error_threshold
diff --git a/tests/unit/tests/ocf_lru.c/lru.c b/tests/unit/tests/ocf_lru.c/lru.c
index a677522..ce69e82 100644
--- a/tests/unit/tests/ocf_lru.c/lru.c
+++ b/tests/unit/tests/ocf_lru.c/lru.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2021-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/ocf_lru.c
* _lru_init
diff --git a/tests/unit/tests/ocf_lru.c/lru_iter.c b/tests/unit/tests/ocf_lru.c/lru_iter.c
index 0f2ccfc..c6e9084 100644
--- a/tests/unit/tests/ocf_lru.c/lru_iter.c
+++ b/tests/unit/tests/ocf_lru.c/lru_iter.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2021-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/ocf_lru.c
* lru_iter_next
diff --git a/tests/unit/tests/ocf_space.c/ocf_space.c b/tests/unit/tests/ocf_space.c/ocf_space.c
index b257be2..067cc39 100644
--- a/tests/unit/tests/ocf_space.c/ocf_space.c
+++ b/tests/unit/tests/ocf_space.c/ocf_space.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2021-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/ocf_space.c
* ocf_remap_do
diff --git a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_dec.c b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_dec.c
index 8bd40fc..47d6c41 100644
--- a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_dec.c
+++ b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_dec.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2019-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/utils/utils_refcnt.c
* ocf_refcnt_dec
diff --git a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_freeze.c b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_freeze.c
index a1385f3..479519d 100644
--- a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_freeze.c
+++ b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_freeze.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2019-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/utils/utils_refcnt.c
* ocf_refcnt_freeze
diff --git a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_inc.c b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_inc.c
index d1b6133..ef9db7c 100644
--- a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_inc.c
+++ b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_inc.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2019-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/utils/utils_refcnt.c
* ocf_refcnt_inc
diff --git a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_init.c b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_init.c
index 3f28207..af63087 100644
--- a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_init.c
+++ b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_init.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2019-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/utils/utils_refcnt.c
* ocf_refcnt_init
diff --git a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_register_zero_cb.c b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_register_zero_cb.c
index fcb260c..65959a4 100644
--- a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_register_zero_cb.c
+++ b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_register_zero_cb.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2019-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/utils/utils_refcnt.c
* ocf_refcnt_register_zero_cb
diff --git a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_unfreeze.c b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_unfreeze.c
index 2a2e10b..229fe1f 100644
--- a/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_unfreeze.c
+++ b/tests/unit/tests/utils/utils_refcnt.c/utils_refcnt_unfreeze.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright(c) 2019-2022 Intel Corporation
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
/*
* src/utils/utils_refcnt.c
* ocf_refcnt_unfreeze