Skip to content

Commit ebec495

Browse files
committed
travis: license check for new files
Fail if new file does not contain SPDX identifier. We only checked for changed files, and warn. This is not sufficient because new files should follow our license guide. It could have been overlooked. This fixes the problem.
1 parent 5940b16 commit ebec495

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

.travis.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,38 @@ matrix:
7171
# scancode does not support list of files, only one file or directory
7272
# we use SCANCODE directory for all changed files (their copies with full tree)
7373
- >-
74-
git diff --name-only --diff-filter=d FETCH_HEAD..HEAD \
74+
git diff --name-only --diff-filter=ad FETCH_HEAD..HEAD \
7575
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true ) \
7676
| ( grep -v '^tools/test/toolchains/api_test.py' || true ) \
7777
| while read file; do cp --parents "${file}" SCANCODE; done
7878
- scancode -l --json-pp scancode.json SCANCODE
7979
- python ./tools/test/travis-ci/scancode-evaluate.py -f scancode.json || true
80+
# run the same but for new files. All new files must have SPDX
81+
- >-
82+
git diff --name-only --diff-filter=A FETCH_HEAD..HEAD \
83+
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true ) \
84+
| ( grep -v '^tools/test/toolchains/api_test.py' || true ) \
85+
| while read file; do cp --parents "${file}" SCANCODE_NEW_FILES; done
86+
- scancode -l --json-pp scancode_new_files.json SCANCODE_NEW_FILES
87+
- python ./tools/test/travis-ci/scancode-evaluate.py -f scancode_new_files.json || true
8088
after_success:
8189
- python ./tools/test/travis-ci/scancode-evaluate.py -f scancode.json
8290
- cat scancode-evaluate.log
8391
- COUNT=$(cat scancode-evaluate.log | grep 'File:' | wc -l)
92+
- python ./tools/test/travis-ci/scancode-evaluate.py -f scancode_new_files.json
93+
- cat scancode-evaluate.log
94+
- COUNT_NEW_FILES=$(cat scancode-evaluate.log | grep 'File:' | wc -l)
8495
- |
85-
if [ $COUNT == 0 ]; then
96+
if [ $COUNT == 0 && $COUNT_NEW_FILES == 0 ]; then
8697
echo "License check OK";
8798
STATUSM="All licenses OK";
8899
set_status "success" "$STATUSM";
100+
elif [ $COUNT_NEW_FILES != 0 ]; then
101+
echo "License check failed, new files with the license issues found";
102+
STATUSM="Needs review, ${COUNT} license issues found";
103+
set_status "failure" "$STATUSM";
89104
else
90-
echo "License check failed, please review license issues found";
105+
echo "License check failed, please review license issues found in modified files";
91106
STATUSM="Needs review, ${COUNT} license issues found";
92107
set_status "success" "$STATUSM";
93108
fi

0 commit comments

Comments
 (0)