Skip to content

Commit

Permalink
ci: fix installing nodejs deps in the tests (#973)
Browse files Browse the repository at this point in the history
## Description

The PR fixes breaking tests that are related to the execution in the CI
only.
  • Loading branch information
aleksuss committed Feb 5, 2025
1 parent b09898c commit 3827f88
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions engine-tests/src/utils/one_inch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ pub static LIMIT_ORDER_PROTOCOL_PATH: LazyLock<PathBuf> =
LazyLock::new(|| download_and_compile_solidity_sources("limit-order-protocol"));

fn download_and_compile_solidity_sources(repo_name: &str) -> PathBuf {
let sources_dir = Path::new("target").join(repo_name);

let sources_dir = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("target")
.join(repo_name);
// Contracts not already present, so download and compile them (but only once, even
// if multiple tests running in parallel saw `contracts_dir` does not exist).
if !sources_dir.exists() {
let url = format!("https://github.com/1inch/{repo_name}");
let repo = git2::Repository::clone(&url, &sources_dir).unwrap();

if repo_name == "limit-order-protocol" {
let commit_hash = git2::Oid::from_str(HASH_COMMIT).unwrap();
repo.set_head_detached(commit_hash).unwrap();
Expand All @@ -31,7 +33,7 @@ fn download_and_compile_solidity_sources(repo_name: &str) -> PathBuf {
// install packages
let output = Command::new("/usr/bin/env")
.current_dir(&sources_dir)
.args(["yarn", "install", "--network-concurrency", "1"])
.args(["yarn", "install"])
.output()
.unwrap();
assert!(
Expand All @@ -40,22 +42,22 @@ fn download_and_compile_solidity_sources(repo_name: &str) -> PathBuf {
String::from_utf8_lossy(&output.stderr),
);

let hardhat = |command: &str| {
let output = Command::new("/usr/bin/env")
.current_dir(&sources_dir)
.args(["node", "node_modules/hardhat/internal/cli/cli.js", command])
.output()
.unwrap();
assert!(
output.status.success(),
"Unsuccessful exit status while install while executing `{command}`: {}",
String::from_utf8_lossy(&output.stderr)
);
};

// clean and compile
hardhat("clean");
hardhat("compile");
// clean and compile EVM contracts
hardhat(&sources_dir, "clean");
hardhat(&sources_dir, "compile");

sources_dir.join("artifacts/contracts")
}

fn hardhat(sources_dir: impl AsRef<Path>, command: &str) {
let output = Command::new("/usr/bin/env")
.current_dir(sources_dir)
.args(["node", "node_modules/hardhat/internal/cli/cli.js", command])
.output()
.unwrap();
assert!(
output.status.success(),
"Unsuccessful exit status while install while executing `{command}`: {}",
String::from_utf8_lossy(&output.stderr)
);
}

0 comments on commit 3827f88

Please sign in to comment.