-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AZP: Add header check for copyrights scan
- Loading branch information
1 parent
63be496
commit a3baaf1
Showing
4 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
general: | ||
exclude: | ||
- "\\.git.*" | ||
- "\\.(yml|md|txt)" | ||
- "^\\.ci.*" | ||
- "NEWS" | ||
- "\\.(m4|ac)" | ||
- "\\.conf" | ||
- "src/components/tl/nvat/*" | ||
- "\\.cu" | ||
- "AUTHORS" | ||
- "LICENSE" | ||
- "docs/*" | ||
- "\\.Dockerfile" # might need an update from this point on | ||
- "perftest_msg_pow2" | ||
- "contrib/*" | ||
- "debian/*" | ||
- "src/\\*/Makefile" | ||
- "src/ucg/Makefile" | ||
- "src/ucg/base/Makefile" | ||
- "src/ucg/builtin/Makefile" | ||
- "src/ucs/arch/aarch64/memcpy_thunderx2.S" | ||
- "\\.mod" | ||
- "\\.supp" | ||
- "\\.log" | ||
|
||
bsd: | ||
validate-spdx-license: true | ||
include: | ||
- ".*\\.(am|in|hpp|cpp|py|cc|h|c|sh|go|xml|java|yaml|inl)$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash -x | ||
|
||
if [ -z "$WORKSPACE" ]; then | ||
echo "ERROR: WORKSPACE variable is empty" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "$WORKSPACE" ]; then | ||
echo "ERROR: ""$WORKSPACE"" does not exist" | ||
exit 1 | ||
fi | ||
|
||
# this variable is mandatory for header_check.py | ||
if [[ -z $GITHUB_TOKEN ]]; then | ||
echo "ERROR: GITHUB_TOKEN variable is empty" | ||
exit 1 | ||
fi | ||
|
||
IMAGE="rdmz-harbor.rdmz.labs.mlnx/toolbox/header_check" | ||
IMAGE="harbor.mellanox.com/toolbox/header_check" | ||
HEADER_CHECK_TOOL="docker run --rm \ | ||
--user $(id -u):$(id -g) \ | ||
-v $PWD:$PWD -w $PWD \ | ||
$IMAGE" | ||
|
||
$HEADER_CHECK_TOOL \ | ||
--config "${WORKSPACE}"/buildlib/tools/copyright-check-map.yaml \ | ||
--path "$WORKSPACE" \ | ||
--git-repo "$WORKSPACE" | tee copyrights.log | ||
|
||
exit_code=$? | ||
echo "exit_code=${exit_code}" | ||
# Correct error code is not returned by the script, need to check output file if its empty it failed | ||
if [[ ! -s copyrights.log ]]; then | ||
echo "copyrights.log is empty which means the script failed internally" | ||
exit 1 | ||
fi | ||
set +eE | ||
grep -rn ERROR copyrights.log | ||
exit_code=$? | ||
set -eE | ||
if [ ${exit_code} -eq 0 ]; then | ||
echo "Please refer to https://confluence.nvidia.com/pages/viewpage.action?pageId=788418816" | ||
${HEADER_CHECK_TOOL} \ | ||
--config "${WORKSPACE}"/buildlib/tools/copyright-check-map.yaml \ | ||
--path "${WORKSPACE}" \ | ||
--repair \ | ||
--git-repo "${WORKSPACE}" | tee copyrights_repair.log | ||
# create list of modified files | ||
# needed for new git versions (from the check header docker image) | ||
git config --global --add safe.directory "$WORKSPACE" | ||
files=$(git status | grep 'modified:' | awk '{print $NF}' ) | ||
mkdir "$WORKSPACE"/repaired_files/ | ||
cp --parents "$files" "$WORKSPACE"/repaired_files/ | ||
cd "$WORKSPACE"/repaired_files/ | ||
tar -czf "$WORKSPACE"/copyright_repaired_files.tar.gz . | ||
exit 1 | ||
fi | ||
if [ "${do_release}" == "true" ] && [ ! -z "${RMAX_SDK_VERSION}" ]; then | ||
REPORTS_DIR="${release_dir}/${RMAX_SDK_VERSION}/reports" | ||
sudo -E -u swx-jenkins mkdir -p "${REPORTS_DIR}" | ||
sudo -E -u swx-jenkins cp -v copyrights.log "${REPORTS_DIR}" | ||
|
||
# upload to artifactory - experimental does not fail build | ||
TARGET_PATH="$ARTIFACTORY_URL/$ARTIFACTORY_REPO/release/$RMAX_SDK_VERSION/linux/reports/copyright/" | ||
curl --silent --show-error --fail -u "$ARTIFACTORY_USER:$ARTIFACTORY_KEY" -T copyrights.log \ | ||
-X PUT "$TARGET_PATH" || true | ||
fi |