-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
94 lines (79 loc) · 2.88 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
93
94
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CURRENT_DIR := $(dir $(MAKEFILE_PATH))
ARCH := $(shell uname -m)
.PHONY: all
all: help
.PHONY: prepare
prepare: tidy lint doc build test
.PHONY: cover
cover:
go tool cover -html ./cover.out
.PHONY: doc
doc: build-cli
cd cli && HOME="/home/user" ./bin/kubectl-shovel doc && cd -
.PHONY: lint
lint:
golangci-lint run
.PHONY: tidy
tidy:
go mod tidy -v
.PHONY: build
build: build-cli build-dumper
.PHONY: build-cli
build-cli:
go build -v -o ./cli/bin/kubectl-shovel ./cli
.PHONY: build-dumper
build-dumper:
go build -v -o ./dumper/bin/dumper ./dumper
.PHONY: test
test: test-unit test-integration
.PHONY: test-unit
test-unit:
go test \
-v \
-race \
-cover \
-coverprofile cover.out \
-timeout 30s \
./...
NODE_VERSION ?= v1.21.1
.PHONY: test-integration-setup
test-integration-setup:
kind create cluster --name "kind" --image=kindest/node:$(NODE_VERSION)
FRAMEWORK ?= net6.0
.PHONY: test-integration-prepare
test-integration-prepare:
./hacks/prepare-integration-tests.sh "$(CURRENT_DIR)" "kind-kind" "$(ARCH)" "$(FRAMEWORK)"
.PHONY: test-integration
test-integration: test-integration-prepare
go test \
-v \
-ldflags="-X github.com/dodopizza/kubectl-shovel/test/integration_test.TargetContainerImage=kubectl-shovel/sample-integration-tests:$(FRAMEWORK)" \
-parallel 1 \
-timeout 600s \
--tags=integration \
./test/integration/...
.PHONY: help
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@echo " ${YELLOW}prepare ${RESET} Run all available checks and generators"
@echo " ${YELLOW}cover ${RESET} Open html coverage report in browser"
@echo " ${YELLOW}doc ${RESET} Run doc generation"
@echo " ${YELLOW}lint ${RESET} Run linters via golangci-lint"
@echo " ${YELLOW}tidy ${RESET} Run tidy for go module to remove unused dependencies"
@echo " ${YELLOW}build ${RESET} Build all components"
@echo " ${YELLOW}build-cli ${RESET} Build cli component of shovel"
@echo " ${YELLOW}build-dumper ${RESET} Build dumper component of shovel"
@echo " ${YELLOW}test ${RESET} Run all available tests"
@echo " ${YELLOW}test-unit ${RESET} Run all unit tests"
@echo " ${YELLOW}test-integration ${RESET} Run all integration tests"
@echo " ${YELLOW}test-integration-setup ${RESET} Setup integration tests environment. Create kind cluster"
@echo " ${YELLOW}test-integration-prepare ${RESET} Prepare integration tests (build required images and load to kind cluster)"