-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
152 lines (121 loc) · 4.3 KB
/
Copy pathMakefile
File metadata and controls
152 lines (121 loc) · 4.3 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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# -------------------------------------------------------------------
# Configuration
# -------------------------------------------------------------------
V ?=
KIND_CLUSTER_NAME ?= praxis-dev
PROJECT_IMAGE ?= project:dev
KUBECTL ?= kubectl --context kind-$(KIND_CLUSTER_NAME)
ifneq ($(V),)
_NOCAPTURE := -- --nocapture
endif
.PHONY: all build release check clean \
test lint fmt doc audit \
coverage coverage-check \
images container kind-up kind-down \
dev-env dev-push dev-integration \
help
# -------------------------------------------------------------------
# All
# -------------------------------------------------------------------
all: build fmt lint test audit
# -------------------------------------------------------------------
# Build
# -------------------------------------------------------------------
build:
cargo build --workspace
release:
cargo build --workspace --release
check:
cargo check --workspace
clean:
cargo clean
# -------------------------------------------------------------------
# Test
# -------------------------------------------------------------------
test:
cargo test --workspace $(_NOCAPTURE)
# -------------------------------------------------------------------
# Quality
# -------------------------------------------------------------------
lint:
cargo clippy --workspace --all-targets -- -D warnings
cargo +nightly fmt --all -- --check
cargo machete
fmt:
cargo +nightly fmt --all
doc:
RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
audit:
cargo audit
cargo deny check
coverage:
cargo llvm-cov --workspace --html --output-dir target/coverage
coverage-check:
cargo llvm-cov --workspace --fail-under-lines 80
# -------------------------------------------------------------------
# Container
# -------------------------------------------------------------------
container:
podman build -t $(PROJECT_IMAGE) -f Containerfile . || \
docker build -t $(PROJECT_IMAGE) -f Containerfile .
images:
docker build -t $(PROJECT_IMAGE) -f Containerfile .
# -------------------------------------------------------------------
# KIND
# -------------------------------------------------------------------
kind-up: images
KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) \
bash hack/setup-kind.sh
kind-down:
KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) \
bash hack/teardown-kind.sh
# -------------------------------------------------------------------
# Iterative Development
# -------------------------------------------------------------------
dev-env: images
KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) \
bash hack/setup-kind.sh
dev-push:
docker build -t $(PROJECT_IMAGE) -f Containerfile .
kind load docker-image $(PROJECT_IMAGE) --name $(KIND_CLUSTER_NAME)
dev-integration:
@kind get kubeconfig --name $(KIND_CLUSTER_NAME) > /tmp/kind-$(KIND_CLUSTER_NAME).kubeconfig
KUBECONFIG=/tmp/kind-$(KIND_CLUSTER_NAME).kubeconfig \
cargo test --features integration -- --ignored $(if $(V),--nocapture,)
# -------------------------------------------------------------------
# Help
# -------------------------------------------------------------------
help:
@echo "Variables:"
@echo " V=1 show test output (--nocapture)"
@echo " KIND_CLUSTER_NAME KIND cluster name"
@echo " PROJECT_IMAGE container image tag"
@echo ""
@echo "Top-level:"
@echo " all build + lint + test + audit"
@echo ""
@echo "Build:"
@echo " build cargo build --workspace"
@echo " release cargo build --workspace --release"
@echo " check cargo check --workspace"
@echo " clean cargo clean"
@echo ""
@echo "Test:"
@echo " test run all tests"
@echo ""
@echo "Quality:"
@echo " lint clippy + rustfmt check"
@echo " fmt format with nightly rustfmt"
@echo " doc build docs with warnings denied"
@echo " audit cargo audit + cargo deny"
@echo " coverage HTML coverage report"
@echo " coverage-check fail if line coverage < 80%%"
@echo ""
@echo "KIND:"
@echo " kind-up create cluster + deploy"
@echo " kind-down delete cluster"
@echo ""
@echo "Development:"
@echo " dev-env create/reuse persistent cluster"
@echo " dev-push build + load + rollout"
@echo " dev-integration run integration tests"