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 runtime version field #1826

Merged
merged 3 commits into from
Jul 18, 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
15 changes: 13 additions & 2 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use indoc::{formatdoc, printdoc};
use shuttle_common::{
constants::{
API_URL_DEFAULT, DEFAULT_IDLE_MINUTES, EXAMPLES_REPO, EXECUTABLE_DIRNAME,
RESOURCE_SCHEMA_VERSION, SHUTTLE_GH_ISSUE_URL, SHUTTLE_IDLE_DOCS_URL,
RESOURCE_SCHEMA_VERSION, RUNTIME_NAME, SHUTTLE_GH_ISSUE_URL, SHUTTLE_IDLE_DOCS_URL,
SHUTTLE_INSTALL_DOCS_URL, SHUTTLE_LOGIN_URL, STORAGE_DIRNAME, TEMPLATES_SCHEMA_VERSION,
},
deployment::{EcsState, DEPLOYER_END_MESSAGES_BAD, DEPLOYER_END_MESSAGES_GOOD},
Expand Down Expand Up @@ -1897,7 +1897,7 @@ impl Shuttle {
// TODO: support overriding this
let package = packages
.first()
.expect("at least one shuttle crate in the workspace");
.expect("Expected at least one crate with shuttle-runtime in the workspace");
let package_name = package.name.to_owned();
rust_build_args.package_name = Some(package_name);

Expand All @@ -1910,6 +1910,17 @@ impl Shuttle {
rust_build_args.no_default_features = no_default_features;
rust_build_args.features = features.map(|v| v.join(","));

rust_build_args.shuttle_runtime_version = package
.dependencies
.iter()
.find(|dependency| dependency.name == RUNTIME_NAME)
.expect("shuttle package to have runtime dependency")
.req
.comparators
.first()
// is "^0.X.0" when `shuttle-runtime = "0.X.0"` is in Cargo.toml
.and_then(|c| c.to_string().strip_prefix('^').map(ToOwned::to_owned));

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

deployment_req_buildarch_beta.build_args = Some(BuildArgsBeta::Rust(rust_build_args));
Expand Down
3 changes: 3 additions & 0 deletions common/src/models/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ pub enum BuildArgsBeta {

#[derive(Deserialize, Serialize)]
pub struct BuildArgsRustBeta {
/// Version of shuttle-runtime used by this crate
pub shuttle_runtime_version: Option<String>,
/// Use the built in cargo chef setup for caching
pub cargo_chef: bool,
/// Build with the built in `cargo build` setup
Expand All @@ -322,6 +324,7 @@ pub struct BuildArgsRustBeta {
impl Default for BuildArgsRustBeta {
fn default() -> Self {
Self {
shuttle_runtime_version: Default::default(),
cargo_chef: true,
cargo_build: true,
package_name: Default::default(),
Expand Down