From 2ff3a2d50428f3f7d1ef9633b59e938346128688 Mon Sep 17 00:00:00 2001 From: Eirik A Date: Mon, 25 Mar 2024 13:21:12 +0000 Subject: [PATCH] Factor out workspace props (#1437) * Factor out common workspace Cargo.toml properties Signed-off-by: clux * factor out forbid(unsafe_code) Signed-off-by: clux * factor out deny(missing_docs) found one case where we were not in sync. raising an issue Signed-off-by: clux * simplify msrv checks now that it's in sync cargo-msrv does not work with the new package factoring out but it wasn't really that helpful anyway... we only bumped the msrv when something broke, so.. Signed-off-by: clux * fix merge missing change Signed-off-by: clux --------- Signed-off-by: clux Signed-off-by: Eirik A --- .github/workflows/ci.yml | 9 ++------- Cargo.toml | 17 +++++++++++++++++ e2e/Cargo.toml | 8 ++++---- examples/Cargo.toml | 12 ++++-------- justfile | 15 +++------------ kube-client/Cargo.toml | 21 ++++++++++----------- kube-client/src/lib.rs | 2 -- kube-core/Cargo.toml | 20 ++++++++++---------- kube-core/src/lib.rs | 2 -- kube-derive/Cargo.toml | 19 +++++++++---------- kube-derive/src/lib.rs | 2 -- kube-runtime/Cargo.toml | 25 ++++++++++++++----------- kube-runtime/src/lib.rs | 1 - kube/Cargo.toml | 21 ++++++++++----------- kube/src/lib.rs | 2 -- 15 files changed, 83 insertions(+), 93 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26c7d10ca..8812743d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,14 +112,9 @@ jobs: command: check args: --workspace - - name: Check rust-version keys matches MSRV consistently + - name: Check rust-version keys matches advertised MSRV run: | - if [[ $(cat ./*/Cargo.toml | grep "rust-version" | uniq | wc -l) -gt 1 ]]; then - echo "inconsistent rust-version keys set in various kube-crates:" - rg "rust-version" ./*/Cargo.toml - exit 1 - fi - if ! cat kube/Cargo.toml | grep "rust-version" | grep "${{ steps.msrv.outputs.msrv }}"; then + if ! cat Cargo.toml | grep "rust-version" | grep "${{ steps.msrv.outputs.msrv }}"; then echo "msrv policy inconsistent with rust-version key" exit 1 fi diff --git a/Cargo.toml b/Cargo.toml index 06a59e062..1cc879c7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,23 @@ members = [ "examples", ] +[workspace.package] +version = "0.88.1" +authors = [ + "clux ", + "Natalie Klestrup Röijezon ", + "kazk ", +] +repository = "https://github.com/kube-rs/kube" +readme = "README.md" +license = "Apache-2.0" +edition = "2021" +rust-version = "1.75.0" + +[workspace.lints.rust] +unsafe_code = "forbid" +missing_docs = "deny" + [workspace.dependencies] ahash = "0.8" anyhow = "1.0.71" diff --git a/e2e/Cargo.toml b/e2e/Cargo.toml index 9e3e16ccc..d689ae3ac 100644 --- a/e2e/Cargo.toml +++ b/e2e/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "e2e" -version = "0.1.0" -authors = ["clux "] publish = false -edition = "2021" -license = "Apache-2.0" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true [package.metadata.release] release = false diff --git a/examples/Cargo.toml b/examples/Cargo.toml index a497a5405..60c1e4909 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -1,14 +1,10 @@ [package] name = "kube-examples" -version = "0.1.0" -authors = [ - "clux ", - "Natalie Klestrup Röijezon ", - "kazk ", -] publish = false -edition = "2021" -license = "Apache-2.0" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true [package.metadata.release] release = false diff --git a/justfile b/justfile index 3cb269bf3..eba15879b 100644 --- a/justfile +++ b/justfile @@ -95,21 +95,12 @@ k3d: # Bump the msrv of kube; "just bump-msrv 1.60.0" bump-msrv msrv: #!/usr/bin/env bash - # TODO: warn if not msrv+2 not found - oldmsrv="$(rg "rust-version = \"(.*)\"" -r '$1' kube/Cargo.toml)" - fastmod -m -d . --extensions toml "rust-version = \"$oldmsrv\"" "rust-version = \"{{msrv}}\"" - # sanity - if [[ $(cat ./*/Cargo.toml | grep "rust-version" | uniq | wc -l) -gt 1 ]]; then - echo "inconsistent rust-version keys set in various kube-crates:" - rg "rust-version" ./*/Cargo.toml - exit 1 - fi - fullmsrv="{{msrv}}" + fullmsrv="{{msrv}}" # need a temporary var for this shortmsrv="${fullmsrv::-2}" # badge can use a short display version badge="[![Rust ${shortmsrv}](https://img.shields.io/badge/MSRV-${shortmsrv}-dea584.svg)](https://github.com/rust-lang/rust/releases/tag/{{msrv}})" + sd "rust-version = \".*\"" "rust-version = \"{{msrv}}\"" Cargo.toml sd "^.+badge/MSRV.+$" "${badge}" README.md - sd "${oldmsrv}" "{{msrv}}" .devcontainer/Dockerfile - cargo msrv + sd "rust:.*-bullseye" "rust:{{msrv}}-bullseye" .devcontainer/Dockerfile # Increment the Kubernetes feature version from k8s-openapi for tests; "just bump-k8s" bump-k8s: diff --git a/kube-client/Cargo.toml b/kube-client/Cargo.toml index 2977792a6..2c5dc4293 100644 --- a/kube-client/Cargo.toml +++ b/kube-client/Cargo.toml @@ -1,19 +1,15 @@ [package] name = "kube-client" -version = "0.88.1" description = "Kubernetes client" -authors = [ - "clux ", - "Natalie Klestrup Röijezon ", - "kazk ", -] -license = "Apache-2.0" -repository = "https://github.com/kube-rs/kube" -readme = "../README.md" +version.workspace = true +authors.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true +edition.workspace = true +rust-version.workspace = true keywords = ["kubernetes", "client",] categories = ["web-programming::http-client", "configuration", "network-programming", "api-bindings"] -rust-version = "1.75.0" -edition = "2021" [features] default = ["client"] @@ -39,6 +35,9 @@ features = ["client", "rustls-tls", "openssl-tls", "ws", "oauth", "oidc", "jsonp # Define the configuration attribute `docsrs`. Used to enable `doc_cfg` feature. rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] base64 = { workspace = true, optional = true } chrono = { workspace = true, optional = true } diff --git a/kube-client/src/lib.rs b/kube-client/src/lib.rs index 9b248969d..6d567904a 100644 --- a/kube-client/src/lib.rs +++ b/kube-client/src/lib.rs @@ -61,8 +61,6 @@ //! - [`Api`](crate::Api) for the generic api methods available on Kubernetes resources //! - [k8s-openapi](https://docs.rs/k8s-openapi) for how to create typed kubernetes objects directly #![cfg_attr(docsrs, feature(doc_cfg))] -#![deny(missing_docs)] -#![forbid(unsafe_code)] // Nightly clippy (0.1.64) considers Drop a side effect, see https://github.com/rust-lang/rust-clippy/issues/9608 #![allow(clippy::unnecessary_lazy_evaluations)] diff --git a/kube-core/Cargo.toml b/kube-core/Cargo.toml index 43325de6a..8fb7fb68d 100644 --- a/kube-core/Cargo.toml +++ b/kube-core/Cargo.toml @@ -1,23 +1,23 @@ [package] name = "kube-core" description = "Kube shared types, traits and client-less behavior" -version = "0.88.1" -authors = [ - "clux ", - "kazk ", -] -edition = "2021" -rust-version = "1.75.0" -license = "Apache-2.0" +version.workspace = true +authors.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true +edition.workspace = true +rust-version.workspace = true keywords = ["kubernetes", "apimachinery"] categories = ["api-bindings", "encoding", "parser-implementations"] -repository = "https://github.com/kube-rs/kube" -readme = "../README.md" [package.metadata.docs.rs] features = ["ws", "admission", "jsonpatch", "k8s-openapi/latest"] rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [features] ws = [] admission = ["json-patch"] diff --git a/kube-core/src/lib.rs b/kube-core/src/lib.rs index 94cd2f2ea..4e87ed752 100644 --- a/kube-core/src/lib.rs +++ b/kube-core/src/lib.rs @@ -7,8 +7,6 @@ //! Everything in this crate is re-exported from [`kube`](https://crates.io/crates/kube) //! (even with zero features) under [`kube::core`]((https://docs.rs/kube/*/kube/core/index.html)). #![cfg_attr(docsrs, feature(doc_cfg))] -#![deny(missing_docs)] -#![forbid(unsafe_code)] #[cfg_attr(docsrs, doc(cfg(feature = "admission")))] #[cfg(feature = "admission")] diff --git a/kube-derive/Cargo.toml b/kube-derive/Cargo.toml index af4e8e912..fa43a8951 100644 --- a/kube-derive/Cargo.toml +++ b/kube-derive/Cargo.toml @@ -1,19 +1,18 @@ [package] name = "kube-derive" description = "Custom derives for the kube kubernetes crates" -version = "0.88.1" -authors = [ - "clux ", - "kazk ", -] -edition = "2021" -rust-version = "1.75.0" -license = "Apache-2.0" -repository = "https://github.com/kube-rs/kube" -readme = "../README.md" +version.workspace = true +authors.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true +edition.workspace = true +rust-version.workspace = true keywords = ["kubernetes", "macro", "customresource", "crd"] categories = ["api-bindings", "encoding"] +[lints] +workspace = true [dependencies] proc-macro2.workspace = true diff --git a/kube-derive/src/lib.rs b/kube-derive/src/lib.rs index 68b068dad..c185d3b1c 100644 --- a/kube-derive/src/lib.rs +++ b/kube-derive/src/lib.rs @@ -1,6 +1,4 @@ //! A crate for kube's derive macros. -#![forbid(unsafe_code)] -#![deny(missing_docs)] #![recursion_limit = "1024"] extern crate proc_macro; #[macro_use] extern crate quote; diff --git a/kube-runtime/Cargo.toml b/kube-runtime/Cargo.toml index 5f3e0c63b..db2faa77a 100644 --- a/kube-runtime/Cargo.toml +++ b/kube-runtime/Cargo.toml @@ -1,18 +1,15 @@ [package] name = "kube-runtime" -version = "0.88.1" -description = "Kubernetes futures controller runtime" -authors = [ - "Natalie Klestrup Röijezon ", - "clux ", -] -license = "Apache-2.0" -repository = "https://github.com/kube-rs/kube" -readme = "../README.md" +description = "Kubernetes controller runtime" +version.workspace = true +authors.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true +edition.workspace = true +rust-version.workspace = true keywords = ["kubernetes", "runtime", "reflector", "watcher", "controller"] categories = ["web-programming::http-client", "caching", "network-programming"] -rust-version = "1.75.0" -edition = "2021" [features] unstable-runtime = ["unstable-runtime-subscribe", "unstable-runtime-predicates", "unstable-runtime-stream-control", "unstable-runtime-reconcile-on"] @@ -26,6 +23,12 @@ features = ["k8s-openapi/latest", "unstable-runtime"] # Define the configuration attribute `docsrs`. Used to enable `doc_cfg` feature. rustdoc-args = ["--cfg", "docsrs"] +[lints] +#workspace = true +rust.unsafe_code = "forbid" +# TODO: make this pass and switch to workspace lints +#rust.missing_docs = "warn" + [dependencies] futures.workspace = true kube-client = { path = "../kube-client", version = "=0.88.1", default-features = false, features = ["jsonpatch", "client"] } diff --git a/kube-runtime/src/lib.rs b/kube-runtime/src/lib.rs index f59d6d607..553fca629 100644 --- a/kube-runtime/src/lib.rs +++ b/kube-runtime/src/lib.rs @@ -8,7 +8,6 @@ //! opinionated starting point that should be appropriate for simple operators, but all //! components are designed to be usable á la carte if your operator doesn't quite fit that mold. -#![forbid(unsafe_code)] #![deny(clippy::all)] #![deny(clippy::pedantic)] // Triggered by many derive macros (kube-derive, derivative) diff --git a/kube/Cargo.toml b/kube/Cargo.toml index 401e2c5af..b7c4a4011 100644 --- a/kube/Cargo.toml +++ b/kube/Cargo.toml @@ -1,19 +1,15 @@ [package] name = "kube" -version = "0.88.1" description = "Kubernetes client and async controller runtime" -authors = [ - "clux ", - "Natalie Klestrup Röijezon ", - "kazk ", -] -license = "Apache-2.0" -repository = "https://github.com/kube-rs/kube" -readme = "../README.md" +version.workspace = true +authors.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true +edition.workspace = true +rust-version.workspace = true keywords = ["kubernetes", "client", "runtime", "cncf"] categories = ["network-programming", "caching", "api-bindings", "configuration", "encoding"] -rust-version = "1.75.0" -edition = "2021" [features] default = ["client", "rustls-tls"] @@ -45,6 +41,9 @@ features = ["client", "rustls-tls", "openssl-tls", "derive", "ws", "oauth", "jso # Define the configuration attribute `docsrs`. Used to enable `doc_cfg` feature. rustdoc-args = ["--cfg", "docsrs"] +[lints] +workspace = true + [dependencies] kube-derive = { path = "../kube-derive", version = "=0.88.1", optional = true } kube-core = { path = "../kube-core", version = "=0.88.1" } diff --git a/kube/src/lib.rs b/kube/src/lib.rs index 9d4b13e27..842df4ea8 100644 --- a/kube/src/lib.rs +++ b/kube/src/lib.rs @@ -104,8 +104,6 @@ //! # Examples //! A large list of complete, runnable examples with explainations are available in the [examples folder](https://github.com/kube-rs/kube/tree/main/examples). #![cfg_attr(docsrs, feature(doc_cfg))] -#![deny(missing_docs)] -#![forbid(unsafe_code)] macro_rules! cfg_client { ($($item:item)*) => {