Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: beta multi lang deployment models #1820

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ use ignore::WalkBuilder;
use indicatif::ProgressBar;
use indoc::{formatdoc, printdoc};
use shuttle_common::models::deployment::{
BuildArgsBeta, BuildMetaBeta, DeploymentRequestBuildArchiveBeta, DeploymentRequestImageBeta,
BuildArgsBeta, BuildArgsRustBeta, BuildMetaBeta, DeploymentRequestBuildArchiveBeta,
DeploymentRequestImageBeta,
};
use shuttle_common::{
constants::{
Expand Down Expand Up @@ -1849,7 +1850,7 @@ impl Shuttle {
};

if self.beta {
let mut build_args = BuildArgsBeta::default();
let mut rust_build_args = BuildArgsRustBeta::default();

let metadata = async_cargo_metadata(manifest_path.as_path()).await?;
let packages = find_shuttle_packages(&metadata)?;
Expand All @@ -1858,20 +1859,20 @@ impl Shuttle {
.first()
.expect("at least one shuttle crate in the workspace");
let package_name = package.name.to_owned();
build_args.package_name = Some(package_name);
rust_build_args.package_name = Some(package_name);

// activate shuttle feature if present
let (no_default_features, features) = if package.features.contains_key("shuttle") {
(true, Some(vec!["shuttle".to_owned()]))
} else {
(false, None)
};
build_args.no_default_features = no_default_features;
build_args.features = features.map(|v| v.join(","));
rust_build_args.no_default_features = no_default_features;
rust_build_args.features = features.map(|v| v.join(","));

// TODO: determine which (one) binary to build

deployment_req_buildarch_beta.build_args = Some(build_args);
deployment_req_buildarch_beta.build_args = Some(BuildArgsBeta::Rust(rust_build_args));

// TODO: have all of the above be configurable in CLI and Shuttle.toml
}
Expand Down
12 changes: 10 additions & 2 deletions common/src/models/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,16 @@ pub struct DeploymentRequestBuildArchiveBeta {
pub build_meta: Option<BuildMetaBeta>,
}

#[derive(Deserialize, Serialize, Default)]
#[serde(tag = "type", content = "content")]
pub enum BuildArgsBeta {
Rust(BuildArgsRustBeta),
#[default]
Unknown,
}

#[derive(Deserialize, Serialize)]
pub struct BuildArgsBeta {
pub struct BuildArgsRustBeta {
/// Use the built in cargo chef setup for caching
pub cargo_chef: bool,
/// Build with the built in `cargo build` setup
Expand All @@ -329,7 +337,7 @@ pub struct BuildArgsBeta {
pub mold: bool,
}

impl Default for BuildArgsBeta {
impl Default for BuildArgsRustBeta {
fn default() -> Self {
Self {
cargo_chef: true,
Expand Down