Skip to content

Commit adaa2b6

Browse files
committed
travis: license check does not fail but report issues
Master branch contains lot of missing SPDX identifiers, we will clean them up but this will take some time. In the meantime, we should not increase the license missing files. Each PR will report if there is no license issue or positive number reported as Github status. Travis won't fail if there are issues. This will highlight the issues that anyone can fix. As soon as master is clean, we can fix set_status and revert part of this commit.
1 parent 37a7ff0 commit adaa2b6

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,20 @@ matrix:
7373
| ( grep -v '^tools/test/toolchains/api_test.py') \
7474
| while read file; do cp --parents "${file}" SCANCODE; done
7575
- scancode -l --json-pp scancode.json SCANCODE
76+
- python ./tools/test/travis-ci/scancode-evaluate.py -f scancode.json || true
77+
after_success:
7678
- python ./tools/test/travis-ci/scancode-evaluate.py -f scancode.json
79+
- retval=$?
80+
- |
81+
if [ $retval == 0 ]; then
82+
echo "License check OK";
83+
else
84+
echo "License check failed, please review license issues found";
85+
STATUSM="Needs review, ${retval} license issues found";
86+
set_status "success" "$STATUSM";
87+
fi
88+
89+
7790
7891
- <<: *basic-vm
7992
name: "include check"

tools/test/travis-ci/scancode-evaluate.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def license_check(directory_name, file):
4747
file - scancode json output file (output from scancode --license --json-pp)
4848
4949
Returns:
50-
0 if success, -1 if any error in file licenses found
50+
0 if nothing found
51+
>0 - count how many license isses found
52+
-1 if any error in file licenses found
5153
"""
5254

5355
offenders = []
@@ -103,9 +105,7 @@ def license_check(directory_name, file):
103105
userlog.warning("Found files with missing license details, please review and fix")
104106
for offender in offenders:
105107
userlog.warning("File: " + offender['file']['path'][len(directory_name):] + " " + "reason: " + offender['reason'])
106-
return -1
107-
else:
108-
return 0
108+
return len(offenders)
109109

110110
def parse_args():
111111
parser = argparse.ArgumentParser(
@@ -119,7 +119,6 @@ def parse_args():
119119
if __name__ == "__main__":
120120

121121
args = parse_args()
122-
123122
if args.file and os.path.isfile(args.file):
124123
sys.exit(license_check(args.directory_name, args.file))
125124
else:

0 commit comments

Comments
 (0)