-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (56 loc) · 1.9 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
61
62
63
64
65
66
67
68
69
70
71
# Image URL to use all building/pushing image targets
TAG ?= $(shell git describe --tags --abbrev=0 --match '[0-9].*[0-9].*[0-9]' 2>/dev/null )
IMG ?= ghcr.io/banzaicloud/crd-updater:$(TAG)
GOLANGCI_VERSION = 1.41.1
LICENSEI_VERSION = 0.4.0
all: build
.PHONY: check
check: test lint ## Run tests and linters
bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION}
@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
bin/golangci-lint-${GOLANGCI_VERSION}:
@mkdir -p bin
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ./bin v${GOLANGCI_VERSION}
@mv bin/golangci-lint $@
.PHONY: lint
lint: bin/golangci-lint ## Run linter
# "unused" linter is a memory hog, but running it separately keeps it contained (probably because of caching)
bin/golangci-lint run --disable=unused && bin/golangci-lint run
.PHONY: lint-fix
lint-fix: bin/golangci-lint ## Run linter
# "unused" linter is a memory hog, but running it separately keeps it contained (probably because of caching)
bin/golangci-lint run --disable=unused --fix && bin/golangci-lint run --fix
bin/licensei: bin/licensei-${LICENSEI_VERSION}
@ln -sf licensei-${LICENSEI_VERSION} bin/licensei
bin/licensei-${LICENSEI_VERSION}:
@mkdir -p bin
curl -sfL https://raw.githubusercontent.com/goph/licensei/master/install.sh | bash -s v${LICENSEI_VERSION}
@mv bin/licensei $@
.PHONY: license-check
license-check: bin/licensei ## Run license check
bin/licensei check
bin/licensei header
.PHONY: license-cache
license-cache: bin/licensei ## Generate license cache
bin/licensei cache
.PHONY: test
# Run tests
test: fmt vet
.PHONY: tidy
tidy:
go mod tidy
.PHONY: build
build: tidy fmt vet
go build -o bin/crd-updater main.go
.PHONY: fmt
# Run go fmt against code
fmt:
go fmt ./...
.PHONY: vet
# Run go vet against code
vet:
go vet ./...
.PHONY: docker-build
# Build the docker image
docker-build:
docker build . -t ${IMG}