Skip to content

Commit

Permalink
ci(licenses): check if licenses file is updated (#1898)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexei Dodon <[email protected]>
  • Loading branch information
adodon2go authored Oct 10, 2023
1 parent ee25985 commit 039648a
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 84 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/license.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,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
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,18 @@ swagger:
swag init --parseDependency -o swagger -g pkg/api/routes.go -q

.PHONY: update-licenses
# note: for predictable output of below sort command we use locale LC_ALL=C
update-licenses: LC_ALL=C
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:
Expand Down
Loading

0 comments on commit 039648a

Please sign in to comment.