-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
51 lines (41 loc) · 1.07 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
IMAGE ?= quay.io/skhoury/kube-carbon-footprint
VERSION ?= v0.0.1
GOLANGCI_LINT_VERSION = v1.42.1
COVERPROFILE = coverage.out
ifeq (,$(shell which podman 2>/dev/null))
OCI_BIN ?= docker
else
OCI_BIN ?= podman
endif
.PHONY: prereqs
prereqs:
@echo "### Test if prerequisites are met, and installing missing dependencies"
test -f $(go env GOPATH)/bin/golangci-lint || go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
.PHONY: vendors
vendors:
@echo "### Checking vendors"
go mod tidy && go mod vendor
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: lint
lint: prereqs
@echo "### Linting code"
golangci-lint run ./...
.PHONY: test
test:
@echo "### Testing"
go test ./... -coverprofile ${COVERPROFILE}
.PHONY: verify
verify: lint test
.PHONY: build
build:
@echo "### Building"
go build -mod vendor -o kube-carbon-footprint cmd/kube-carbon-footprint.go
.PHONY: image
image:
@echo "### Building image with ${OCI_BIN}"
$(OCI_BIN) build --build-arg VERSION="$(VERSION)" -t $(IMAGE):$(VERSION) .
.PHONY: push
push:
$(OCI_BIN) push $(IMAGE):$(VERSION)