Skip to content

Commit fdab61d

Browse files
authored
Merge pull request #13586 from 0xc0170/fix_travis_new_files
travis: license check for new files
2 parents dcf6def + 36bb124 commit fdab61d

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

.travis.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,32 +64,50 @@ matrix:
6464
- pip install scancode-toolkit==3.1.1
6565
before_script:
6666
- mkdir -p SCANCODE
67+
- mkdir -p SCANCODE_NEW_FILES
6768
# Fetch remaining information needed for branch comparison
6869
- git fetch --all --unshallow --tags
6970
- git fetch origin "${TRAVIS_BRANCH}"
7071
script:
7172
# scancode does not support list of files, only one file or directory
7273
# we use SCANCODE directory for all changed files (their copies with full tree)
7374
- >-
74-
git diff --name-only --diff-filter=d FETCH_HEAD..HEAD \
75+
git diff --name-only --diff-filter=ad FETCH_HEAD..HEAD \
7576
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true ) \
7677
| ( grep -v '^tools/test/toolchains/api_test.py' || true ) \
7778
| while read file; do cp --parents "${file}" SCANCODE; done
7879
- scancode -l --json-pp scancode.json SCANCODE
7980
- python ./tools/test/travis-ci/scancode-evaluate.py -f scancode.json || true
81+
# run the same but for new files. All new files must have SPDX
82+
- >-
83+
git diff --name-only --diff-filter=A FETCH_HEAD..HEAD \
84+
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true ) \
85+
| ( grep -v '^tools/test/toolchains/api_test.py' || true ) \
86+
| while read file; do cp --parents "${file}" SCANCODE_NEW_FILES; done
87+
- scancode -l --json-pp scancode_new_files.json SCANCODE_NEW_FILES
88+
- python ./tools/test/travis-ci/scancode-evaluate.py -f scancode_new_files.json || true
8089
after_success:
8190
- python ./tools/test/travis-ci/scancode-evaluate.py -f scancode.json
8291
- cat scancode-evaluate.log
8392
- COUNT=$(cat scancode-evaluate.log | grep 'File:' | wc -l)
93+
- python ./tools/test/travis-ci/scancode-evaluate.py -f scancode_new_files.json
94+
- cat scancode-evaluate.log
95+
- COUNT_NEW_FILES=$(cat scancode-evaluate.log | grep 'File:' | wc -l)
8496
- |
85-
if [ $COUNT == 0 ]; then
97+
if [ $COUNT == 0 ] && [ $COUNT_NEW_FILES == 0 ]; then
8698
echo "License check OK";
8799
STATUSM="All licenses OK";
88100
set_status "success" "$STATUSM";
101+
elif [ $COUNT_NEW_FILES != 0 ]; then
102+
echo "License check failed, files with the license issues found";
103+
STATUSM="Needs review, license issues in modified files: ${COUNT}, new files: ${COUNT_NEW_FILES}";
104+
set_status "failure" "$STATUSM";
105+
false;
89106
else
90-
echo "License check failed, please review license issues found";
107+
echo "License check failed, please review license issues found in modified files";
91108
STATUSM="Needs review, ${COUNT} license issues found";
92109
set_status "success" "$STATUSM";
110+
false;
93111
fi
94112
95113

0 commit comments

Comments
 (0)