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

alt: shared target folder for faster CI #42

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 3 additions & 1 deletion cargo-near/src/cargo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ impl CrateMetadata {

let absolute_manifest_dir = manifest_path.directory()?;
let absolute_workspace_root = metadata.workspace_root.canonicalize()?;
if absolute_manifest_dir != absolute_workspace_root {
if std::env::var("CARGO_NEAR_FORCE_WORKSPACE").map_or(false, |v| v == "1")
|| absolute_manifest_dir != absolute_workspace_root
{
// If the contract is a package in a workspace, we use the package name
// as the name of the sub-folder where we put the `.contract` bundle.
target_directory = target_directory.join(package_name);
Expand Down
5 changes: 4 additions & 1 deletion integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ macro_rules! generate_abi {
let lib_rs_path = src_dir.join("lib.rs");
fs::write(lib_rs_path, lib_rs)?;

std::env::set_var("CARGO_TARGET_DIR", workspace_dir.join("target"));
std::env::set_var("CARGO_NEAR_FORCE_WORKSPACE", "1");

cargo_near::exec(cargo_near::NearCommand::Abi(cargo_near::AbiCommand {
manifest_path: Some(cargo_path),
doc: false,
out_dir: None,
}))?;

let abi_root: near_abi::AbiRoot =
serde_json::from_slice(&fs::read(workspace_dir.join(function_name!()).join("target").join("near").join("abi.json"))?)?;
serde_json::from_slice(&fs::read(workspace_dir.join("target").join("near").join(function_name!()).join("abi.json"))?)?;
abi_root
}};
(with Cargo $cargo_path:expr; $($code:tt)*) => {
Expand Down