-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (67 loc) · 2.38 KB
/
Copy pathMakefile
File metadata and controls
85 lines (67 loc) · 2.38 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
79
80
81
82
83
84
85
# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
NAME := application-load-balancer-controller
export REPO := ghcr.io/stackitcloud
VERSION ?= $(shell git describe --dirty --tags --match='v*' 2>/dev/null || git rev-parse --short HEAD)
export TAG := $(VERSION)
IS_DEV ?= true
ifeq ($(IS_DEV),true)
REPO_POSTFIX := dev
endif
.PHONY: all
all: verify
##@ Tools
include ./hack/tools.mk
export PUSH ?= false
.PHONY: images
images: $(KO)
KO_DOCKER_REPO=$(REPO)/$(NAME)-$(REPO_POSTFIX) $(KO) build --push=$(PUSH) \
--image-label org.opencontainers.image.source="https://github.com/stackitcloud/application-load-balancer-controller" \
--sbom none -t $(TAG) --bare \
--platform linux/amd64,linux/arm64 \
./cmd/$(NAME)
.PHONY: clean-tools-bin
clean-tools-bin: ## Empty the tools binary directory.
rm -rf $(TOOLS_BIN_DIR)/* $(TOOLS_BIN_DIR)/.version_*
.PHONY: fmt
fmt: $(GOIMPORTS_REVISER) ## Run go fmt against code.
go fmt ./...
$(GOIMPORTS_REVISER) .
.PHONY: modules
modules: ## Runs go mod to ensure modules are up to date.
go mod tidy
.PHONY: test
test: ## Run tests.
./hack/test.sh ./cmd/... ./pkg/...
.PHONY: test-cover
test-cover: ## Run tests with coverage.
go test -coverprofile cover.out ./...
go tool cover -html cover.out -o cover.html
##@ Verification
.PHONY: lint
lint: $(GOLANGCI_LINT) ## Run golangci-lint against code.
$(GOLANGCI_LINT) run ./...
.PHONY: check
check: lint test ## Check everything (lint + test).
.PHONY: verify-fmt
verify-fmt: fmt ## Verify go code is formatted.
@if !(git diff --quiet HEAD); then \
echo "unformatted files detected, please run 'make fmt'"; exit 1; \
fi
.PHONY: verify-modules
verify-modules: modules ## Verify go module files are up to date.
@if !(git diff --quiet HEAD -- go.sum go.mod); then \
echo "go module files are out of date, please run 'make modules'"; exit 1; \
fi
.PHONY: verify-generate
verify-generate: generate ## Verify go module files are up to date.
@if !(git diff --quiet HEAD); then \
echo "generate created a diff, please run 'make generate'"; exit 1; \
fi
.PHONY: verify
verify: verify-fmt verify-modules verify-generate check
.PHONY: generate
generate:
go generate ./...