@@ -64,30 +64,46 @@ matrix:
64
64
- pip install scancode-toolkit==3.1.1
65
65
before_script :
66
66
- mkdir -p SCANCODE
67
+ - mkdir -p SCANCODE_NEW_FILES
67
68
# Fetch remaining information needed for branch comparison
68
69
- git fetch --all --unshallow --tags
69
70
- git fetch origin "${TRAVIS_BRANCH}"
70
71
script :
71
72
# scancode does not support list of files, only one file or directory
72
73
# we use SCANCODE directory for all changed files (their copies with full tree)
73
74
- >-
74
- git diff --name-only --diff-filter=d FETCH_HEAD..HEAD \
75
+ git diff --name-only --diff-filter=ad FETCH_HEAD..HEAD \
75
76
| ( grep '.\(c\|cpp\|h\|hpp\|py\)$' || true ) \
76
77
| ( grep -v '^tools/test/toolchains/api_test.py' || true ) \
77
78
| while read file; do cp --parents "${file}" SCANCODE; done
78
79
- scancode -l --json-pp scancode.json SCANCODE
79
80
- 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
80
89
after_success :
81
90
- python ./tools/test/travis-ci/scancode-evaluate.py -f scancode.json
82
91
- cat scancode-evaluate.log
83
92
- 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)
84
96
- |
85
- if [ $COUNT == 0 ]; then
97
+ if [ $COUNT == 0 && $COUNT_NEW_FILES == 0 ]; then
86
98
echo "License check OK";
87
99
STATUSM="All licenses OK";
88
100
set_status "success" "$STATUSM";
101
+ elif [ $COUNT_NEW_FILES != 0 ]; then
102
+ echo "License check failed, new files with the license issues found";
103
+ STATUSM="Needs review, ${COUNT} license issues found";
104
+ set_status "failure" "$STATUSM";
89
105
else
90
- echo "License check failed, please review license issues found";
106
+ echo "License check failed, please review license issues found in modified files ";
91
107
STATUSM="Needs review, ${COUNT} license issues found";
92
108
set_status "success" "$STATUSM";
93
109
fi
0 commit comments