Skip to content

Commit

Permalink
feat: beta runtime version field (#1826)
Browse files Browse the repository at this point in the history
* feat: runtime version field

* feat: determine runtime version

* nit
  • Loading branch information
jonaro00 authored Jul 18, 2024
1 parent 1d8a281 commit f72134c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
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

0 comments on commit f72134c

Please sign in to comment.