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

test: integration tests, doc tests and improve coverage #242

Merged
merged 13 commits into from
Jul 11, 2024
Merged
57 changes: 53 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
files: codecov.json
fail_ci_if_error: true

contract-integration-tests:
documentation-tests:
needs: lint
runs-on: ubuntu-latest
steps:
Expand All @@ -98,18 +98,67 @@ jobs:
with:
git-user: ${{ env.GITHUB_ACTOR }}

- name: Run doc tests
run: cargo test --doc

contract-integration-tests:
needs: lint
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rust-src, clippy

- name: Cache
uses: Swatinem/rust-cache@v2

- name: Run integration tests
run: cargo test --no-default-features --features contract --test contract

parachain-integration-tests:
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- uses: "./.github/actions/init"
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rust-src, clippy

- name: Cache
uses: Swatinem/rust-cache@v2

- name: Install packages (Linux)
if: matrix.os == 'ubuntu-latest'
uses: "./.github/actions/init"
with:
git-user: ${{ env.GITHUB_ACTOR }}

- name: Install packages (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install protobuf
protoc --version

- name: Run integration tests
run: cargo test --no-default-features --features parachain --test parachain
37 changes: 37 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 @@ -34,6 +34,7 @@ predicates = "3.1.0"
tar = "0.4.40"
tempfile = "3.10"
thiserror = "1.0.58"
tokio-test = "0.4.4"

# networking
reqwest = { version = "0.12", features = ["json"] }
Expand Down
13 changes: 10 additions & 3 deletions crates/pop-cli/src/commands/up/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ use pop_contracts::{
};
use sp_core::Bytes;
use sp_weights::Weight;
use std::path::{Path, PathBuf};
use std::process::Child;
use std::{
path::{Path, PathBuf},
process::Command,
};
use tempfile::NamedTempFile;
use url::Url;

Expand Down Expand Up @@ -259,14 +262,18 @@ impl UpContractCommand {
/// Handles the optional termination of a local running node.
fn terminate_node(process: Option<(Child, NamedTempFile)>) -> anyhow::Result<()> {
// Prompt to close any launched node
let Some((mut process, log)) = process else {
let Some((process, log)) = process else {
return Ok(());
};
if confirm("Would you like to terminate the local node?")
.initial_value(true)
.interact()?
{
process.kill()?
// Stop the process contracts-node
Command::new("kill")
.args(["-s", "TERM", &process.id().to_string()])
.spawn()?
.wait()?;
} else {
log.keep()?;
log::warning(format!("NOTE: The node is running in the background with process ID {}. Please terminate it manually when done.", process.id()))?;
Expand Down
37 changes: 23 additions & 14 deletions crates/pop-cli/src/commands/up/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ pub(crate) struct ZombienetCommand {
/// Whether the output should be verbose.
#[arg(short, long, action)]
verbose: bool,
/// Automatically source all needed binaries required without prompting for confirmation.
#[clap(short('y'), long)]
skip_confirm: bool,
}

impl ZombienetCommand {
Expand Down Expand Up @@ -83,7 +86,7 @@ impl ZombienetCommand {
};

// Source any missing/stale binaries
if Self::source_binaries(&mut zombienet, &cache, self.verbose).await? {
if Self::source_binaries(&mut zombienet, &cache, self.verbose, self.skip_confirm).await? {
return Ok(());
}

Expand Down Expand Up @@ -159,6 +162,7 @@ impl ZombienetCommand {
zombienet: &mut Zombienet,
cache: &PathBuf,
verbose: bool,
skip_confirm: bool,
) -> anyhow::Result<bool> {
// Check for any missing or stale binaries
let binaries: Vec<_> = zombienet.binaries().filter(|b| !b.exists() || b.stale()).collect();
Expand Down Expand Up @@ -197,15 +201,17 @@ impl ZombienetCommand {
))
.dim()
.to_string();
if !confirm(format!(
if !skip_confirm {
if !confirm(format!(
"📦 Would you like to source them automatically now? It may take some time...\n {list}"))
.initial_value(true)
.interact()?
{
outro_cancel(
.initial_value(true)
.interact()?
{
outro_cancel(
"🚫 Cannot launch the specified network until all required binaries are available.",
)?;
return Ok(true);
return Ok(true);
}
}
}

Expand Down Expand Up @@ -235,13 +241,16 @@ impl ZombienetCommand {
log::warning(format!(
"ℹ️ The following binaries have newer versions available:\n {list}"
))?;

latest = confirm(
"📦 Would you like to source them automatically now? It may take some time..."
.to_string(),
)
.initial_value(true)
.interact()?;
if !skip_confirm {
latest = confirm(
"📦 Would you like to source them automatically now? It may take some time..."
.to_string(),
)
.initial_value(true)
.interact()?;
} else {
latest = true;
}
}

let binaries: Vec<_> = binaries
Expand Down
Loading
Loading