-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
61 lines (48 loc) · 1.71 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
all: lint test
PHONY: test coverage lint golint clean vendor local-dev-databases docker-up docker-down integration-test unit-test
GOOS=linux
DB_STRING=host=localhost port=26257 user=root sslmode=disable
DB=dns_controller
DEV_DB=${DB}
TEST_DB=${DB}_test
DEV_URI=dbname=${DEV_DB} ${DB_STRING}
TEST_URI=dbname=${TEST_DB} ${DB_STRING}
test: | unit-test integration-test
integration-test: test-database
@echo Running integration tests...
@DNSCONTROLLER_DB_URI="${TEST_URI}" go test -cover -tags testtools,integration -p 1 ./...
unit-test: | lint
@echo Running unit tests...
@go test -cover -short -tags testtools ./...
coverage: | test-database
@echo Generating coverage report...
@DNSCONTROLLER_DB_URI="${TEST_URI}" go test ./... -race -coverprofile=coverage.out -covermode=atomic -tags testtools -p 1
@go tool cover -func=coverage.out
@go tool cover -html=coverage.out
lint: golint
golint: | vendor
@echo Linting Go files...
@golangci-lint run
clean: docker-clean
@echo Cleaning...
@rm -rf ./dist/
@rm -rf coverage.out
@go clean -testcache
vendor:
@go mod download
@go mod tidy
docker-up:
@docker-compose -f quickstart.yml up -d crdb
docker-down:
@docker-compose -f quickstart.yml down
docker-clean:
@docker-compose -f quickstart.yml down --volumes
dev-database: | vendor
@cockroach sql --insecure -e "drop database if exists ${DEV_DB}"
@cockroach sql --insecure -e "create database ${DEV_DB}"
@DNSCONTROLLER_DB_URI="${DEV_URI}" go run main.go migrate up
test-database: | vendor
@cockroach sql --insecure -e "drop database if exists ${TEST_DB}"
@cockroach sql --insecure -e "create database ${TEST_DB}"
@DNSCONTROLLER_DB_URI="${TEST_URI}" go run main.go migrate up
@cockroach sql --insecure -e "use ${TEST_DB};"