-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
123 lines (100 loc) · 2.28 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
ARGS ?=
SUDO ?= sudo -E
KUBERNIX ?= $(SUDO) target/release/kubernix $(ARGS)
CONTAINER_RUNTIME ?= $(SUDO) podman
RUN_DIR ?= $(shell pwd)/kubernix-run
export IMAGE ?= docker.io/saschagrunert/kubernix
define nix
nix run -f nix/build.nix $(1)
endef
define nix-run
$(call nix,-c $(1))
endef
define nix-run-pure
$(call nix,-ik SSH_AUTH_SOCK -c $(1))
endef
all: build
.PHONY: build
build:
$(call nix-run-pure,cargo build)
.PHONY: build-image
build-image:
$(CONTAINER_RUNTIME) build -t $(IMAGE) .
.PHONY: build-release
build-release:
$(call nix-run-pure,cargo build --release)
.PHONY: coverage
coverage:
$(call nix-run-pure,cargo kcov --lib)
.PHONY: e2e
e2e:
$(call nix-run,$(SUDO) \
KUBERNETES_SERVICE_HOST=127.0.0.1 \
KUBERNETES_SERVICE_PORT=6443 \
KUBECONFIG=$(RUN_DIR)/kubeconfig/admin.kubeconfig \
e2e.test \
--provider=local \
--ginkgo.focus='.*$(FOCUS).*' \
--ginkgo.progress \
$(ARGS) \
)
.PHONY: docs
docs:
$(call nix-run-pure,cargo doc --no-deps)
.PHONY: lint-clippy
lint-clippy:
$(call nix-run-pure,cargo clippy --all -- -D warnings)
.PHONY: lint-rustfmt
lint-rustfmt:
$(call nix-run-pure,cargo fmt && git diff --exit-code)
.PHONY: nix
nix:
$(call nix-run-pure,$(shell which bash))
.PHONY: nixdeps
nixdeps:
@echo '| Application | Version |'
@echo '| - | - |'
@nix-instantiate nix 2> /dev/null \
| sed -n 's;/nix/store/[[:alnum:]]\{32\}-\(.*\)-\(.*\).drv\(!bin\)\{0,1\};| \1 | v\2 |;p' \
| sort
.PHONY: nixpkgs
nixpkgs:
@nix run -f channel:nixpkgs-unstable nix-prefetch-git -c nix-prefetch-git \
--no-deepClone https://github.com/nixos/nixpkgs > nix/nixpkgs.json
.PHONY: run
run: build-release
$(KUBERNIX)
.PHONY: run-image
run-image:
$(SUDO) contrib/prepare-system
mkdir -p $(RUN_DIR)
if [ -d /dev/mapper ]; then \
DEV_MAPPER=-v/dev/mapper:/dev/mapper ;\
fi ;\
$(CONTAINER_RUNTIME) run \
-v $(RUN_DIR):/kubernix-run \
--rm \
--privileged \
--net=host \
$$DEV_MAPPER \
-it $(IMAGE) $(ARGS)
.PHONY: shell
shell: build-release
$(KUBERNIX) shell
define test
$(call nix-run,\
cargo test \
--test $(1) $(ARGS) \
-- \
--test-threads 1 \
--nocapture)
endef
.PHONY: test-integration
test-integration:
$(call test,integration)
.PHONY: test-e2e
test-e2e:
$(call test,e2e)
.PHONY: test-unit
test-unit:
$(call nix-run-pure,cargo test --lib)