-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
67 lines (52 loc) · 1.86 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
APP ?= spot-assistant-bot
TAG ?= $(shell git rev-parse --short HEAD)
REGISTRY ?= registry.marahin.pl
.PHONY: install-dependencies install-bins go-mod
install-bins:
@go install github.com/fzipp/gocyclo/cmd/gocyclo@v0.6.0
@go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.26.0
go-mod:
@echo "INFO: Running go mod tidy"
@go mod tidy
install-dependencies: install-bins go-mod
@echo "INFO: Downloading dependencies"
docker:
@echo "INFO: Building Docker image"
@docker build -t "${REGISTRY}/${APP}:${TAG}" -f Dockerfile .
push-to-registry:
@docker push "${REGISTRY}/${APP}:${TAG}"
@echo "INFO: Pushed ${REGISTRY}/${APP}:${TAG}"
sqlc-diff:
@echo "INFO: Running sqlc diff"
@sqlc diff -f internal/infrastructure/reservation/postgresql/sqlc.yaml
@sqlc diff -f internal/infrastructure/spot/postgresql/sqlc.yaml
test: install-dependencies sqlc-diff go-vet gocyclo
@echo "INFO: Running tests"
@go test -cover -race -coverprofile=coverage.out ./...
test-coverage: test
@echo "INFO: Generating test coverage report"
@go tool cover -html=coverage.out
go-vet:
@echo "INFO: Running go vet"
@go vet ./...
gocyclo:
@echo "INFO: Running gocyclo"
@output=$$(gocyclo -over 15 .) ; \
if [ $$? -ne 0 ]; then \
echo "Gocyclo complexity complaints: "; \
echo $$output; \
exit 1; \
fi
sqlc-generate:
@echo "INFO: Generating sqlc"
@sqlc generate -f internal/infrastructure/reservation/postgresql/sqlc.yaml
@sqlc generate -f internal/infrastructure/spot/postgresql/sqlc.yaml
sqlc-vet:
@echo "INFO: Running sqlc vet"
@sqlc vet -f internal/infrastructure/reservation/postgresql/sqlc.yaml
@sqlc vet -f internal/infrastructure/spot/postgresql/sqlc.yaml
build: install-dependencies sqlc-generate test
@make build-only
build-only:
@echo "INFO: Building version: ${TAG}"
@CGO_ENABLED=0 go build -o ./bin/${APP} -ldflags="-X spot-assistant/internal/common/version.Version=${TAG}" cmd/main.go