-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (50 loc) · 2.01 KB
/
Makefile
File metadata and controls
64 lines (50 loc) · 2.01 KB
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
SERVICE_NAME = extauthz
K3D_CLUSTER_NAME = extauthz
.PHONY: build
build: clean
go build -o $(SERVICE_NAME) ./cmd/$(SERVICE_NAME)
sha256sum $(SERVICE_NAME)
.PHONY: clean
clean:
rm -f cover.out cover.html $(SERVICE_NAME)
rm -rf cover/
.PHONY: lint
lint:
golangci-lint run -v --fix ./...
.PHONY: test
test: clean install-gotestsum
@mkdir -p cover/integration cover/unit
@go clean -testcache
gotestsum --junitfile="${CURDIR}/junit-unit.xml" --format=testname -- -count=1 -race -cover ./... -args -test.gocoverdir="${CURDIR}/cover/unit"
GOCOVERDIR="${CURDIR}/cover/integration" gotestsum --junitfile="${CURDIR}/junit-integration.xml" --format=testname -- -v -count=1 -race --tags=integration ./integration
@go tool covdata textfmt -i=./cover/unit,./cover/integration -o cover.out
@go tool cover -func=cover.out
@echo "On a Mac, you can use the following command to open the coverage report in the browser\ngo tool cover -html=cover.out -o cover.html && open cover.html"
.PHONY: install-gotestsum
install-gotestsum:
(cd /tmp && go install gotest.tools/gotestsum@latest)
.PHONY: helm-test
helm-test: helm-unit-test helm-integration-test
.PHONY: helm-unit-test
helm-unit-test:
cd ./helm-tests/unit && go test -v -count=1 -race .
.PHONY: helm-integration-test
helm-integration-test:
# we are explicit here to ensure that teardown really runs twice
$(MAKE) k3d-teardown
$(MAKE) k3d-setup
$(MAKE) helm-integration-test-run
$(MAKE) k3d-teardown
.PHONY: k3d-setup
k3d-setup:
k3d cluster create $(K3D_CLUSTER_NAME) -p "30083:30083@server:0" --api-port 127.0.0.1:6443
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(SERVICE_NAME) ./cmd/$(SERVICE_NAME)
docker build --no-cache -t localhost/$(SERVICE_NAME):latest -f Dockerfile.dev .
k3d image import localhost/$(SERVICE_NAME):latest -c $(K3D_CLUSTER_NAME)
.PHONY: helm-integration-test-run
helm-integration-test-run:
kubectl config current-context
cd ./helm-tests/integration && go test -v -count=1 -race .
.PHONY: k3d-teardown
k3d-teardown:
k3d cluster delete $(K3D_CLUSTER_NAME)