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

ci: fix installing nodejs deps in the tests #973

Merged
merged 4 commits into from
Nov 12, 2024
Merged
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
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)
);
}
Loading