-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (50 loc) · 1.65 KB
/
Makefile
File metadata and controls
59 lines (50 loc) · 1.65 KB
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
export PATH := $(abspath ./vendor/bin):$(PATH)
K8S_DEPLOYMENT_FILE = kubernetes/application/deployment.yaml
IMAGE_NAME = ghcr.io/counterapi/counterapi
BASE_PACKAGE_NAME = github.com/counterapi/api
GIT_VERSION = $(shell git describe --tags --always 2> /dev/null || echo 0.0.0)
LDFLAGS = -ldflags "-X $(BASE_PACKAGE_NAME)/pkg/info.Version=$(GIT_VERSION)"
BUFFER := $(shell mktemp)
REPORT_DIR = dist/report
COVER_PROFILE = $(REPORT_DIR)/coverage.out
BINARY_NAME = dist/counterapi
.PHONY: build
build:
CGO_ENABLED=0 GOOS="$(TARGETOS)" GOARCH="$(TARGETARCH)" go build $(LDFLAGS) -a -installsuffix cgo -o $(BINARY_NAME) main.go
.PHONY: lint
lint:
@echo "Checking code style"
gofmt -l . | tee $(BUFFER)
@! test -s $(BUFFER)
go vet ./...
golangci-lint run
.PHONY: test
test:
@echo "Running unit tests"
mkdir -p $(REPORT_DIR)
go test -covermode=count -coverprofile=$(COVER_PROFILE) -tags test -failfast ./...
go tool cover -html=$(COVER_PROFILE) -o $(REPORT_DIR)/coverage.html
.PHONY: cut-tag
cut-tag:
@echo "Cutting $(version)"
git tag $(version)
git push origin $(version)
.PHONY: release
release: build-for-container
@echo "Releasing $(GIT_VERSION)"
docker build -t counter .
docker tag counter:latest counterapi/counterapi:$(GIT_VERSION)
docker push counterapi/counter:$(GIT_VERSION)
.PHONY: dev
dev:
docker compose up --build
.PHONY: dev-db
dev-db:
docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=root -d postgres
.PHONY: set-db-variables
set-db-variables:
export DB_HOST=localhost
export DB_PORT=5432
export DB_USER=postgres
export DB_NAME=counter_api
export DB_PASSWORD=root