-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
70 lines (56 loc) · 2.14 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
API_URL = http://localhost:3000
CUR_DIR = $(shell echo "${PWD}")
.PHONY: unit-tests integration-tests coverage format clean mocks remove-mocks lint
build-GetBooksFunction:
@echo "Building GetBooksFunction"
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o get-books github.com/rotiroti/alessandrina/functions/get-books/
mv get-books $(ARTIFACTS_DIR)
@echo "Built GetBooksFunction successfully"
build-GetBookFunction:
@echo "Building GetBookFunction"
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o get-book github.com/rotiroti/alessandrina/functions/get-book/
mv get-book $(ARTIFACTS_DIR)
@echo "Built GetBookFunction successfully"
build-CreateBookFunction:
@echo "Building CreateBookFunction"
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o create-book github.com/rotiroti/alessandrina/functions/create-book/
mv create-book $(ARTIFACTS_DIR)
@echo "Built CreateBookFunction successfully"
build-DeleteBookFunction:
@echo "Building DeleteBookFunction"
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o delete-book github.com/rotiroti/alessandrina/functions/delete-book/
mv delete-book $(ARTIFACTS_DIR)
@echo "Built DeleteBookFunction successfully"
build-k6:
@echo "Building k6 tool"
go install go.k6.io/xk6/cmd/xk6@latest
xk6 build --with github.com/grafana/[email protected]
@echo "Built k6 successfully"
format:
@echo "Format code"
go fmt ./...
lint:
@echo "Run linting"
@docker run -t --rm -v ${CUR_DIR}:/app -w /app golangci/golangci-lint:v1.53 golangci-lint run --fix -v
unit-tests:
@echo "Run unit tests"
go test -v -race -coverprofile=coverage.out -covermode=atomic $$(go list ./... | grep -v /functions/ | grep -v /tests/)
coverage: unit-tests
@echo "Run unit tests and create HTML coverage report"
go tool cover -html=coverage.out -o coverage.html
integration-tests:
@echo "Run integration tests"
API_URL=${API_URL} INTEGRATION=1 go test -count=1 -v -race ./tests/...
mocks:
@echo "Generate mocks"
docker run --rm -v ${CUR_DIR}:/app -w /app vektra/mockery --all
remove-mocks:
@echo "Clean up mocks"
find . -name 'mock_*.go' | xargs rm
rm -fr mocks/
clean:
@echo "Clean up"
rm -f *.html
rm -f *.out
rm -fr .aws-sam
rm -f ./k6