-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
68 lines (50 loc) · 1.51 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
## Settings
# Build Settings
GOOS=linux
# Utility settings
TOOLS_DIR := .tools
GOLANGCI_LINT_VERSION = v1.55.2
# Container build settings
CONTAINER_BUILD_CMD?=docker build
# Container settings
CONTAINER_REPO?=ghcr.io/metal-toolbox
AUDITTAIL_CONTAINER_IMAGE_NAME = $(CONTAINER_REPO)/audittail
CONTAINER_TAG?=latest
## Targets
all: lint test
PHONY: test coverage lint golint clean vendor
.PHONY: test coverage lint golint vendor clean image audittail-image
test: | lint
@echo Running unit tests...
@go test -timeout 30s -cover -short -tags testtools ./...
coverage:
@echo Generating coverage report...
@go test -timeout 30s -tags testtools ./... -race -coverprofile=coverage.out -covermode=atomic
@go tool cover -func=coverage.out
@go tool cover -html=coverage.out
lint: golint
golint: | vendor $(TOOLS_DIR)/golangci-lint
@echo Linting Go files...
@$(TOOLS_DIR)/golangci-lint run
clean:
@echo Cleaning...
@rm -rf coverage.out
@go clean -testcache
@rm -r $(TOOLS_DIR)
vendor:
@go mod download
@go mod tidy
image: audittail-image
audittail-image:
$(CONTAINER_BUILD_CMD) -f images/audittail/Dockerfile . -t $(AUDITTAIL_CONTAINER_IMAGE_NAME):$(CONTAINER_TAG)
# Tools setup
$(TOOLS_DIR):
mkdir -p $(TOOLS_DIR)
$(TOOLS_DIR)/golangci-lint: $(TOOLS_DIR)
export \
VERSION=$(GOLANGCI_LINT_VERSION) \
URL=https://raw.githubusercontent.com/golangci/golangci-lint \
BINDIR=$(TOOLS_DIR) && \
curl -sfL $$URL/$$VERSION/install.sh | sh -s $$VERSION
$(TOOLS_DIR)/golangci-lint version
$(TOOLS_DIR)/golangci-lint linters