-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (50 loc) · 1.76 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
projectname?=btc-cirrus-reporter
default: help
.PHONY: help
help: ## list makefile targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: build
build: ## build golang binary
@go build -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags --always)" -o $(projectname)
.PHONY: install
install: ## install golang binary
@go install -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags --always)"
.PHONY: run
run: ## run the app
@go run -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags --always)" main.go
.PHONY: fmtcheck
fmtcheck: ## run gofmt and print detected files
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
PHONY: test
test: ## run go tests
go test -v ./...
PHONY: clean
clean: ## clean up environment
@rm -rf coverage.out dist/ $(projectname)
PHONY: cover
cover: ## display test coverage
go test -v -race $(shell go list ./... | grep -v /vendor/) -v -coverprofile=coverage.out
go tool cover -func=coverage.out
PHONY: fmt
fmt: ## format go files
gofumpt -w .
PHONY: lint
lint: ## lint go files
golangci-lint run -c .golang-ci.yml
PHONY: lint-fix
lint-fix: ## fix
golangci-lint run -c .golang-ci.yml --fix
.PHONY: docker-build
docker-build: ## dockerize golang application
@docker build --tag $(projectname) .
.PHONY: docker-run
docker-run:
@docker run $(projectname)
.PHONY: pre-commit
pre-commit: ## run pre-commit hooks
pre-commit run
postgres:
docker run --rm --name postgres -d --network=host -e POSTGRES_PASSWORD=postgres postgres:13
postgres-restart:
(docker stop postgres || echo) && (docker rm postgres || echo ) && \
docker run --rm --name postgres -d --network=host -e POSTGRES_PASSWORD=postgres postgres:13