-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
60 lines (46 loc) · 1.42 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
SHELL := /bin/bash
NAME := statuspage-exporter
REPO := quay.io/app-sre/$(NAME)
TAG ?= $(shell git rev-parse --short HEAD)
CONTAINER_ENGINE ?= $(shell which podman >/dev/null 2>&1 && echo podman || echo docker)
PKGS := $(shell go list ./... | grep -v -E '/vendor/|/test')
.PHONY: build
build:
go build -o $(NAME) cmd/statuspage-exporter/main.go
.PHONY: image
image:
ifeq ($(CONTAINER_ENGINE), podman)
DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build --no-cache -t $(REPO):$(TAG) . --progress=plain
else
DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) --config=$(DOCKER_CONF) build --no-cache -t $(REPO):latest . --progress=plain
endif
.PHONY: image
image-latest: image
$(CONTAINER_ENGINE) tag $(REPO):$(TAG) $(REPO):latest
run:
@source env.sh && go run cmd/statuspage-exporter/main.go -page-id $(PAGE_ID)
.PHONY: image-push
image-push:
$(CONTAINER_ENGINE) --config=$(DOCKER_CONF) push $(REPO):$(TAG)
$(CONTAINER_ENGINE) --config=$(DOCKER_CONF) push $(REPO):latest
.PHONY: kube
kube: build
${CONTAINER_ENGINE} kube down exporter.yaml || true
${CONTAINER_ENGINE} kube play exporter.yaml --build=true
.PHONY: clean
clean:
rm -f ./statuspage-exporter
###########
# Testing #
###########
.PHONY: vet
vet:
go vet ./...
.PHONY: test
test: vet test-unit
.PHONY: test-unit
test-unit:
go test -race -short $(PKGS) -count=1
.PHONY: container-test
container-test:
$(CONTAINER_ENGINE) build --target test -t $(REPO):$(TAG) -f Dockerfile .