From 3c7775db15056d8980254f1fa19b5f9417e8a0f2 Mon Sep 17 00:00:00 2001 From: Sam Dowell Date: Mon, 12 Aug 2024 18:58:41 -0700 Subject: [PATCH] ci: make license check presubmit stricter (#1389) This updates the lint-license check to validate all dependencies in the vendor directory and use a specific allowlist of licenses. This will make it more apparent when new licenses are added in the future. --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 38741cfdf..cd6456850 100644 --- a/Makefile +++ b/Makefile @@ -367,11 +367,16 @@ lint-go: "$(GOLANGCI_LINT)" lint-bash: @./scripts/lint-bash.sh +# List of currently permitted licenses to be included for go modules. +# This may need to be updated as new dependencies are added. +# See https://github.com/google/licenseclassifier/blob/e6a9bb99b5a6f71d5a34336b8245e305f5430f99/license_type.go +ALLOWED_LICENSES := "MIT,ISC,Apache-2.0,BSD-2-Clause,BSD-3-Clause" + .PHONY: lint-license # Lints licenses for all packages, even ones just for testing. lint-license: "$(GO_LICENSES)" - @echo "\"$(GO_LICENSES)\" check \$$(go list all)" - @"$(GO_LICENSES)" check $(shell go list all) + @echo "\"$(GO_LICENSES)\" check --allowed_licenses=$(ALLOWED_LICENSES) \$$(go list all) ./vendor/..." + @"$(GO_LICENSES)" check --allowed_licenses=$(ALLOWED_LICENSES) $(shell go list all) ./vendor/... "$(GO_LICENSES)": buildenv-dirs GOPATH="$(GO_DIR)" go install github.com/google/go-licenses/v2