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: build tests in release profile, limit build workers #514

Merged
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
2 changes: 1 addition & 1 deletion codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "shuttle-codegen"
version = "0.7.2"
edition.workspace = true
licence.workspace = true
license.workspace = true
description = "Proc-macro code generator for the shuttle.rs service"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "shuttle-common"
version.workspace = true
edition.workspace = true
licence.workspace = true
license.workspace = true
description = "Common library for the shuttle platform (https://www.shuttle.rs/)"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
9 changes: 9 additions & 0 deletions deployer/src/deployment/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use super::{Built, QueueReceiver, RunSender, State};
use crate::error::{Error, Result, TestError};
use crate::persistence::{LogLevel, SecretRecorder};

use cargo::util::interning::InternedString;
use cargo_metadata::Message;
use chrono::Utc;
use crossbeam_channel::Sender;
Expand Down Expand Up @@ -312,6 +313,14 @@ async fn run_pre_deploy_tests(
ansi: false,
};

// We set the tests to build with the release profile since deployments compile
// with the release profile by default. This means crates don't need to be
// recompiled in debug mode for the tests, reducing memory usage during deployment.
compile_opts.build_config.requested_profile = InternedString::new("release");

// Build tests with a maximum of 8 workers.
compile_opts.build_config.jobs = 8;

let opts = TestOptions {
compile_opts,
no_run: false,
Expand Down
6 changes: 6 additions & 0 deletions service/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ fn get_compile_options(config: &Config, release_mode: bool) -> anyhow::Result<Co
InternedString::new("dev")
};

// This sets the max workers for cargo build to 8 for release mode (aka deployment),
// but leaves it as default (num cpus) for local runs
if release_mode {
opts.build_config.jobs = 8
};

Ok(opts)
}

Expand Down