From 58f056663aac7c2c68fd92e10bce6196c197e5f0 Mon Sep 17 00:00:00 2001 From: oddgrd <29732646+oddgrd@users.noreply.github.com> Date: Mon, 5 Dec 2022 15:25:43 +0100 Subject: [PATCH] feat: implement workspace inheritance for common & proto this commit also pulls in a PR branch of cargo-chef for compatibility with local workspace dependencies --- Cargo.toml | 21 ++++++++++----------- Containerfile | 9 ++++++--- admin/Cargo.toml | 4 ++-- cargo-shuttle/Cargo.toml | 4 ++-- common/Cargo.toml | 2 +- deployer/Cargo.toml | 8 +++----- gateway/Cargo.toml | 5 ++--- proto/Cargo.toml | 6 +++--- provisioner/Cargo.toml | 3 +-- service/Cargo.toml | 4 +--- 10 files changed, 31 insertions(+), 35 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6179ac037d..bddfd9abdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,24 +18,23 @@ exclude = [ "resources/persist", "resources/secrets", "resources/shared-db", - "resources/static-folder" + "resources/static-folder", + # TODO: remove this when we can install cargo-chef directly after + # https://github.com/LukeMathWalker/cargo-chef/pull/171 is merged + # and released + "cargo-chef" ] -# TODO: should we have the same version for all crates? -# currently backend crates are 0.7.3 and client side are 0.7.2 [workspace.package] -# version = "0.7.2" +# This is the version used for backend crates (common, proto, gateway, deployer) +version = "0.7.3" edition = "2021" license = "Apache-2.0" +# https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#inheriting-a-dependency-from-a-workspace [workspace.dependencies] -# TODO: these are different versions, so we end up setting the version in two -# places for some of them. Using the workspace version also means the resources -# can't resolve their dependency on shuttle-service. -# shuttle-common = { path = "common" } -# shuttle-proto = { path = "proto" } -# shuttle-service = { path = "service" } -# shuttle-codegen = { path = "codegen" } +shuttle-common = { path = "common", version = "0.7.3", default-features = false } +shuttle-proto = { path = "proto", version = "0.7.3" } anyhow = "1.0.66" async-trait = "0.1.58" diff --git a/Containerfile b/Containerfile index b866f55b40..b42c9c3b20 100644 --- a/Containerfile +++ b/Containerfile @@ -7,8 +7,9 @@ RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v21.9 unzip -o protoc-21.9-linux-x86_64.zip -d /usr bin/protoc &&\ unzip -o protoc-21.9-linux-x86_64.zip -d /usr/ 'include/*' &&\ rm -f protoc-21.9-linux-x86_64.zip -RUN cargo install cargo-chef WORKDIR /build +RUN git clone --single-branch -b feat/mask-workspace-dependencies https://github.com/oddgrd/cargo-chef.git &&\ + cd cargo-chef && cargo build FROM shuttle-build as cache WORKDIR /src @@ -17,11 +18,13 @@ RUN find ${SRC_CRATES} \( -name "*.proto" -or -name "*.rs" -or -name "*.toml" -o FROM shuttle-build AS planner COPY --from=cache /build . -RUN cargo chef prepare --recipe-path recipe.json +RUN cargo run --bin cargo-chef --manifest-path="cargo-chef/Cargo.toml" \ + -- chef prepare --recipe-path recipe.json FROM shuttle-build AS builder COPY --from=planner /build/recipe.json recipe.json -RUN cargo chef cook --recipe-path recipe.json +RUN cargo run --bin cargo-chef --manifest-path="cargo-chef/Cargo.toml" \ + -- chef cook --recipe-path recipe.json COPY --from=cache /build . ARG folder RUN cargo build --bin shuttle-${folder} diff --git a/admin/Cargo.toml b/admin/Cargo.toml index 9e78a3b212..c57dfe3b65 100644 --- a/admin/Cargo.toml +++ b/admin/Cargo.toml @@ -16,5 +16,5 @@ tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter"] } [dependencies.shuttle-common] -version = "0.7.3" -path = "../common" +workspace = true +features = ["models"] diff --git a/cargo-shuttle/Cargo.toml b/cargo-shuttle/Cargo.toml index 69437d3694..7ebbf45345 100644 --- a/cargo-shuttle/Cargo.toml +++ b/cargo-shuttle/Cargo.toml @@ -47,8 +47,8 @@ uuid = { workspace = true, features = ["v4"] } webbrowser = "0.8.2" [dependencies.shuttle-common] -version = "0.7.3" -path = "../common" +workspace = true +features = ["models"] [dependencies.shuttle-secrets] version = "0.7.2" diff --git a/common/Cargo.toml b/common/Cargo.toml index 813b0f8bc1..d499254b99 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shuttle-common" -version = "0.7.3" +version.workspace = true edition.workspace = true licence.workspace = true description = "Common library for the shuttle platform (https://www.shuttle.rs/)" diff --git a/deployer/Cargo.toml b/deployer/Cargo.toml index 2a0257c8b6..3693c0ff63 100644 --- a/deployer/Cargo.toml +++ b/deployer/Cargo.toml @@ -45,13 +45,11 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } uuid = { workspace = true, features = ["v4"] } [dependencies.shuttle-common] -version = "0.7.3" -path = "../common" -features = ["backend"] +workspace = true +features = ["backend", "models"] [dependencies.shuttle-proto] -version = "0.7.2" -path = "../proto" +workspace = true [dependencies.shuttle-service] version = "0.7.2" diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml index 22164e5c81..319ba21a3e 100644 --- a/gateway/Cargo.toml +++ b/gateway/Cargo.toml @@ -44,9 +44,8 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } uuid = { workspace = true, features = [ "v4" ] } [dependencies.shuttle-common] -version = "0.7.3" -path = "../common" -features = ["backend"] +workspace = true +features = ["backend", "models"] [dev-dependencies] anyhow = { workspace = true } diff --git a/proto/Cargo.toml b/proto/Cargo.toml index d97982cfe0..e0474ee672 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shuttle-proto" -version = "0.7.3" +version.workspace = true edition.workspace = true license.workspace = true publish = false @@ -11,8 +11,8 @@ prost = "0.11.2" tonic = "0.8.3" [dependencies.shuttle-common] -version = "0.7.3" -path = "../common" +workspace = true +features = ["models"] [build-dependencies] tonic-build = "0.8.3" diff --git a/provisioner/Cargo.toml b/provisioner/Cargo.toml index f546a66a68..81cb065b6e 100644 --- a/provisioner/Cargo.toml +++ b/provisioner/Cargo.toml @@ -23,8 +23,7 @@ tracing = { workspace = true } tracing-subscriber = { workspace = true } [dependencies.shuttle-proto] -version = "0.7.3" -path = "../proto" +workspace = true [dev-dependencies] ctor = "0.1.26" diff --git a/service/Cargo.toml b/service/Cargo.toml index 74205af63c..546f128d71 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -53,9 +53,7 @@ path = "../codegen" optional = true [dependencies.shuttle-common] -version = "0.7.3" -path = "../common" -default-features = false +workspace = true [dev-dependencies] portpicker = "0.1.1"