Skip to content

Commit e872cb9

Browse files
committed
chore: format and test unexpected license changes properly
1 parent 3b1aa76 commit e872cb9

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

.github/workflows/license-scan.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,31 @@ jobs:
2020
with:
2121
allow-licenses: 0BSD, BSD-1-Clause, BSD-2-Clause, BSD-3-Clause, LGPL-2.0-or-later, LGPL-2.1-or-later, LGPL-3.0-only, LGPL-3.0-or-later, MIT, WTFPL, Apache-2.0, MPL-2.0
2222
# Note that we explicitly allow LGPL-2.x-or-later, since LGPL-2.x (only) is not compatible with LGPL-3.x
23+
# allow-dependencies-licenses: 'pkg:pypi/numpy'
24+
#
2325
- name: 'Disallow unlicensed/unknown license'
2426
shell: bash
2527
env:
26-
UNLICENSED: "${{ steps.review.outputs.invalid-license-changes }}"
28+
UNRESOLVED_LICENSES: "${{ steps.review.outputs.invalid-license-changes }}"
2729
run: |
28-
EXPECTED='{"unlicensed":[],"unresolved":[],"forbidden":[]}'
30+
EXPECTED='{"unlicensed":["numpy"],"unresolved":[],"forbidden":[]}'
2931
3032
echo $EXPECTED
31-
echo $UNLICENSED
32-
33-
if [ $UNLICENSED = $EXPECTED ]; then
34-
echo "No unlicensed changes found."
33+
echo $UNRESOLVED_LICENSES
34+
35+
# get name of unresolved license dependencies
36+
UNRESOLVED_LICENSES_FORMATTED_JSON=$(echo $UNRESOLVED_LICENSES | jq '{unlicensed: [.unlicensed[].name], unresolved: [.unresolved[].name], forbidden: [.forbidden[].name]}')
37+
EXPECTED_FORMATTED_JSON=$(echo $EXPECTED | jq)
38+
39+
#echo $UNRESOLVED_LICENSES_FORMATTED_JSON
40+
#echo $EXPECTED_FORMATTED_JSON
41+
42+
if [ $UNRESOLVED_LICENSES_FORMATTED_JSON = $EXPECTED_FORMATTED_JSON ]; then
43+
echo "No unexpected unresolved license changes found."
3544
else
3645
BOLD_RED='\033[1;31m'
3746
RESET='\033[0m'
38-
echo -e "${BOLD_RED}Invalid license changes found:${RESET}\n$UNLICENSED"
47+
echo -e "${BOLD_RED}Invalid unresolved license changes found:${RESET}\n$UNRESOLVED_LICENSES_FORMATTED_JSON"
3948
exit 1
4049
fi
4150

0 commit comments

Comments
 (0)