Skip to content

Commit

Permalink
feat: implement workspace inheritance for common & proto
Browse files Browse the repository at this point in the history
this commit also pulls in a PR branch of cargo-chef for compatibility with local workspace dependencies
  • Loading branch information
oddgrd committed Dec 5, 2022
1 parent 014fab9 commit 58f0566
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 35 deletions.
21 changes: 10 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions cargo-shuttle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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/)"
Expand Down
8 changes: 3 additions & 5 deletions deployer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
6 changes: 3 additions & 3 deletions proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shuttle-proto"
version = "0.7.3"
version.workspace = true
edition.workspace = true
license.workspace = true
publish = false
Expand All @@ -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"
3 changes: 1 addition & 2 deletions provisioner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 58f0566

Please sign in to comment.