diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | Makefile.build.mk | 3 | ||||
-rw-r--r-- | Makefile.internal.mk | 6 | ||||
-rw-r--r-- | Makefile.util.mk | 26 |
4 files changed, 10 insertions, 31 deletions
@@ -1,12 +1,6 @@ IMPORT_PATH := gitlab.com/gitlab-org/gitlab-pages V := 1 -# Space separated patterns of packages to skip in list, test, fmt. -IGNORED_DIRS := internal/httputil internal/mocks - -# GitLab Pages is statically compiled without CGO to help it in chroot mode -export CGO_ENABLED := 0 - include Makefile.build.mk include Makefile.util.mk include Makefile.internal.mk diff --git a/Makefile.build.mk b/Makefile.build.mk index ba672739..3289573d 100644 --- a/Makefile.build.mk +++ b/Makefile.build.mk @@ -3,7 +3,6 @@ GO_BUILD_TAGS := continuous_profiler_stackdriver FIPS_MODE ?= 0 ifeq ($(FIPS_MODE), 1) GO_BUILD_TAGS := $(GO_BUILD_TAGS),fips - CGO_ENABLED := 1 endif # To compute a unique and deterministic value for GNU build-id, we build the Go binary a second time. @@ -12,7 +11,7 @@ endif ## Skip generation of the GNU build ID if set to speed up builds. WITHOUT_BUILD_ID ?= -.PHONY: all setup generate-mocks build clean +.PHONY: all setup cisetup generate-mocks build clean all: gitlab-pages diff --git a/Makefile.internal.mk b/Makefile.internal.mk index a3e7eb7b..b4cf5777 100644 --- a/Makefile.internal.mk +++ b/Makefile.internal.mk @@ -10,12 +10,6 @@ endif VERSION_FLAGS :=-X "main.VERSION=$(VERSION)" -X "main.REVISION=$(REVISION)" -_allpackages = $(shell (go list ./... | \ - grep -v $(addprefix -e ,$(IGNORED_DIRS)))) - -# memoize allpackages, so that it's executed only once and only if used -allpackages = $(if $(__allpackages),,$(eval __allpackages := $$(_allpackages)))$(__allpackages) - export GOPATH := $(CURDIR)/.GOPATH export GOBIN := $(CURDIR)/bin diff --git a/Makefile.util.mk b/Makefile.util.mk index e9abe846..82eafd3b 100644 --- a/Makefile.util.mk +++ b/Makefile.util.mk @@ -1,9 +1,9 @@ -.PHONY: lint test race acceptance bench cover list deps-check deps-download changelog +.PHONY: lint format test race acceptance bench cover deps-check mocks-check deps-download changelog zip OUT_FORMAT ?= colored-line-number LINT_FLAGS ?= $(if $V,-v) REPORT_FILE ?= -COVERAGE_PACKAGES=$(shell (go list ./... | grep -v $(addprefix -e ,$(IGNORED_DIRS) "test/acceptance") | tr "\n", "," | sed 's/\(.*\),/\1 /')) +COVERAGE_PACKAGES=$(shell (go list ./... | grep -v -e "test/acceptance" | tr "\n", "," | sed 's/\(.*\),/\1 /')) lint: .GOPATH/.ok bin/golangci-lint $Q ./bin/golangci-lint run ./... --out-format $(OUT_FORMAT) $(LINT_FLAGS) | tee ${REPORT_FILE} @@ -11,34 +11,31 @@ lint: .GOPATH/.ok bin/golangci-lint format: .GOPATH/.ok bin/golangci-lint $Q ./bin/golangci-lint run ./... --fix --out-format $(OUT_FORMAT) $(LINT_FLAGS) | tee ${REPORT_FILE} -test: .GOPATH/.ok .GOPATH/.ok bin/gotestsum gitlab-pages +test: .GOPATH/.ok bin/gotestsum gitlab-pages rm -f tests.out ./bin/gotestsum --junitfile junit-test-report.xml --format testname -- ./... ${ARGS} -race: .GOPATH/.ok .GOPATH/.ok bin/gotestsum gitlab-pages - CGO_ENABLED=1 ./bin/gotestsum --junitfile junit-test-report.xml --format testname -- -race $(if $V,-v) $(allpackages) ${ARGS} +race: .GOPATH/.ok bin/gotestsum gitlab-pages + ./bin/gotestsum --junitfile junit-test-report.xml --format testname -- -race $(if $V,-v) ./... ${ARGS} -acceptance: .GOPATH/.ok .GOPATH/.ok bin/gotestsum gitlab-pages +acceptance: .GOPATH/.ok bin/gotestsum gitlab-pages ./bin/gotestsum --junitfile junit-test-report.xml --format testname -- $(if $V,-v) ./test/acceptance ${ARGS} bench: .GOPATH/.ok gitlab-pages - go test -bench=. -run=^$$ $(allpackages) + go test -bench=. -run=^$$ ./... # The acceptance tests cannot count for coverage -cover: gitlab-pages +cover: @echo "NOTE: make cover does not exit 1 on failure, don't use it to check for tests success!" $Q rm -f .GOPATH/cover/test.coverage $Q mkdir -p .GOPATH/cover - $Q go test -short -cover -coverpkg=$(COVERAGE_PACKAGES) -coverprofile=.GOPATH/cover/test.coverage $(allpackages) + $Q go test -short -cover -coverpkg=$(COVERAGE_PACKAGES) -coverprofile=.GOPATH/cover/test.coverage ./... $Q go tool cover -html .GOPATH/cover/test.coverage -o coverage.html @echo "" @echo "=====> Total test coverage: <=====" @echo "" $Q go tool cover -func .GOPATH/cover/test.coverage -list: .GOPATH/.ok - @echo $(allpackages) - deps-check: .GOPATH/.ok go mod tidy @if git diff --color=always --exit-code -- go.mod go.sum; then \ @@ -61,17 +58,12 @@ mocks-check: .GOPATH/.ok generate-mocks deps-download: .GOPATH/.ok go mod download -junit-report: .GOPATH/.ok bin/gotestsum - ./bin/gotestsum --junitfile junit-test-report.xml --format testname - changelog: TOKEN='$(GITLAB_PRIVATE_TOKEN)' VERSION='$(shell cat VERSION)' BRANCH='$(BRANCH)' bash ./.gitlab/scripts/changelog.sh ifndef GITLAB_PRIVATE_TOKEN $(error GITLAB_PRIVATE_TOKEN is undefined) endif -.PHONY: zip - zip: cd $(PWD)/shared/pages/$(PROJECT_SUBDIR)/ && \ zip -r public.zip public/ |