From fa5f8568405a2e3fc3660c38453ebd4a2bb5539d Mon Sep 17 00:00:00 2001 From: sdairs Date: Fri, 13 Nov 2026 03:36:30 +0000 Subject: [PATCH] build: inherit shared package fields from [workspace.package], read the MSRV from it (#1352) Edition, rust-version, license, repository and homepage live once in the root manifest; msrv.yml reads rust-version from cargo metadata. Release tarballs carry LICENSE, the library forbids unsafe code, and the CLI's duplicate serde_json dev-dependency is gone. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/msrv.yml | 16 ++++++++++++++-- .github/workflows/release.yml | 3 +++ AGENTS.md | 2 +- Cargo.toml | 9 +++++++++ crates/clickhouse-cloud-api/Cargo.toml | 10 +++++----- crates/clickhouse-cloud-api/src/lib.rs | 2 ++ crates/clickhouse-openapi-analyzer/Cargo.toml | 6 ++++-- crates/clickhousectl/Cargo.toml | 11 +++++------ 8 files changed, 43 insertions(+), 16 deletions(-) diff --git a/.github/workflows/msrv.yml b/.github/workflows/msrv.yml index 47d12a7fb..1919f5948 100644 --- a/.github/workflows/msrv.yml +++ b/.github/workflows/msrv.yml @@ -24,11 +24,23 @@ jobs: with: persist-credentials: false - # Keep in sync with `rust-version` in the crate manifests. + # The MSRV is `workspace.package.rust-version`, which every crate + # inherits; read it with the runner's preinstalled cargo. + - name: Read declared rust-version + id: msrv + run: | + versions=$(cargo metadata --no-deps --format-version 1 | jq -r '[.packages[].rust_version] | unique | .[]') + if [ "$(printf '%s\n' "$versions" | wc -l)" -ne 1 ] || [ -z "$versions" ] || [ "$versions" = "null" ]; then + echo "::error::expected one rust-version across the workspace, got: ${versions:-}" + exit 1 + fi + echo "Declared rust-version: $versions" + echo "version=$versions" >> "$GITHUB_OUTPUT" + - name: Install Rust toolchain uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable @ 2026-10-16 with: - toolchain: "1.94.1" + toolchain: ${{ steps.msrv.outputs.version }} - name: Check all targets run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c90a49d0c..38d3b5ee9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -103,6 +103,9 @@ jobs: DIR="clickhousectl-${TARGET}-v${VERSION}" mkdir "$DIR" cp "target/${TARGET}/release/clickhousectl" "$DIR/" + # install.sh, npm install.js and `update` take the binary by name, + # so the licence beside it changes nothing they extract. + cp LICENSE "$DIR/" tar -czf "${DIR}.tar.gz" "$DIR" - name: Upload artifact diff --git a/AGENTS.md b/AGENTS.md index 9e4b1717b..faabc38d0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -134,7 +134,7 @@ the unit layer by default. Where a unit test and a subprocess test overlap, keep ## Dependencies Use `cargo add` with the latest version and an explicit crate, e.g. `cargo add -p clickhouse-cloud-api url`. -Every crate declares the same `rust-version`; raise it in all three manifests, both READMEs and `msrv.yml` together. +The MSRV is `rust-version` in the root `[workspace.package]` (`msrv.yml` reads it); raise it there and in both READMEs. ## Releases diff --git a/Cargo.toml b/Cargo.toml index 96de60b6a..5ed3affef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,12 @@ members = [ "crates/clickhouse-openapi-analyzer", ] resolver = "3" + +# Shared by every crate (`.workspace = true`). `rust-version` is the one +# MSRV: msrv.yml reads it from `cargo metadata`. Versions stay per crate. +[workspace.package] +edition = "2024" +rust-version = "1.94.1" +license = "Apache-2.0" +repository = "https://github.com/ClickHouse/clickhousectl" +homepage = "https://github.com/ClickHouse/clickhousectl" diff --git a/crates/clickhouse-cloud-api/Cargo.toml b/crates/clickhouse-cloud-api/Cargo.toml index 0352feecf..ad813d579 100644 --- a/crates/clickhouse-cloud-api/Cargo.toml +++ b/crates/clickhouse-cloud-api/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "clickhouse-cloud-api" version = "0.6.0" -edition = "2024" -rust-version = "1.94.1" +edition.workspace = true +rust-version.workspace = true description = "Typed Rust client for the ClickHouse Cloud API" -license = "Apache-2.0" -repository = "https://github.com/ClickHouse/clickhousectl" -homepage = "https://github.com/ClickHouse/clickhousectl" +license.workspace = true +repository.workspace = true +homepage.workspace = true keywords = ["clickhouse", "cloud", "api", "client"] categories = ["api-bindings", "database"] # Ship the library and its documentation only: the spec snapshot, tests and diff --git a/crates/clickhouse-cloud-api/src/lib.rs b/crates/clickhouse-cloud-api/src/lib.rs index 52c0a78c9..99272c875 100644 --- a/crates/clickhouse-cloud-api/src/lib.rs +++ b/crates/clickhouse-cloud-api/src/lib.rs @@ -75,6 +75,8 @@ //! spec drift of that kind is the job of the repository's daily OpenAPI drift //! check, not of runtime deserialization. +#![forbid(unsafe_code)] + pub mod client; pub mod convert; pub mod error; diff --git a/crates/clickhouse-openapi-analyzer/Cargo.toml b/crates/clickhouse-openapi-analyzer/Cargo.toml index 502cf7102..0e0f857e2 100644 --- a/crates/clickhouse-openapi-analyzer/Cargo.toml +++ b/crates/clickhouse-openapi-analyzer/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "clickhouse-openapi-analyzer" version = "0.0.0" -edition = "2024" -rust-version = "1.94.1" +edition.workspace = true +rust-version.workspace = true +license.workspace = true +repository.workspace = true publish = false [lib] diff --git a/crates/clickhousectl/Cargo.toml b/crates/clickhousectl/Cargo.toml index 92c723803..77df89e7f 100644 --- a/crates/clickhousectl/Cargo.toml +++ b/crates/clickhousectl/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "clickhousectl" version = "0.6.0" -edition = "2024" -rust-version = "1.94.1" +edition.workspace = true +rust-version.workspace = true description = "The CLI for ClickHouse: local and cloud." -license = "Apache-2.0" -repository = "https://github.com/ClickHouse/clickhousectl" -homepage = "https://github.com/ClickHouse/clickhousectl" +license.workspace = true +repository.workspace = true +homepage.workspace = true keywords = ["clickhouse", "cli", "database", "cloud"] categories = ["command-line-utilities", "database"] readme = "../../README.md" @@ -75,7 +75,6 @@ clap_complete = { version = "=4.6.11", features = ["unstable-dynamic"] } [dev-dependencies] rustls = { version = "0.23.46", default-features = false, features = ["aws_lc_rs", "std", "tls12"] } rustls-native-certs = "0.8.5" -serde_json = "1" tokio = { version = "1", features = ["test-util"] } tokio-postgres = "0.7.18" tokio-postgres-rustls = "0.14.0"