@@ -46,25 +46,37 @@ vet: ## Run go vet against code
46
46
generate : controller-gen # # Generate code
47
47
$(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
48
48
49
- $(GO-LICENSES ) :
50
- go install github.com/google/go-licenses@latest
49
+ $(GO_LICENSES ) :
50
+ @if ! which $@ & > /dev/null; then \
51
+ go install github.com/google/go-licenses@latest; \
52
+ fi
51
53
52
- licenses.csv : go.mod # # Track licenses in a CSV file
54
+ licenses.csv : go.mod $( GO_LICENSES ) # # Track licenses in a CSV file
53
55
@echo " Tracking licenses into file $@ "
54
56
@echo " ========================================"
55
57
GOOS=linux GOARCH=amd64 $(GO_LICENSES ) csv --include_tests $(BASE_GO_PACKAGE ) /... > $@
56
58
57
- .PHONY : check-licenses
58
- check-licenses : licenses.csv # # Check licenses
59
+ # We only check that go.mod is NOT newer than licenses.csv because the CI
60
+ # tends to generate slightly different results, so content comparison wouldn't work
61
+ licenses-tracked : # # Checks license.csv is up to date
62
+ @if [ go.mod -nt licenses.csv ]; then \
63
+ echo " License.csv is stale! Please run 'make licenses.csv' and commit" ; exit 1; \
64
+ else echo " License.csv OK (up to date)" ; fi
65
+
66
+ .PHONY : check-licenses-compliance
67
+ check-licenses-compliance : licenses.csv # # Check licenses are compliant with our restrictions
59
68
@echo " Checking licenses not to be: $( DISALLOWED_LICENSES) "
60
69
@echo " ============================================"
61
70
GOOS=linux GOARCH=amd64 $(GO_LICENSES ) check --include_tests $(BASE_GO_PACKAGE ) /... \
62
71
--disallowed_types $(DISALLOWED_LICENSES )
63
72
@echo " --------------------"
64
73
@echo " Licenses check: PASS"
65
74
75
+ .PHONY : check-licenses
76
+ check-licenses : licenses-tracked check-licenses-compliance # # Check license tracking & compliance
77
+
66
78
TEST ?= ./pkg/... ./api/... ./cmd/... ./controllers/... ./test/e2e/util/mongotester/...
67
- test : generate fmt vet manifests check-licenses # # Run unit tests
79
+ test : generate fmt vet manifests # # Run unit tests
68
80
go test $(options ) $(TEST ) -coverprofile cover.out
69
81
70
82
manager : generate fmt vet # # Build operator binary
0 commit comments