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
Show file tree
Hide file tree
Changes from 3 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
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ evm-core = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.
evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.46.1-aurora", default-features = false, features = ["std", "tracing"] }
evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.46.1-aurora", default-features = false, features = ["std", "tracing"] }
fixed-hash = { version = "0.8", default-features = false }
fslock = "0.2"
function_name = "0.3"
git2 = "0.19"
hex = { version = "0.4", default-features = false, features = ["alloc"] }
Expand Down
1 change: 1 addition & 0 deletions engine-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ evm-gasometer.workspace = true
evm-runtime.workspace = true
git2.workspace = true
hex.workspace = true
fslock.workspace = true
libsecp256k1.workspace = true
near-crypto.workspace = true
near-parameters.workspace = true
Expand Down
45 changes: 27 additions & 18 deletions engine-tests/src/utils/one_inch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ 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 target_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("target");
let lock_file = target_dir.join(format!("{repo_name}.lock"));
// Using a file lock to prevent parallel execution from the different processes in GitHub CI.
let mut lock = fslock::LockFile::open(&lock_file).unwrap();

lock.lock().unwrap();

let sources_dir = target_dir.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 +38,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 +47,24 @@ 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");

lock.unlock().unwrap();

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