-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
84 lines (58 loc) · 2.25 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
80
81
82
83
84
export APP=matrix-on-call-bot
export DSN="mysql://on-call:secret@tcp(localhost:33060)/on-call?readTimeout=3s&timeout=30s&parseTime=True"
all: format lint build
run-server:
go run ./cmd/matrix-on-call-bot server
build:
go build ./cmd/matrix-on-call-bot
mod:
go mod download
build-linux:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -o matrix-on-call-bot ./cmd/matrix-on-call-bot
install:
go install ./cmd/matrix-on-call-bot
############################################################
# Format and Lint
############################################################
check-formatter:
which goimports || go install golang.org/x/tools/cmd/goimports
which gofumpt || go install mvdan.cc/gofumpt
format: check-formatter
find . -type f -name "*.go" -not -path "./vendor/*" | xargs -n 1 -I R goimports -w R
find . -type f -name "*.go" -not -path "./vendor/*" | xargs -n 1 -I R gofumpt -w R
check-linter:
which golangci-lint || go install github.com/golangci/golangci-lint/cmd/[email protected]
lint: check-linter
golangci-lint run ./...
lint-result: check-linter
golangci-lint run ./... && echo "Lint Success ✅" || echo "Lint Failure ❌"
############################################################
# Test
############################################################
test:
go test -v -race -p 1 `go list ./... | grep -v integration`
ci-test:
go test -v -race -p 1 -coverprofile=coverage.txt -covermode=atomic ./...
go tool cover -func coverage.txt
integration-tests:
go test -v -race -p 1 `go list ./... | grep integration`
############################################################
# Migrations
############################################################
migrate-create:
migrate create -ext sql -dir ./migrations $(NAME)
migrate-up:
migrate -verbose -path ./migrations -database $(DSN) up
migrate-down:
migrate -path ./migrations -database $(DSN) down
migrate-reset:
migrate -path ./migrations -database $(DSN) drop
migrate-install:
which migrate || GO111MODULE=off go get -tags 'mysql' -v -u github.com/golang-migrate/migrate/cmd/migrate
############################################################
# Development Environment
############################################################
up:
docker-compose up
down:
docker-compose down