This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
65 lines (50 loc) · 1.63 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
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GORUN=$(GOCMD) run
PROJECT=circa10a/k8s-label-rules-webhook
BINARY=webhook
VERSION := $(shell grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+" main.go)
GOBUILDFLAGS=-ldflags="-s -w"
test: export GIN_MODE=release
test: export METRICS=true
test:
go test -v | sed '/ERRO/d; /level=error/d; /printer.go/d'
docs:
# Swagger
# https://github.com/swaggo/gin-swagger
swag init -o api
build: docs
$(GOBUILD) $(GOBUILDFLAGS) -o $(BINARY)
run: docs
$(GORUN) . --metrics
compile: docs
GOOS=linux GOARCH=amd64 go build $(GOBUILDFLAGS) -o bin/$(BINARY)-linux-amd64
GOOS=linux GOARCH=arm go build $(GOBUILDFLAGS) -o bin/$(BINARY)-linux-arm
GOOS=linux GOARCH=arm64 go build $(GOBUILDFLAGS) -o bin/$(BINARY)-linux-arm64
GOOS=darwin GOARCH=amd64 go build $(GOBUILDFLAGS) -o bin/$(BINARY)-darwin-amd64
clean:
$(GOCLEAN)
rm -f $(BINARY)
rm -rf ./api/
coverage: export GIN_MODE=release
coverage: export METRICS=true
coverage:
go test -coverprofile=c.out | sed '/ERRO/d; /level=error/d' && go tool cover -html=c.out && rm c.out
docker-build: docs
docker build -t $(PROJECT):$(VERSION) .
docker-run: docs
docker run --rm -v $(shell pwd)/rules.yaml:/rules.yaml \
-p 8080:8080 \
$(PROJECT):$(VERSION) --file rules.yaml --metrics
docker-dev: docker-build docker-run
release: ARCH="linux-amd64"
release: docs
GOOS=linux GOARCH=amd64 go build $(GOBUILDFLAGS) -o $(BINARY)
tar -czf $(BINARY)-$(VERSION)-linux-amd64.tar.gz $(BINARY)
docker-release: docker-build
docker-release: docs
echo "${DOCKER_PASSWORD}" | docker login -u ${USERNAME} --password-stdin
docker push $(PROJECT):$(VERSION)
lint:
golangci-lint run -v