| 1 |
# vim: ts=4 sw=4 ft=make |
| 2 |
|
| 3 |
MAKEFILE_PATH := $(realpath $(lastword $(MAKEFILE_LIST))) |
| 4 |
MAKEFILE_DIR := $(abspath $(dir $(MAKEFILE_PATH))) |
| 5 |
|
| 6 |
# Run tests and linters. If this passes then CI tests |
| 7 |
# should also pass. |
| 8 |
.PHONY: all |
| 9 |
all: test lint |
| 10 |
|
| 11 |
# Common variables |
| 12 |
include $(MAKEFILE_DIR)/../../common.mk |
| 13 |
|
| 14 |
# # Run tests an |
| 15 |
# Run verbose tests |
| 16 |
testverbose: override GO_TEST_FLAGS += -v |
| 17 |
|
| 18 |
# Run verbose tests |
| 19 |
testrace: override GO_COVER_FLAGS = |
| 20 |
testrace: override GO_TEST_FLAGS += -race |
| 21 |
|
| 22 |
.PHONY: test testverbose testrace |
| 23 |
test testverbose testrace: |
| 24 |
@GOGC=$(GO_GOGC) $(GO_TEST) ./... |
| 25 |
|
| 26 |
# Actual ci target (separate because so that we can override GO) |
| 27 |
.PHONY: .ci |
| 28 |
.ci: GO = $(RICHGO_TARGET) |
| 29 |
.ci: export RICHGO_FORCE_COLOR=1 |
| 30 |
.ci: testverbose |
| 31 |
|
| 32 |
# Run and colorize verbose tests for CI |
| 33 |
.PHONY: ci |
| 34 |
ci: bin/richgo |
| 35 |
ci: .ci |
| 36 |
|
| 37 |
# Run golangci-lint |
| 38 |
.PHONY: golangci-lint |
| 39 |
golangci-lint: bin/golangci-lint |
| 40 |
@$(GOLANGCI_TARGET) run |
| 41 |
|
| 42 |
.PHONY: vet |
| 43 |
vet: |
| 44 |
@$(GO) vet ./... |
| 45 |
|
| 46 |
.PHONY: lint |
| 47 |
lint: vet golangci-lint |
| 48 |
|
| 49 |
# Make sure there aren't any comments that need addressing (TODO or WARN) |
| 50 |
# |
| 51 |
# NOTE: not currently part of the "lint" target. |
| 52 |
.PHONY: lint-comments |
| 53 |
lint-comments: |
| 54 |
@if $(xgrep) $(GREP_COMMENTS) $(COMMENTS); then \ |
| 55 |
echo ''; \ |
| 56 |
echo '$(red)FAIL: $(cyan)address comments!$(term-reset)'; \ |
| 57 |
exit 1; \ |
| 58 |
fi |
| 59 |
|
| 60 |
.PHONY: clean |
| 61 |
clean: |
| 62 |
@$(GO) clean -i ./... |