From 9bf1e85dfa5ef443f519041ef86e7410557ab9cb Mon Sep 17 00:00:00 2001 From: sapcc-bot Date: Thu, 15 Feb 2024 15:41:25 +0000 Subject: [PATCH] Run go-makefile-maker --- .license-scan-overrides.jsonl | 1 + Makefile | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.license-scan-overrides.jsonl b/.license-scan-overrides.jsonl index 58c45080..708e4f0e 100644 --- a/.license-scan-overrides.jsonl +++ b/.license-scan-overrides.jsonl @@ -1,3 +1,4 @@ {"name": "github.com/chzyer/logex", "licenceType": "MIT"} +{"name": "github.com/hashicorp/vault/api/auth/approle", "licenceType": "MPL-2.0"} {"name": "github.com/jpillora/longestcommon", "licenceType": "MIT"} {"name": "github.com/spdx/tools-golang", "licenceTextOverrideFile": "vendor/github.com/spdx/tools-golang/LICENSE.code"} diff --git a/Makefile b/Makefile index e75fc6a0..22b3212b 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,11 @@ install-scripts: install -m 0755 motd.sh "$(DESTDIR)$(PREFIX)/bin/motd.sh" install: install-scripts +prepare-static-check: FORCE + @if ! hash golangci-lint 2>/dev/null; then printf "\e[1;36m>> Installing golangci-lint (this may take a while)...\e[0m\n"; go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; fi + @if ! hash go-licence-detector 2>/dev/null; then printf "\e[1;36m>> Installing go-licence-detector...\e[0m\n"; go install go.elastic.co/go-licence-detector@latest; fi + @if ! hash addlicense 2>/dev/null; then printf "\e[1;36m>> Installing addlicense...\e[0m\n"; go install github.com/google/addlicense@latest; fi + GO_BUILDFLAGS = -mod vendor GO_LDFLAGS = GO_TESTENV = @@ -46,7 +51,7 @@ install: FORCE build/backup-server install -d -m 0755 "$(DESTDIR)$(PREFIX)/bin" install -m 0755 build/backup-server "$(DESTDIR)$(PREFIX)/bin/backup-server" -# which packages to test with "go test" +# which packages to test with test runner GO_TESTPKGS := $(shell go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}' ./...) # which packages to measure coverage for GO_COVERPKGS := $(shell go list ./...) @@ -58,18 +63,13 @@ comma := , check: FORCE static-check build/cover.html build-all @printf "\e[1;32m>> All checks successful.\e[0m\n" -prepare-static-check: FORCE - @if ! hash golangci-lint 2>/dev/null; then printf "\e[1;36m>> Installing golangci-lint (this may take a while)...\e[0m\n"; go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; fi - @if ! hash go-licence-detector 2>/dev/null; then printf "\e[1;36m>> Installing go-licence-detector...\e[0m\n"; go install go.elastic.co/go-licence-detector@latest; fi - @if ! hash addlicense 2>/dev/null; then printf "\e[1;36m>> Installing addlicense...\e[0m\n"; go install github.com/google/addlicense@latest; fi - run-golangci-lint: FORCE prepare-static-check @printf "\e[1;36m>> golangci-lint\e[0m\n" @golangci-lint run build/cover.out: FORCE | build - @printf "\e[1;36m>> go test\e[0m\n" - @env $(GO_TESTENV) go test $(GO_BUILDFLAGS) -ldflags '-s -w -X github.com/sapcc/go-api-declarations/bininfo.binName=backup-tools -X github.com/sapcc/go-api-declarations/bininfo.version=$(BININFO_VERSION) -X github.com/sapcc/go-api-declarations/bininfo.commit=$(BININFO_COMMIT_HASH) -X github.com/sapcc/go-api-declarations/bininfo.buildDate=$(BININFO_BUILD_DATE) $(GO_LDFLAGS)' -shuffle=on -p 1 -coverprofile=$@ -covermode=count -coverpkg=$(subst $(space),$(comma),$(GO_COVERPKGS)) $(GO_TESTPKGS) + @printf "\e[1;36m>> Running tests\e[0m\n" + @env $(GO_TESTENV) go test -shuffle=on $(GO_BUILDFLAGS) -ldflags '-s -w -X github.com/sapcc/go-api-declarations/bininfo.binName=backup-tools -X github.com/sapcc/go-api-declarations/bininfo.version=$(BININFO_VERSION) -X github.com/sapcc/go-api-declarations/bininfo.commit=$(BININFO_COMMIT_HASH) -X github.com/sapcc/go-api-declarations/bininfo.buildDate=$(BININFO_BUILD_DATE) $(GO_LDFLAGS)' -p 1 -coverprofile=$@ -covermode=count -coverpkg=$(subst $(space),$(comma),$(GO_COVERPKGS)) $(GO_TESTPKGS) build/cover.html: build/cover.out @printf "\e[1;36m>> go tool cover > build/cover.html\e[0m\n" @@ -125,6 +125,9 @@ help: FORCE @printf " \e[36mvars\e[0m Display values of relevant Makefile variables.\n" @printf " \e[36mhelp\e[0m Display this help.\n" @printf "\n" + @printf "\e[1mPrepare\e[0m\n" + @printf " \e[36mprepare-static-check\e[0m Install any tools required by static-check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n" + @printf "\n" @printf "\e[1mBuild\e[0m\n" @printf " \e[36mbuild-all\e[0m Build all binaries.\n" @printf " \e[36mbuild/backup-server\e[0m Build backup-server.\n" @@ -132,7 +135,6 @@ help: FORCE @printf "\n" @printf "\e[1mTest\e[0m\n" @printf " \e[36mcheck\e[0m Run the test suite (unit tests and golangci-lint).\n" - @printf " \e[36mprepare-static-check\e[0m Install any tools required by static-check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n" @printf " \e[36mrun-golangci-lint\e[0m Install and run golangci-lint. Installing is used in CI, but you should probably install golangci-lint using your package manager.\n" @printf " \e[36mbuild/cover.out\e[0m Run tests and generate coverage report.\n" @printf " \e[36mbuild/cover.html\e[0m Generate an HTML file with source code annotations from the coverage report.\n"