-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
62 lines (48 loc) · 2.12 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
.PHONY: zip terraform localstack test test-integration lint gofumpt gci ci-init ci-test ci-test-integration
zip:
@CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o bootstrap ./cmd/api
@zip infra/terraform/bootstrap.zip bootstrap
@rm bootstrap
terraform:
@tflocal -chdir=infra/terraform init
@tflocal -chdir=infra/terraform apply --auto-approve
localstack:
@docker compose build
@docker compose up -d
test:
@mkdir -p reports
@go test -coverprofile=reports/codecoverage_all.cov ./... -cover -race -p=4
@go tool cover -func=reports/codecoverage_all.cov > reports/functioncoverage.out
@go tool cover -html=reports/codecoverage_all.cov -o reports/coverage.html
@echo "View report at $(PWD)/reports/coverage.html"
@tail -n 1 reports/functioncoverage.out
test-integration: | zip
@mkdir -p reports
@go test -coverprofile=reports/codecoverage_all.cov ./... --tags=integration -cover -race -p=4 -v
@go tool cover -func=reports/codecoverage_all.cov > reports/functioncoverage.out
@go tool cover -html=reports/codecoverage_all.cov -o reports/coverage.html
@echo "View report at $(PWD)/reports/coverage.html"
@tail -n 1 reports/functioncoverage.out
$(GOBIN)/golangci-lint:
@go install github.com/golangci/golangci-lint/cmd/[email protected]
lint: | $(GOBIN)/golangci-lint
@echo Linting...
@golangci-lint -v --concurrency=3 --config=.golangci.yml --issues-exit-code=1 run \
--out-format=colored-line-number
$(GOBIN)/gofumpt:
@go install mvdan.cc/gofumpt@latest
@go mod tidy
gofumpt: | $(GOBIN)/gofumpt
@gofumpt -w $(shell ls -d $(PWD)/*/)
$(GOBIN)/gci:
@go install github.com/daixiang0/gci@latest
@go mod tidy
gci: | $(GOBIN)/gci
@gci write --section Standard --section Default --section "Prefix(github.com/wimspaargaren/go-lambda-localstack-example)" $(shell ls -d $(PWD)/*)
# Debug: @docker build -t localstack-lambda-ci --progress=plain . #debug docker build
ci-init: | zip
@docker build -t localstack-lambda-ci .
ci-test:
@docker run localstack-lambda-ci go test ./...
ci-test-integration:
@docker run --network=host -v "/var/run/docker.sock:/var/run/docker.sock:rw" localstack-lambda-ci go test --tags=integration -v ./...