-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
92 lines (69 loc) · 2.32 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
85
86
87
88
89
90
91
92
.PHONY: all help setup vet lint deadcode vulncheck tests integration-tests all-tests cover sonarqube-up sonarqube-down sonarqube-analysis fmt compose-ps compose-up compose-down build build-run-api clean doc
APP_NAME=crawler_app
## help: show this help.
help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
## setup: run the command mod download and tidy from Go
setup:
GO111MODULE=on go mod download
go mod tidy
go mod verify
## vet: run the command vet from Go
vet:
go vet ./...
## lint: run all linters configured
lint:
golangci-lint run ./...
## deadcode: run command to look for deadcode
deadcode:
deadcode .
## vulncheck: run all vulnerability checks
vulncheck:
govulncheck ./...
## tests: run all unit tests
tests:
go test -race -coverprofile coverage.out ./... -short=true -count=1
## integration-tests: run all integration tests
integration-tests:
go test -race ./... -run Integration -count=1
## all-tests: run all unit and integration tests
all-tests:
go test -race -coverprofile coverage.out ./... -count=1
## cover: run the command tool cover to open coverage file as HTML
cover: all-tests
go tool cover -html coverage.out
## sonarqube-up: start sonarqube container
sonarqube-up:
docker run -d --name sonarqube -p ${SONAR_PORT}:${SONAR_PORT} sonarqube
## sonarqube-down: stop sonarqube container
sonarqube-down:
docker rm sonarqube -f
## sonarqube-analysis: run sonar scanner
sonarqube-analysis: all-tests
${SONAR_BINARY} -Dsonar.host.url=${SONAR_HOST} -Dsonar.login=${SONAR_LOGIN} -Dsonar.password=${SONAR_PASSWORD}
## fmt: run go formatter recursively on all files
fmt:
gofmt -s -w .
## compose-ps: list all containers running
compose-ps:
docker compose -f build/docker-compose.yml ps
## compose-up: start API and dependencies
compose-up:
docker compose -f build/docker-compose.yml up -d
## compose-down: stop API and dependencies
compose-down:
docker compose -f build/docker-compose.yml down
## build: create an executable of the application
build:
go build -o ${APP_NAME} .
## build-run-api: build project and run the API using the built binary
build-run-api: build
./${APP_NAME} api
## clean: run the go clean command and removes the application binary
clean:
go clean
rm ${APP_NAME}
## doc: run the project documentation using HTTP
doc:
godoc -http=:6060
all: help