-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
58 lines (43 loc) · 1.79 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
.PHONY: build push gotest gobuild govet coveragereport generate test-schema validate-schema
CONTAINER_ENGINE ?= $(shell which podman >/dev/null 2>&1 && echo podman || echo docker)
IMAGE_NAME := quay.io/app-sre/go-qontract-reconcile
IMAGE_TAG := $(shell git rev-parse --short=7 HEAD)
ifneq (,$(wildcard $(CURDIR)/.docker))
DOCKER_CONF := $(CURDIR)/.docker
else
DOCKER_CONF := $(HOME)/.docker
endif
GOOS := $(shell go env GOOS)
TMP_COVERAGE := $(shell mktemp)
golint:
go install github.com/mgechev/[email protected]
go run github.com/mgechev/[email protected] -config revive.toml -set_exit_status ./...
gotest:
CGO_ENABLED=0 GOOS=$(GOOS) go test ./...
govet: gotest
go vet ./...
gobuild: govet
CGO_ENABLED=0 GOOS=$(GOOS) go build -o go-qontract-reconcile -a ./main.go
build:
ifeq ($(CONTAINER_ENGINE), podman)
@DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build --no-cache -t $(IMAGE_NAME):latest . --progress=plain
else
@DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) --config=$(DOCKER_CONF) build --no-cache -t $(IMAGE_NAME):latest . --progress=plain
endif
@$(CONTAINER_ENGINE) tag $(IMAGE_NAME):latest $(IMAGE_NAME):$(IMAGE_TAG)
validate:
ifeq ($(CONTAINER_ENGINE), podman)
@DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) build --rm --no-cache -t $(IMAGE_NAME):validate -f Dockerfile . --progress=plain --target builder
else
@DOCKER_BUILDKIT=1 $(CONTAINER_ENGINE) --config=$(DOCKER_CONF) build --rm --no-cache -t $(IMAGE_NAME):validate -f Dockerfile . --progress=plain --target builder
endif
push:
@$(CONTAINER_ENGINE) --config=$(DOCKER_CONF) push $(IMAGE_NAME):latest
@$(CONTAINER_ENGINE) --config=$(DOCKER_CONF) push $(IMAGE_NAME):$(IMAGE_TAG)
coveragereport:
go test -coverprofile=$(TMP_COVERAGE) ./...
go tool cover -html=$(TMP_COVERAGE) -o coverage.html
update-schema:
./hack/update_schema.sh
generate:
go generate ./...