From 527b5ab8052bfb5e7ff7c3a54747b1470c69fafa Mon Sep 17 00:00:00 2001 From: perekopskiy <53865202+perekopskiy@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:37:57 +0300 Subject: [PATCH] ci: fix using cargo nextest (#2855) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ `cargo install --list` doesn't work properly in CI because we copy only binaries to zk-environment also increase reth block-time and fixes upgrade-test which improves tests stability ## Why ❔ we rely on cargo-nextest in tests ## Checklist - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`. --- .github/workflows/ci.yml | 1 + core/tests/upgrade-test/tests/upgrade.test.ts | 14 ++++++++----- docker-compose-cpu-runner.yml | 2 +- docker-compose-gpu-runner-cuda-12-0.yml | 2 +- docker-compose-gpu-runner.yml | 2 +- docker-compose.yml | 2 +- zk_toolbox/Cargo.lock | 1 - .../zk_supervisor/src/commands/test/rust.rs | 20 +++---------------- .../crates/zk_supervisor/src/messages.rs | 1 - 9 files changed, 17 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53c16911491..e05b84cda97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,6 +76,7 @@ jobs: - 'etc/**' - 'contracts/**' - 'infrastructure/zk/**' + - 'docker/zk-environment/**' - '!**/*.md' - '!**/*.MD' diff --git a/core/tests/upgrade-test/tests/upgrade.test.ts b/core/tests/upgrade-test/tests/upgrade.test.ts index 0f70e751b84..2e223b9d744 100644 --- a/core/tests/upgrade-test/tests/upgrade.test.ts +++ b/core/tests/upgrade-test/tests/upgrade.test.ts @@ -89,25 +89,29 @@ describe('Upgrade test', function () { alice = tester.emptyWallet(); if (fileConfig.loadFromFile) { - let walletConfig = loadConfig({ pathToHome, chain: fileConfig.chain, config: 'wallets.yaml' }); + const chainWalletConfig = loadConfig({ pathToHome, chain: fileConfig.chain, config: 'wallets.yaml' }); - adminGovWallet = new ethers.Wallet(walletConfig.governor.private_key, alice._providerL1()); + adminGovWallet = new ethers.Wallet(chainWalletConfig.governor.private_key, alice._providerL1()); - walletConfig = loadConfig({ + const ecosystemWalletConfig = loadConfig({ pathToHome, chain: fileConfig.chain, configsFolder: '../../configs/', config: 'wallets.yaml' }); - ecosystemGovWallet = new ethers.Wallet(walletConfig.governor.private_key, alice._providerL1()); + if (ecosystemWalletConfig.governor.private_key == chainWalletConfig.governor.private_key) { + ecosystemGovWallet = adminGovWallet; + } else { + ecosystemGovWallet = new ethers.Wallet(ecosystemWalletConfig.governor.private_key, alice._providerL1()); + } } else { let govMnemonic = ethers.Mnemonic.fromPhrase( require('../../../../etc/test_config/constant/eth.json').mnemonic ); let govWalletHD = ethers.HDNodeWallet.fromMnemonic(govMnemonic, "m/44'/60'/0'/0/1"); adminGovWallet = new ethers.Wallet(govWalletHD.privateKey, alice._providerL1()); - ecosystemGovWallet = new ethers.Wallet(govWalletHD.privateKey, alice._providerL1()); + ecosystemGovWallet = adminGovWallet; } logs = fs.createWriteStream('upgrade.log', { flags: 'a' }); diff --git a/docker-compose-cpu-runner.yml b/docker-compose-cpu-runner.yml index beb54f3ade9..e0f751130eb 100644 --- a/docker-compose-cpu-runner.yml +++ b/docker-compose-cpu-runner.yml @@ -11,7 +11,7 @@ services: source: ./etc/reth/chaindata target: /chaindata - command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 300ms --chain /chaindata/reth_config + command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 600ms --chain /chaindata/reth_config ports: - 127.0.0.1:8545:8545 diff --git a/docker-compose-gpu-runner-cuda-12-0.yml b/docker-compose-gpu-runner-cuda-12-0.yml index 35a0faeb962..f2089446a41 100644 --- a/docker-compose-gpu-runner-cuda-12-0.yml +++ b/docker-compose-gpu-runner-cuda-12-0.yml @@ -11,7 +11,7 @@ services: source: ./etc/reth/chaindata target: /chaindata - command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 300ms --chain /chaindata/reth_config + command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 600ms --chain /chaindata/reth_config ports: - 127.0.0.1:8545:8545 diff --git a/docker-compose-gpu-runner.yml b/docker-compose-gpu-runner.yml index f95ae0d5f54..35c6c3778f2 100644 --- a/docker-compose-gpu-runner.yml +++ b/docker-compose-gpu-runner.yml @@ -11,7 +11,7 @@ services: source: ./etc/reth/chaindata target: /chaindata - command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 300ms --chain /chaindata/reth_config + command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 600ms --chain /chaindata/reth_config ports: - 127.0.0.1:8545:8545 diff --git a/docker-compose.yml b/docker-compose.yml index 1e3a273ec9a..7e1b52f8334 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: source: ./etc/reth/chaindata target: /chaindata - command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 300ms --chain /chaindata/reth_config + command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 600ms --chain /chaindata/reth_config postgres: diff --git a/zk_toolbox/Cargo.lock b/zk_toolbox/Cargo.lock index 75859021979..7c53e2747da 100644 --- a/zk_toolbox/Cargo.lock +++ b/zk_toolbox/Cargo.lock @@ -6539,7 +6539,6 @@ dependencies = [ "bigdecimal", "futures", "hex", - "itertools 0.10.5", "num", "once_cell", "reqwest 0.12.5", diff --git a/zk_toolbox/crates/zk_supervisor/src/commands/test/rust.rs b/zk_toolbox/crates/zk_supervisor/src/commands/test/rust.rs index ad1318cfa76..c42f95e8e3b 100644 --- a/zk_toolbox/crates/zk_supervisor/src/commands/test/rust.rs +++ b/zk_toolbox/crates/zk_supervisor/src/commands/test/rust.rs @@ -12,7 +12,7 @@ use crate::{ dals::{Dal, CORE_DAL_PATH, PROVER_DAL_PATH}, defaults::{TEST_DATABASE_PROVER_URL, TEST_DATABASE_SERVER_URL}, messages::{ - MSG_CARGO_NEXTEST_MISSING_ERR, MSG_CHAIN_NOT_FOUND_ERR, MSG_POSTGRES_CONFIG_NOT_FOUND_ERR, + MSG_CHAIN_NOT_FOUND_ERR, MSG_POSTGRES_CONFIG_NOT_FOUND_ERR, MSG_RESETTING_TEST_DATABASES, MSG_UNIT_TESTS_RUN_SUCCESS, MSG_USING_CARGO_NEXTEST, }, }; @@ -61,13 +61,8 @@ pub async fn run(shell: &Shell, args: RustArgs) -> anyhow::Result<()> { let _dir_guard = shell.push_dir(&link_to_code); - let cmd = if nextest_is_installed(shell)? { - logger::info(MSG_USING_CARGO_NEXTEST); - cmd!(shell, "cargo nextest run --release") - } else { - logger::error(MSG_CARGO_NEXTEST_MISSING_ERR); - cmd!(shell, "cargo test --release") - }; + logger::info(MSG_USING_CARGO_NEXTEST); + let cmd = cmd!(shell, "cargo nextest run --release"); let cmd = if let Some(options) = args.options { Cmd::new(cmd.args(options.split_whitespace())).with_force_run() @@ -84,15 +79,6 @@ pub async fn run(shell: &Shell, args: RustArgs) -> anyhow::Result<()> { Ok(()) } -fn nextest_is_installed(shell: &Shell) -> anyhow::Result { - let out = String::from_utf8( - Cmd::new(cmd!(shell, "cargo install --list")) - .run_with_output()? - .stdout, - )?; - Ok(out.contains("cargo-nextest")) -} - async fn reset_test_databases( shell: &Shell, link_to_code: &Path, diff --git a/zk_toolbox/crates/zk_supervisor/src/messages.rs b/zk_toolbox/crates/zk_supervisor/src/messages.rs index d64e87cd0eb..89cf8c1d9b6 100644 --- a/zk_toolbox/crates/zk_supervisor/src/messages.rs +++ b/zk_toolbox/crates/zk_supervisor/src/messages.rs @@ -99,7 +99,6 @@ pub(super) const MSG_TESTS_RECOVERY_SNAPSHOT_HELP: &str = "Run recovery from a snapshot instead of genesis"; pub(super) const MSG_UNIT_TESTS_RUN_SUCCESS: &str = "Unit tests ran successfully"; pub(super) const MSG_USING_CARGO_NEXTEST: &str = "Using cargo-nextest for running tests"; -pub(super) const MSG_CARGO_NEXTEST_MISSING_ERR: &str = "cargo-nextest is missing, please run 'cargo install cargo-nextest'. Falling back to 'cargo test'"; pub(super) const MSG_L1_CONTRACTS_ABOUT: &str = "Run L1 contracts tests"; pub(super) const MSG_L1_CONTRACTS_TEST_SUCCESS: &str = "L1 contracts tests ran successfully"; pub(super) const MSG_PROVER_TEST_ABOUT: &str = "Run prover tests";