Skip to content

Commit 07adffc

Browse files
jmklixbretambrose
andauthored
add license checker (#447)
Co-authored-by: Bret Ambrose <[email protected]>
1 parent 8e83351 commit 07adffc

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/license-check.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: License Scan
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: [3.9]
12+
13+
steps:
14+
- name: Checkout main
15+
uses: actions/checkout@v2
16+
with:
17+
path: sdkmain
18+
ref: ${{ github.base_ref }}
19+
- name: Checkout this ref
20+
uses: actions/checkout@v2
21+
with:
22+
path: new-ref
23+
fetch-depth: 0
24+
- name: Get Diff
25+
run: git --git-dir ./new-ref/.git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }}| xargs > fileList.txt
26+
- name: Checkout scancode
27+
uses: actions/checkout@v2
28+
with:
29+
repository: nexB/scancode-toolkit
30+
path: scancode-toolkit
31+
fetch-depth: 1
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v2
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
# ScanCode
37+
- name: Self-configure scancode
38+
working-directory: ./scancode-toolkit
39+
run: ./scancode --help
40+
- name: Run Scan code on pr ref
41+
run: for filename in $(< fileList.txt); do ./scancode-toolkit/scancode -l -n 30 --json-pp - ./sdkmain/$filename | grep short_name | sort | uniq >> old-licenses.txt; done
42+
- name: Run Scan code on main
43+
run: for filename in $(< fileList.txt); do ./scancode-toolkit/scancode -l -n 30 --json-pp - ./new-ref/$filename | grep short_name | sort | uniq >> new-licenses.txt; done
44+
# compare
45+
- name: License test
46+
run: if ! cmp old-licenses.txt new-licenses.txt; then echo "Licenses differ! Failing."; exit -1; else echo "Licenses are the same. Success."; exit 0; fi

0 commit comments

Comments
 (0)