Skip to content

Commit

Permalink
Make implicitly dependent feature explicitly depend on each other (#1551
Browse files Browse the repository at this point in the history
)

* Make implicitly dependent feature explicitly depend on each other

By running a variant of cargo hack, we found a number of compile issues
when using unusual feature combinations, and these are largely rectified
by making intended feature pairings explicit.

Client features now depend on the `client` feature, runtime features
now depend on the `runtime` feature, etc.

- rustls-tls / openssl-tls => `client` feature
- oauth / oidc / gzip / socks5 / http-proxy => `client` feature
- unstable-runtime => `runtime` feature

Unfortunately, the cargo hack solution is simplistic and cannot verify everything AFAIKT yet.
I am currently running with excluding oauth and oidc because these
require picking a tls stack and we have an intended compile error for this.
I cannot find a way to tell `hack` to model this without just excluding them.

The number of features makes the combination features test very long,
case in point, the cargo hack invocation in the justfile:

- tests **11370** feature combinations
- takes >2h (currently 30m in at 2000 combination on a beefy 7950X3D)

Signed-off-by: clux <[email protected]>

* update and run in ci

Signed-off-by: clux <[email protected]>

* opt in to hack ci

Signed-off-by: clux <[email protected]>

* also group derive with other core feature

Signed-off-by: clux <[email protected]>

---------

Signed-off-by: clux <[email protected]>
  • Loading branch information
clux authored Jul 30, 2024
1 parent f74576f commit de12b71
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/features.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: features

on:
push:
branches:
- main
# opt in to explicit stuff here, this test is slow
- hack-features

jobs:
cargo-hack:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
- uses: extractions/setup-just@v2
- name: Run cargo-hack
run: just hack
9 changes: 9 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ 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 \
--group-features=admission,jsonpatch,derive
# 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.

readme:
rustdoc README.md --test --edition=2021

Expand Down
18 changes: 9 additions & 9 deletions kube/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ default = ["client", "rustls-tls"]
# default features
client = ["kube-client/client", "config"]
config = ["kube-client/config"]
rustls-tls = ["kube-client/rustls-tls"]
rustls-tls = ["kube-client/rustls-tls", "client"]

# alternative features
openssl-tls = ["kube-client/openssl-tls"]
openssl-tls = ["kube-client/openssl-tls", "client"]

# auxiliary features
ws = ["kube-client/ws", "kube-core/ws"]
kubelet-debug = ["kube-client/kubelet-debug", "kube-core/kubelet-debug"]
oauth = ["kube-client/oauth"]
oidc = ["kube-client/oidc"]
gzip = ["kube-client/gzip"]
oauth = ["kube-client/oauth", "client"]
oidc = ["kube-client/oidc", "client"]
gzip = ["kube-client/gzip", "client"]
jsonpatch = ["kube-core/jsonpatch"]
admission = ["kube-core/admission"]
derive = ["kube-derive", "kube-core/schema"]
runtime = ["kube-runtime"]
unstable-runtime = ["kube-runtime/unstable-runtime"]
unstable-client = ["kube-client/unstable-client"]
socks5 = ["kube-client/socks5"]
http-proxy = ["kube-client/http-proxy"]
unstable-runtime = ["kube-runtime/unstable-runtime", "runtime"]
unstable-client = ["kube-client/unstable-client", "client"]
socks5 = ["kube-client/socks5", "client"]
http-proxy = ["kube-client/http-proxy", "client"]

[package.metadata.docs.rs]
features = ["client", "rustls-tls", "openssl-tls", "derive", "ws", "oauth", "jsonpatch", "admission", "runtime", "k8s-openapi/latest", "unstable-runtime", "socks5", "http-proxy"]
Expand Down

0 comments on commit de12b71

Please sign in to comment.