Skip to content

Commit

Permalink
feat: build tests in release profile, limit build workers (#514)
Browse files Browse the repository at this point in the history
* feat: build tests in release profile, limit build workers

* fix: typo in manifests
  • Loading branch information
oddgrd authored Dec 9, 2022
1 parent 7525c7a commit a37903a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
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

0 comments on commit a37903a

Please sign in to comment.