Skip to content

Commit 80f5978

Browse files
authored
chore: add license review to CI (#12981)
1 parent 777dfbe commit 80f5978

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/ci.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ jobs:
640640
- test-e2e
641641
- offlinedocs
642642
- sqlc-vet
643+
- dependency-license-review
643644
# Allow this job to run even if the needed jobs fail, are skipped or
644645
# cancelled.
645646
if: always()
@@ -656,6 +657,7 @@ jobs:
656657
echo "- test-js: ${{ needs.test-js.result }}"
657658
echo "- test-e2e: ${{ needs.test-e2e.result }}"
658659
echo "- offlinedocs: ${{ needs.offlinedocs.result }}"
660+
echo "- dependency-license-review: ${{ needs.dependency-license-review.result }}"
659661
echo
660662
661663
# We allow skipped jobs to pass, but not failed or cancelled jobs.
@@ -896,3 +898,41 @@ jobs:
896898
- name: Setup and run sqlc vet
897899
run: |
898900
make sqlc-vet
901+
902+
# dependency-license-review checks that no license-incompatible dependencies have been introduced.
903+
# This action is not intended to do a vulnerability check since that is handled by a separate action.
904+
dependency-license-review:
905+
runs-on: ubuntu-latest
906+
steps:
907+
- name: "Checkout Repository"
908+
uses: actions/checkout@v4
909+
- name: "Dependency Review"
910+
id: review
911+
uses: actions/dependency-review-action@v4
912+
with:
913+
allow-licenses: Apache-2.0, BSD-2-Clause, BSD-3-Clause, CC0-1.0, ISC, MIT, MIT-0, MPL-2.0
914+
license-check: true
915+
vulnerability-check: false
916+
- name: "Report"
917+
# make sure this step runs even if the previous failed
918+
if: always()
919+
shell: bash
920+
env:
921+
VULNERABLE_CHANGES: ${{ steps.review.outputs.invalid-license-changes }}
922+
run: |
923+
fields=( "unlicensed" "unresolved" "forbidden" )
924+
925+
# This is unfortunate that we have to do this but the action does not support failing on
926+
# an unknown license. The unknown dependency could easily have a GPL license which
927+
# would be problematic for us.
928+
# Track https://github.com/actions/dependency-review-action/issues/672 for when
929+
# we can remove this brittle workaround.
930+
for field in "${fields[@]}"; do
931+
# Use jq to check if the array is not empty
932+
if [[ $(echo "$VULNERABLE_CHANGES" | jq ".${field} | length") -ne 0 ]]; then
933+
echo "Invalid or unknown licenses detected, contact @sreya to ensure your added dependency falls under one of our allowed licenses."
934+
echo "$VULNERABLE_CHANGES" | jq
935+
exit 1
936+
fi
937+
done
938+
echo "No incompatible licenses detected"

0 commit comments

Comments
 (0)