-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
51 lines (36 loc) · 1.66 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
.PHONY: generate fmt lint test build build-debug pull-parent-image image push deploy
MAKEFILE_PATH=$(shell readlink -f "${0}")
MAKEFILE_DIR=$(shell dirname "${MAKEFILE_PATH}")
version=$(shell grep 'image: ewohltman/ephemeral-roles:' deployments/kubernetes/statefulset.yml | awk -F: '{print $$3}')
parentImage=alpine:latest
protocDirectory=internal/pkg/distributed/api
protocArgumentsIncludes=-I ${protocDirectory}
protocArgumentsGo=--go_out=${protocDirectory} --go_opt=paths=source_relative
protocArgumentsGoGRPC=--go-grpc_out=${protocDirectory} --go-grpc_opt=paths=source_relative
protocArguments=${protocArgumentsIncludes} ${protocArgumentsGo} ${protocArgumentsGoGRPC}
generate:
protoc ${protocArguments} ${protocDirectory}/api.proto
fmt:
gofmt -s -w . && goimports -local github.com/ewohltman/ephemeral-roles -w . && go mod tidy
lint: fmt
golangci-lint run ./...
test:
go test -v -race -coverprofile=coverage.out ./...
@echo "all tests passed"
test-report:
@make test | grep -A 1 'coverage: '
build:
CGO_ENABLED=0 go build -o build/package/ephemeral-roles/ephemeral-roles cmd/ephemeral-roles/ephemeral-roles.go
build-debug:
CGO_ENABLED=0 go build -gcflags "all=-N -l" -o build/package/ephemeral-roles-debug/ephemeral-roles-debug cmd/ephemeral-roles/ephemeral-roles.go
pull-parent-image:
docker pull ${parentImage}
image: pull-parent-image
docker image build -t ewohltman/ephemeral-roles:${version} build/package/ephemeral-roles
push:
docker login -u ${DOCKER_USER} -p ${DOCKER_PASS}
docker push ewohltman/ephemeral-roles:${version}
docker tag ewohltman/ephemeral-roles:${version} ewohltman/ephemeral-roles:latest
docker logout
deploy:
${MAKEFILE_DIR}/scripts/deploy.sh