-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (63 loc) · 2.18 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
72
73
74
75
76
77
78
79
SERVICE_NAME=server-monitor
NAMESPACE=cobden
GIT_COMMIT=`git rev-parse --short HEAD`
-include .env
export
.PHONY: setup
setup: ## Get linting stuffs
go install github.com/golangci/golangci-lint/cmd/golangci-lint
go install golang.org/x/tools/cmd/goimports
go install google.golang.org/protobuf/cmd/protoc-gen-go
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
.PHONY: build-images
build-images: ## Build the images
nerdctl build --platform=amd64,arm64 --tag containers.chewed-k8s.net/${NAMESPACE}/${SERVICE_NAME}:${GIT_COMMIT} --build-arg VERSION=0.1 --build-arg BUILD=${GIT_COMMIT} --build-arg SERVICE_NAME=${SERVICE_NAME} -f ./k8s/Containerfile .
nerdctl tag containers.chewed-k8s.net/${NAMESPACE}/${SERVICE_NAME}:${GIT_COMMIT} containers.chewed-k8s.net/${NAMESPACE}/${SERVICE_NAME}:latest
.PHONY: publish-images
publish-images:
nerdctl push containers.chewed-k8s.net/${NAMESPACE}/${SERVICE_NAME}:${GIT_COMMIT} --all-platforms
nerdctl push containers.chewed-k8s.net/${NAMESPACE}/${SERVICE_NAME}:latest --all-platforms
.PHONY: build
build: build-images
.PHONY: build-publish
build-publish: build publish-images
.PHONY: deploy
deploy:
curl -X POST 'http://cob.cobden.net:9000/api/webhooks/e10ea4a7-f3c4-416e-af0d-9ae7dc82e7fb'
.PHONY: deploy-latest
deploy-latest:
kubectl set image deployment/${SERVICE_NAME} ${SERVICE_NAME}=containers.chewed-k8s.net/${NAMESPACE}/${SERVICE_NAME}:latest --namespace=${NAMESPACE}
.PHONY: build-deploy
build-deploy: build publish-images deploy
.PHONY: lint-build-deploy
lint-build-deploy: lint build publish-images deploy
.PHONY: test
test: lint ## Test the app
go test \
-v \
-race \
-bench=./... \
-benchmem \
-timeout=120s \
-cover \
-coverprofile=./test_coverage.txt \
-bench=./... ./...
.PHONY: mocks
mocks: ## Generate the mocks
go generate ./...
.PHONY: full
full: clean build fmt lint test ## Clean, build, make sure its formatted, linted, and test it
.PHONY: lint
lint: ## Lint
golangci-lint run --config ./golangci.yml
.PHONY: fmt
fmt: ## Formatting
gofmt -w -s .
goimports -w .
go clean ./...
.PHONY: pre-commit
pre-commit: fmt lint ## Do formatting and linting
.PHONY: clean
clean: ## Clean
go clean ./...
rm -rf bin/${SERVICE_NAME}