From de12b7172dac70d7bf5fad4be3184a861b358624 Mon Sep 17 00:00:00 2001 From: Eirik A Date: Tue, 30 Jul 2024 14:18:30 +0100 Subject: [PATCH] Make implicitly dependent feature explicitly depend on each other (#1551) * 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 * update and run in ci Signed-off-by: clux * opt in to hack ci Signed-off-by: clux * also group derive with other core feature Signed-off-by: clux --------- Signed-off-by: clux --- .github/workflows/features.yml | 22 ++++++++++++++++++++++ justfile | 9 +++++++++ kube/Cargo.toml | 18 +++++++++--------- 3 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/features.yml diff --git a/.github/workflows/features.yml b/.github/workflows/features.yml new file mode 100644 index 000000000..c1ea355e1 --- /dev/null +++ b/.github/workflows/features.yml @@ -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 diff --git a/justfile b/justfile index 3c3adf9d8..9c006b8e5 100644 --- a/justfile +++ b/justfile @@ -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 diff --git a/kube/Cargo.toml b/kube/Cargo.toml index 5849b7425..5daabedd9 100644 --- a/kube/Cargo.toml +++ b/kube/Cargo.toml @@ -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"]