Skip to content

Commit

Permalink
ci: fix using cargo nextest (#2855)
Browse files Browse the repository at this point in the history
## 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

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] 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`.
  • Loading branch information
perekopskiy authored Sep 12, 2024
1 parent 3b5e4a6 commit 527b5ab
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 28 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
- 'etc/**'
- 'contracts/**'
- 'infrastructure/zk/**'
- 'docker/zk-environment/**'
- '!**/*.md'
- '!**/*.MD'
Expand Down
14 changes: 9 additions & 5 deletions core/tests/upgrade-test/tests/upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-cpu-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docker-compose-gpu-runner-cuda-12-0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docker-compose-gpu-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion zk_toolbox/Cargo.lock

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

20 changes: 3 additions & 17 deletions zk_toolbox/crates/zk_supervisor/src/commands/test/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
Expand Down Expand Up @@ -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()
Expand All @@ -84,15 +79,6 @@ pub async fn run(shell: &Shell, args: RustArgs) -> anyhow::Result<()> {
Ok(())
}

fn nextest_is_installed(shell: &Shell) -> anyhow::Result<bool> {
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,
Expand Down
1 change: 0 additions & 1 deletion zk_toolbox/crates/zk_supervisor/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 527b5ab

Please sign in to comment.