forked from prometheus-community/jiralert
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (62 loc) · 2.17 KB
/
Makefile
File metadata and controls
78 lines (62 loc) · 2.17 KB
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
69
70
71
72
73
74
75
76
77
78
GO := go
GOBIN ?= ${GOPATH}/bin
STATICCHECK := $(GOBIN)/staticcheck
VERSION := $(shell git describe --tags 2>/dev/null)
ifeq "$(VERSION)" ""
VERSION := $(shell git rev-parse --short HEAD)
endif
RELEASE := jiralert-$(VERSION).linux-amd64
RELEASE_DIR := release/$(RELEASE)
PACKAGES := $(shell $(GO) list ./... | grep -v /vendor/)
DOCKER_IMAGE_NAME := jiralert
# v1.2.0
ERRCHECK_VERSION ?= e14f8d59a22d460d56c5ee92507cd94c78fbf274
ERRCHECK ?= $(GOBIN)/errcheck-$(ERRCHECK_VERSION)
all: check-go-mod clean format check errcheck build test
clean:
@rm -rf jiralert release
format:
@echo ">> formatting code"
@$(GO) fmt $(PACKAGES)
check: $(STATICCHECK)
@echo ">> running staticcheck"
@$(STATICCHECK) $(PACKAGES)
build:
@echo ">> building binaries"
@# CGO must be disabled to run in busybox container.
@GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -ldflags "-X main.Version=$(VERSION)" github.com/free/jiralert/cmd/jiralert
# docker builds docker with no tag.
docker: build
@echo ">> building docker image '${DOCKER_IMAGE_NAME}'"
@docker build -t "${DOCKER_IMAGE_NAME}" .
tarball:
@echo ">> packaging release $(VERSION)"
@rm -rf "$(RELEASE_DIR)/*"
@mkdir -p "$(RELEASE_DIR)"
@cp jiralert README.md LICENSE "$(RELEASE_DIR)"
@mkdir -p "$(RELEASE_WDIR)/config"
@cp config/* "$(RELEASE_DIR)/config"
@tar -zcvf "$(RELEASE).tar.gz" -C "$(RELEASE_DIR)"/.. "$(RELEASE)"
@rm -rf "$(RELEASE_DIR)"
.PHONY: check-go-mod
check-go-mod:
@go mod verify
# errcheck performs static analysis and returns error if any of the errors is not checked.
.PHONY: errcheck
errcheck: $(ERRCHECK)
@echo ">> errchecking the code"
$(ERRCHECK) -verbose -exclude .errcheck_excludes.txt ./cmd/... ./pkg/...
.PHONY: test
test:
@echo ">> running all tests."
@go test $(shell go list ./... | grep -v /vendor/);
$(ERRCHECK):
@go get github.com/kisielk/errcheck@$(ERRCHECK_VERSION)
@mv $(GOBIN)/errcheck $(ERRCHECK)
@go mod tidy
$(STATICCHECK):
ifeq ($(GOBIN),)
@echo >&2 "GOBIN environment variable is not defined, where to put installed binaries?"; exit 1
endif
@echo ">> getting staticcheck"
@GO111MODULE=on GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck