-
-
Notifications
You must be signed in to change notification settings - Fork 411
Expand file tree
/
Copy pathjustfile
More file actions
135 lines (116 loc) · 5.72 KB
/
Copy pathjustfile
File metadata and controls
135 lines (116 loc) · 5.72 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
VERSION := `git rev-parse HEAD`
open := if os() == "macos" { "open" } else { "xdg-open" }
[private]
default:
@just --list --unsorted
clippy:
#rustup component add clippy --toolchain nightly
# all features + all targets, minus e2e (its latest+mk8sv = two k8s-openapi versions -> build panic)
cargo +nightly clippy --workspace --all-features --all-targets --exclude e2e
# default features too, for the #[cfg(not(feature = ...))] paths the first pass can't reach
cargo +nightly clippy --workspace --all-targets
fmt:
#rustup component add rustfmt --toolchain nightly
cargo +nightly fmt --all
doc:
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features --no-deps --open
deny:
# might require rm Cargo.lock first to match CI
cargo deny --workspace --all-features check bans licenses sources
# Unit tests
test:
#!/usr/bin/env bash
if rg "\`\`\`ignored"; then
echo "ignored doctests are not allowed, use compile_fail or no_run"
exit 1
fi
# no default features
cargo test --workspace --lib --no-default-features
# default features
cargo test --workspace --lib --exclude kube-examples --exclude e2e
# all features
cargo test --workspace --lib --all-features --exclude kube-examples --exclude e2e
cargo test --workspace --doc --all-features --exclude kube-examples --exclude e2e
cargo test -p kube-examples --examples
cargo test -p kube-examples --examples --all-features
# Integration tests (will modify your current context's cluster)
test-integration:
kubectl delete pod -lapp=kube-rs-test > /dev/null
cargo test --lib --workspace --exclude e2e --all-features -- --ignored
# some examples are canonical tests
cargo run -p kube-examples --example crd_derive
cargo run -p kube-examples --example crd_api
coverage:
cargo tarpaulin --out=Html --output-dir=.
{{open}} tarpaulin-report.html
hack:
time cargo hack check --feature-powerset --no-private -p kube \
--skip=oauth,oidc \
--group-features=socks5,http-proxy,gzip,ws \
--group-features=admission,jsonpatch,derive,cel \
--group-features=rustls-tls,aws-lc-rs
# Test groups features with minimal overlap that are grouped to reduce combinations.
# Without any grouping this test takes an hour and has to test >11k combinations.
# Skipped oauth and oidc, as these compile fails without a tls stack.
minimal-versions:
cargo hack --remove-dev-deps --workspace
cargo +nightly update -Z direct-minimal-versions
K8S_OPENAPI_ENABLED_VERSION=1.32 cargo check --all-features
readme:
rustdoc README.md --test --edition=2024
e2e: (e2e-mink8s) (e2e-incluster "rustls,latest")
e2e-mink8s:
cargo run -p e2e --bin boot --features=openssl,latest
cargo run -p e2e --bin boot --features=openssl,mk8sv
#cargo run -p e2e --bin boot --features=rustls,latest
#cargo run -p e2e --bin boot --features=rustls,mk8sv
e2e-incluster features:
docker build --build-arg FEATURES="{{features}}" \
-t clux/kube-e2e:{{VERSION}} . -f e2e/Dockerfile
k3d image import clux/kube-e2e:{{VERSION}} -c=$(k3d cluster list -ojson |jq '.[0].name' -r)
sed -i 's/latest/{{VERSION}}/g' e2e/deployment.yaml
kubectl apply -f e2e/deployment.yaml
sed -i 's/{{VERSION}}/latest/g' e2e/deployment.yaml
kubectl get all -n apps
kubectl describe jobs/e2e -n apps
kubectl wait --for=condition=complete job/e2e -n apps --timeout=50s || kubectl logs -f job/e2e -n apps
kubectl get all -n apps
kubectl wait --for=condition=complete job/e2e -n apps --timeout=10s || kubectl get pods -n apps | grep e2e | grep Completed
@echo "need to not commit a sha in the deployment.yaml"
rg "latest" e2e/deployment.yaml -q
k3d:
k3d cluster create main --servers 1 --registry-create main --image rancher/k3s:v1.27.3-k3s1 \
-p 10250:10250 --no-rollback \
--k3s-arg "--disable=traefik,servicelb,metrics-server@server:*" \
--k3s-arg '--kubelet-arg=eviction-hard=imagefs.available<1%,nodefs.available<1%@agent:*' \
--k3s-arg '--kubelet-arg=eviction-minimum-reclaim=imagefs.available=1%,nodefs.available=1%@agent:*' \
--k3s-arg '--kube-apiserver-arg=feature-gates=WatchList=true@server:*'
## RELEASE RELATED
# Bump the msrv of kube; "just bump-msrv 1.60.0"
bump-msrv msrv:
#!/usr/bin/env bash
fullmsrv="{{msrv}}" # need a temporary var for this
shortmsrv="${fullmsrv::-2}" # badge can use a short display version
badge="[](https://github.com/rust-lang/rust/releases/tag/{{msrv}})"
sd "rust-version = \".*\"" "rust-version = \"{{msrv}}\"" Cargo.toml
sd "^.+badge/MSRV.+$" "${badge}" README.md
sd "rust:.*-bullseye" "rust:{{msrv}}-bullseye" .devcontainer/Dockerfile
# Sets the Kubernetes feature version from latest k8s-openapi.
# run: cargo upgrade -p k8s-openapi -i
# then: just bump-k8s
bump-k8s:
#!/usr/bin/env bash
earliest=$(cargo info k8s-openapi --color=never 2> /dev/null |grep earliest | awk -F'[][]' '{print $2}')
latest=$(cargo info k8s-openapi --color=never 2> /dev/null |grep latest | awk -F'[][]' '{print $2}')
# pin mk8sv to k8s-openapi earliest
min_feat="${earliest::-2}${earliest:3}"
min_dots="${min_feat/_/.}"
echo "Setting MK8SV to $min_dots using feature $min_feat"
# workflow pins for k3s (any line with key/array suffixed by # MK8SV)
sd "(.*)([\:\-]{1}) .* # MK8SV$" "\$1\$2 \"${min_dots}\" # MK8SV" .github/workflows/*.yml
# bump mk8sv badge
badge="[](https://kube.rs/kubernetes-version)"
sd "^.+badge/MK8SV.+$" "${badge}" README.md
# bump K8S_OPENAPI_ENABLED_VERSION in minimal-versions recipe (TODO: fix this)
sd "K8S_OPENAPI_ENABLED_VERSION=\S+" "K8S_OPENAPI_ENABLED_VERSION=${min_dots}" justfile
echo "remember to bump kubernetes-version.md in kube-rs/website"