@@ -640,6 +640,7 @@ jobs:
640
640
- test-e2e
641
641
- offlinedocs
642
642
- sqlc-vet
643
+ - dependency-license-review
643
644
# Allow this job to run even if the needed jobs fail, are skipped or
644
645
# cancelled.
645
646
if : always()
@@ -656,6 +657,7 @@ jobs:
656
657
echo "- test-js: ${{ needs.test-js.result }}"
657
658
echo "- test-e2e: ${{ needs.test-e2e.result }}"
658
659
echo "- offlinedocs: ${{ needs.offlinedocs.result }}"
660
+ echo "- dependency-license-review: ${{ needs.dependency-license-review.result }}"
659
661
echo
660
662
661
663
# We allow skipped jobs to pass, but not failed or cancelled jobs.
@@ -896,3 +898,41 @@ jobs:
896
898
- name : Setup and run sqlc vet
897
899
run : |
898
900
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