-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (52 loc) · 2.1 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
TEST_POSTGRES_CONTAINER_NAME = nais-api-postgres-integration-test
TEST_POSTGRES_CONTAINER_PORT = 5666
.PHONY: all
all: generate fmt test check build helm-lint
generate: generate-sql generate-graphql generate-proto generate-mocks
generate-sql:
go run github.com/sqlc-dev/sqlc/cmd/sqlc generate -f .configs/sqlc.yaml
go run github.com/sqlc-dev/sqlc/cmd/sqlc vet -f .configs/sqlc.yaml
go run mvdan.cc/gofumpt@latest -w ./internal/database/gensql
generate-graphql:
go run github.com/99designs/gqlgen generate --config .configs/gqlgen.yaml
go run mvdan.cc/gofumpt@latest -w ./internal/graph
generate-mocks:
find internal pkg -type f -name "mock_*.go" -delete
go run github.com/vektra/mockery/v2 --config ./.configs/mockery.yaml
find internal pkg -type f -name "mock_*.go" -exec go run mvdan.cc/gofumpt@latest -w {} \;
generate-proto:
protoc \
-I pkg/protoapi/schema/ \
./pkg/protoapi/schema/*.proto \
--go_out=. \
--go-grpc_out=.
build:
go build -o bin/api ./cmd/api
go build -o bin/setup_local ./cmd/setup_local
local:
env bash -c 'source local.env; go run ./cmd/api'
debug:
env bash -c 'source local.env; dlv debug --headless --listen=:2345 --api-version=2 ./cmd/api'
test:
go test ./...
test-with-cc:
go test -cover --race ./...
check: staticcheck vulncheck deadcode
staticcheck:
go run honnef.co/go/tools/cmd/staticcheck@latest ./...
vulncheck:
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
deadcode:
go run golang.org/x/tools/cmd/deadcode@latest -test ./...
fmt:
go run mvdan.cc/gofumpt@latest -w ./
helm-lint:
helm lint --strict ./charts
setup-local:
GOOGLE_MANAGEMENT_PROJECT_ID=nais-local-dev go run ./cmd/setup_local -users 40 -teams 10 -owners 2 -members 4 -provision_pub_sub
stop-integration-test-db:
docker stop $(TEST_POSTGRES_CONTAINER_NAME) || true && docker rm $(TEST_POSTGRES_CONTAINER_NAME) || true
start-integration-test-db: stop-integration-test-db
docker run -d -e POSTGRES_PASSWORD=postgres --name $(TEST_POSTGRES_CONTAINER_NAME) -p $(TEST_POSTGRES_CONTAINER_PORT):5432 postgres:14-alpine
integration-test: start-integration-test-db
go test ./... -tags=db_integration_test