diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ee47c03b..0881a3f2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -51,15 +51,27 @@ jobs: runs-on: ubuntu-latest env: CARGO_FLAGS: --profile ci --features kamu/ftp + KAMU_CONTRACTS_DIR: ../../../kamu-contracts steps: - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: kamu-data/kamu-contracts + path: kamu-contracts + token: ${{ secrets.GH_PAT }} - uses: actions-rs/toolchain@v1 - uses: swatinem/rust-cache@v2 with: cache-on-failure: true - - name: build + - uses: cargo-bins/cargo-binstall@main + - name: Install cargo tools + run: | + cargo binstall cargo-nextest -y --force + - name: Install foundry + uses: foundry-rs/foundry-toolchain@v1 + - name: Build run: cargo test ${{ env.CARGO_FLAGS }} --no-run - - name: run tests - run: cargo test ${{ env.CARGO_FLAGS }} - - name: check git diff + - name: Run tests + run: cargo nextest run + - name: Check git diff run: git diff && git diff-index --quiet HEAD diff --git a/Cargo.lock b/Cargo.lock index bab03c3f..c2f370b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1732,15 +1732,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -4213,7 +4204,6 @@ dependencies = [ "ciborium", "clap", "confique", - "dill", "ethers", "http", "internal-error", @@ -4225,8 +4215,6 @@ dependencies = [ "thiserror", "tokio", "tracing", - "tracing-appender", - "tracing-bunyan-formatter", "tracing-log 0.2.0", "tracing-subscriber", "url", @@ -7053,18 +7041,6 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-appender" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" -dependencies = [ - "crossbeam-channel", - "thiserror", - "time", - "tracing-subscriber", -] - [[package]] name = "tracing-attributes" version = "0.1.27" diff --git a/Makefile b/Makefile index 3efa434a..e4104b14 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +TEST_LOG_PARAMS=RUST_LOG_SPAN_EVENTS=new,close RUST_LOG=debug ############################################################################### # Lint @@ -27,7 +28,12 @@ lint-fix: .PHONY: test test: - cargo test + $(TEST_LOG_PARAMS) cargo nextest run + + +.PHONY: test-no-oracle +test-no-oracle: + $(TEST_LOG_PARAMS) cargo nextest run -E 'not test(::oracle::)' ############################################################################### diff --git a/src/app/oracle-executor/Cargo.toml b/src/app/oracle-executor/Cargo.toml index 648d75d3..f914e2e4 100644 --- a/src/app/oracle-executor/Cargo.toml +++ b/src/app/oracle-executor/Cargo.toml @@ -28,7 +28,6 @@ clap = { version = "4", default-features = false, features = [ "wrap_help", ] } chrono = { version = "0.4", default-features = false, features = ["serde"] } -dill = { version = "0.8", default-features = false } ciborium = { version = "0.2", default-features = false } confique = { version = "0.2", default-features = false, features = ["yaml"] } ethers = { version = "2", default-features = false, features = [ @@ -52,8 +51,6 @@ tokio = { version = "1", default-features = false, features = [ "macros", ] } tracing = { version = "0.1", default-features = false, features = [] } -tracing-appender = "0.2" -tracing-bunyan-formatter = "0.3" tracing-log = "0.2" tracing-subscriber = { version = "0.3", default-features = false, features = [ "ansi", diff --git a/src/app/oracle-executor/src/main.rs b/src/app/oracle-executor/src/main.rs index 08fd2240..976ae6f3 100644 --- a/src/app/oracle-executor/src/main.rs +++ b/src/app/oracle-executor/src/main.rs @@ -9,9 +9,8 @@ use clap::Parser; use kamu_oracle_executor::{Cli, Config}; -use tracing_subscriber::fmt::format::FmtSpan; -use tracing_subscriber::layer::SubscriberExt; -use tracing_subscriber::util::SubscriberInitExt; + +const DEFAULT_RUST_LOG: &str = "RUST_LOG=debug,kamu=trace,hyper=info,h2=info"; fn main() { let args = Cli::parse(); @@ -22,14 +21,7 @@ fn main() { .load() .unwrap(); - tracing_subscriber::registry() - .with( - tracing_subscriber::fmt::layer() - .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE) - .with_ansi(true), - ) - .with(tracing_subscriber::filter::EnvFilter::from_default_env()) - .init(); + configure_tracing(); let rt = tokio::runtime::Builder::new_multi_thread() .enable_all() @@ -44,3 +36,25 @@ fn main() { } } } + +fn configure_tracing() { + use tracing_log::LogTracer; + use tracing_subscriber::fmt::format::FmtSpan; + use tracing_subscriber::layer::SubscriberExt; + use tracing_subscriber::util::SubscriberInitExt; + use tracing_subscriber::EnvFilter; + + let env_filter = EnvFilter::try_from_default_env().unwrap_or(EnvFilter::new(DEFAULT_RUST_LOG)); + + tracing_subscriber::registry() + .with(env_filter) + .with( + tracing_subscriber::fmt::layer() + .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE) + .with_ansi(true), + ) + .init(); + + // Redirect all standard logging to tracing events + LogTracer::init().expect("Failed to set LogTracer"); +} diff --git a/src/app/oracle-executor/tests/tests/test_e2e.rs b/src/app/oracle-executor/tests/tests/test_e2e.rs index 7d62c9af..8306b387 100644 --- a/src/app/oracle-executor/tests/tests/test_e2e.rs +++ b/src/app/oracle-executor/tests/tests/test_e2e.rs @@ -7,6 +7,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +use std::path::PathBuf; use std::sync::Arc; use ethers::prelude::*; @@ -32,14 +33,26 @@ abigen!( ///////////////////////////////////////////////////////////////////////////////////////// +fn get_contracts_dir() -> PathBuf { + let dir = if let Ok(dir) = std::env::var("KAMU_CONTRACTS_DIR") { + PathBuf::from(dir) + } else { + std::fs::canonicalize(".") + .unwrap() + .join("../../../../kamu-contracts") + }; + if !dir.exists() { + panic!("Contracts dir not found at {}", dir.display()); + } + dir +} + +///////////////////////////////////////////////////////////////////////////////////////// + +#[test_group::group(e2e, oracle)] #[test_log::test(tokio::test)] async fn test_e2e() { - let contracts_dir = std::fs::canonicalize(".") - .unwrap() - .join("../../../../kamu-contracts"); - if !contracts_dir.exists() { - panic!("Contracts dir not found at {}", contracts_dir.display()); - } + let contracts_dir = get_contracts_dir(); let anvil = ethers::core::utils::Anvil::new().spawn(); let rpc_endpoint = anvil.endpoint(); @@ -56,7 +69,7 @@ async fn test_e2e() { std::process::Command::new("forge") .current_dir(&contracts_dir) - .args(&[ + .args([ "script", "script/Deploy.s.sol", "--fork-url", @@ -66,7 +79,7 @@ async fn test_e2e() { "--broadcast", ]) .status() - .unwrap() + .expect("Failed to deploy contracts. Is foundry installed?") .exit_ok() .unwrap();