From 4cf1d7470553d7a68f0a7286674061565777fe1e Mon Sep 17 00:00:00 2001 From: Catarina Paralta <46568597+paralta@users.noreply.github.com> Date: Tue, 6 Feb 2024 09:48:24 +0000 Subject: [PATCH] refactor: check licenses in multiple modules (#1160) --- .github/workflows/reusable-verification.yml | 2 +- Makefile | 26 +++++++++++++++++---- makefile.d/20-tools.mk | 1 + 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/reusable-verification.yml b/.github/workflows/reusable-verification.yml index f30487181..e618e96b5 100644 --- a/.github/workflows/reusable-verification.yml +++ b/.github/workflows/reusable-verification.yml @@ -45,7 +45,7 @@ jobs: - name: Vendor dependencies to retrieve licenses locally # Vendor deps before running https://github.com/goph/licensei # to avoid false-positives when modules GitHub repo could not be determined - run: go mod vendor + run: make gomod-vendor - name: Check licenses env: diff --git a/Makefile b/Makefile index c6a76e6dd..09a675786 100644 --- a/Makefile +++ b/Makefile @@ -149,13 +149,29 @@ e2e: docker ## Run end-to-end test suite cd e2e && \ go test -v -failfast -test.v -test.paniconexit0 -timeout 2h -ginkgo.v . +VENDORMODULES = $(addprefix vendor-, $(GOMODULES)) + +$(VENDORMODULES): + cd $(dir $(@:vendor-%=%)) && go mod vendor + +.PHONY: gomod-vendor +gomod-vendor: $(VENDORMODULES) # Make vendored copy of dependencies for all modules + +LICENSECHECKMODULES = $(GOMODULES) + +$(LICENSECHECKMODULES): + cd $(dir $(@:license-check-%=%)) && "$(LICENSEI_BIN)" check --config "$(LICENSEI_CONFIG)" + .PHONY: license-check -license-check: bin/licensei license-cache ## Check licenses for software components - $(LICENSEI_BIN) check +license-check: bin/licensei license-cache $(LICENSECHECKMODULES) ## Check licenses for software components + +LICENSECACHEMODULES = $(addprefix license-cache-, $(GOMODULES)) + +$(LICENSECACHEMODULES): + cd $(dir $(@:license-cache-%=%)) && "$(LICENSEI_BIN)" cache --config "$(LICENSEI_CONFIG)" -.PHONY: license-cache -license-cache: bin/licensei ## Generate license cache - $(LICENSEI_BIN) cache ++.PHONY: license-cache +license-cache: bin/licensei $(LICENSECACHEMODULES) ## Generate license cache .PHONY: lint lint: license-check lint-actions lint-bicep lint-cfn lint-go lint-helm ## Run all the linters diff --git a/makefile.d/20-tools.mk b/makefile.d/20-tools.mk index b6957c8ae..c33048c40 100644 --- a/makefile.d/20-tools.mk +++ b/makefile.d/20-tools.mk @@ -3,6 +3,7 @@ #### LICENSEI_BIN := $(BIN_DIR)/licensei +LICENSEI_CONFIG := $(ROOT_DIR)/.licensei.toml LICENSEI_VERSION = 0.9.0 bin/licensei: bin/licensei-$(LICENSEI_VERSION)