From 735163706fdbf8b33fea108fb055b43ffc7502ce Mon Sep 17 00:00:00 2001 From: Alexei Dodon Date: Fri, 6 Oct 2023 23:00:17 +0300 Subject: [PATCH] ci(licenses): check if licenses file is updated Signed-off-by: Alexei Dodon --- .github/workflows/license.yaml | 6 ++---- Makefile | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/license.yaml b/.github/workflows/license.yaml index 7aa1a30de8..c88dcadbbe 100644 --- a/.github/workflows/license.yaml +++ b/.github/workflows/license.yaml @@ -1,13 +1,9 @@ name: "Software License Check" on: push: - paths: - - 'go.mod' branches: - main pull_request: - paths: - - 'go.mod' # The branches below must be a subset of the branches above branches: [main] @@ -27,3 +23,5 @@ jobs: run: go install github.com/google/go-licenses@latest - name: Check for forbidden licenses run: make check-licenses + - name: Check if licenses file is updated + run: make update-licenses diff --git a/Makefile b/Makefile index 8f190ea5e1..7c24a3e0db 100644 --- a/Makefile +++ b/Makefile @@ -261,6 +261,12 @@ update-licenses: @echo "Detecting and updating licenses ... please be patient!" go install github.com/google/go-licenses@latest $(shell echo "Module | License URL | License" > THIRD-PARTY-LICENSES.md; echo "---|---|---" >> THIRD-PARTY-LICENSES.md; for i in $$(go list -m all | awk '{print $$1}'); do l=$$(go-licenses csv $$i 2>/dev/null); if [ $$? -ne 0 ]; then continue; fi; echo $$l | tr \, \| | tr ' ' '\n'; done | sort -u >> THIRD-PARTY-LICENSES.md) + $(eval UNCOMMITED_FILES = $(shell git status --porcelain | grep -c THIRD-PARTY-LICENSES.md)) + @if [ $(UNCOMMITED_FILES) != 0 ]; then \ + echo "THIRD-PARTY-LICENSES.md file needs to be updated";\ + git status;\ + exit 1;\ + fi .PHONY: check-licenses check-licenses: