Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/shuttle-next' into ci/ci-go-green
Browse files Browse the repository at this point in the history
  • Loading branch information
chesedo committed Mar 10, 2023
2 parents b02e595 + 4e1690d commit e541499
Show file tree
Hide file tree
Showing 75 changed files with 1,058 additions and 1,649 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ jobs:
- run: |
cargo clippy --tests \
--all-targets \
--features="codegen,loader,<< parameters.framework >>" \
--features="codegen,builder,<< parameters.framework >>" \
--no-deps -- \
--D warnings \
-A clippy::let-unit-value \
Expand Down Expand Up @@ -210,10 +210,10 @@ jobs:
- restore-cargo-cache
- run:
name: Run unit tests
command: cargo test --package shuttle-service --features="codegen,loader" --lib -- --nocapture
command: cargo test --package shuttle-service --features="codegen,builder" --lib -- --nocapture
- run:
name: Run integration tests
command: cargo test --package shuttle-service --features="codegen,loader" --test '*' -- --nocapture
command: cargo test --package shuttle-service --features="codegen,builder" --test '*' -- --nocapture
- save-cargo-cache
platform-test:
parameters:
Expand Down
24 changes: 6 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cargo-shuttle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ path = "../resources/secrets"

[dependencies.shuttle-service]
workspace = true
features = ["loader"]
features = ["builder"]

[features]
vendored-openssl = ["openssl/vendored"]
Expand Down
85 changes: 47 additions & 38 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use git2::{Repository, StatusOptions};
use ignore::overrides::OverrideBuilder;
use ignore::WalkBuilder;
use shuttle_common::models::{project, secret};
use shuttle_service::loader::{build_crate, Runtime};
use shuttle_service::builder::{build_crate, Runtime};
use std::fmt::Write;
use strum::IntoEnumIterator;
use tar::Builder;
Expand Down Expand Up @@ -376,15 +376,15 @@ impl Shuttle {
});

let working_directory = self.ctx.working_directory();
let id = Default::default();

trace!("building project");
println!(
"{:>12} {}",
"Building".bold().green(),
working_directory.display()
);
let runtime = build_crate(id, working_directory, false, tx).await?;

let runtime = build_crate(working_directory, false, tx).await?;

trace!("loading secrets");
let secrets_path = working_directory.join("Secrets.toml");
Expand All @@ -404,7 +404,7 @@ impl Shuttle {

let service_name = self.ctx.project_name().to_string();

let (is_wasm, so_path) = match runtime {
let (is_wasm, bin_path) = match runtime {
Runtime::Next(path) => (true, path),
Runtime::Legacy(path) => (false, path),
};
Expand All @@ -415,52 +415,62 @@ impl Shuttle {
run_args.port + 1,
));

let get_runtime_executable = || {
let runtime_path = home::cargo_home()
.expect("failed to find cargo home dir")
.join("bin/shuttle-runtime");

if cfg!(debug_assertions) {
// Canonicalized path to shuttle-runtime for dev to work on windows
let path = std::fs::canonicalize(format!("{MANIFEST_DIR}/../runtime"))
.expect("path to shuttle-runtime does not exist or is invalid");

std::process::Command::new("cargo")
.arg("install")
.arg("shuttle-runtime")
.arg("--path")
.arg(path)
.output()
.expect("failed to install the shuttle runtime");
} else {
// If the version of cargo-shuttle is different from shuttle-runtime,
// or it isn't installed, try to install shuttle-runtime from the production
// branch.
if let Err(err) = check_version(&runtime_path) {
trace!("{}", err);
let runtime_path = || {
if is_wasm {
let runtime_path = home::cargo_home()
.expect("failed to find cargo home dir")
.join("bin/shuttle-next");

if cfg!(debug_assertions) {
// Canonicalized path to shuttle-runtime for dev to work on windows
let path = std::fs::canonicalize(format!("{MANIFEST_DIR}/../runtime"))
.expect("path to shuttle-runtime does not exist or is invalid");

trace!("installing shuttle-runtime");
// TODO: Add --features next here when https://github.com/shuttle-hq/shuttle/pull/688 is merged
std::process::Command::new("cargo")
.arg("install")
.arg("shuttle-runtime")
.arg("--git")
.arg("https://github.com/shuttle-hq/shuttle")
.arg("--branch")
.arg("production")
.arg("--path")
.arg(path)
.arg("--bin")
.arg("shuttle-next")
.output()
.expect("failed to install the shuttle runtime");
} else {
// If the version of cargo-shuttle is different from shuttle-runtime,
// or it isn't installed, try to install shuttle-runtime from the production
// branch.
if let Err(err) = check_version(&runtime_path) {
trace!("{}", err);

trace!("installing shuttle-runtime");
// TODO: Add --features next here when https://github.com/shuttle-hq/shuttle/pull/688 is merged
std::process::Command::new("cargo")
.arg("install")
.arg("shuttle-runtime")
.arg("--bin")
.arg("shuttle-next")
.arg("--git")
.arg("https://github.com/shuttle-hq/shuttle")
.arg("--branch")
.arg("production")
.output()
.expect("failed to install the shuttle runtime");
};
};
};

runtime_path
runtime_path
} else {
bin_path.clone()
}
};

let (mut runtime, mut runtime_client) = runtime::start(
is_wasm,
runtime::StorageManagerType::WorkingDir(working_directory.to_path_buf()),
&format!("http://localhost:{}", run_args.port + 1),
run_args.port + 2,
get_runtime_executable,
runtime_path,
)
.await
.map_err(|err| {
Expand All @@ -470,7 +480,7 @@ impl Shuttle {
})?;

let load_request = tonic::Request::new(LoadRequest {
path: so_path
path: bin_path
.into_os_string()
.into_string()
.expect("to convert path to string"),
Expand Down Expand Up @@ -515,8 +525,7 @@ impl Shuttle {
let addr = SocketAddr::new(addr, run_args.port);

let start_request = StartRequest {
deployment_id: id.as_bytes().to_vec(),
service_name,
deployment_id: Uuid::default().as_bytes().to_vec(),
ip: addr.to_string(),
};

Expand Down
Loading

0 comments on commit e541499

Please sign in to comment.