Skip to content

Commit

Permalink
ci: upload test network logs
Browse files Browse the repository at this point in the history
Signed-off-by: 0x009922 <[email protected]>
  • Loading branch information
0x009922 committed Sep 30, 2024
1 parent a536a24 commit 574e713
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/iroha2-dev-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ jobs:
env:
RUSTFLAGS: "-C instrument-coverage"
LLVM_PROFILE_FILE: "iroha-%p-%m.profraw"
TEST_NETWORK_TMP_DIR: /tmp
- name: Upload test network logs
if: always()
uses: actions/upload-artifact@v4
with:
name: test_network_logs
path: |
/tmp/irohad_test_network_*
!*/storage
if-no-files-found: 'ignore'
- name: Generate lcov report
if: always()
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "crates/iroha_cli" --ignore "**/main.rs" -o lcov.info
Expand Down
25 changes: 19 additions & 6 deletions crates/iroha_test_network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ fn iroha_bin() -> impl AsRef<Path> {
})
}

const TEMPDIR_PREFIX: &'static str = "irohad_test_network_";
const TEMPDIR_IN_ENV: &str = "TEST_NETWORK_TMP_DIR";

fn tempdir_in() -> Option<impl AsRef<Path>> {
static ENV: OnceLock<Option<PathBuf>> = OnceLock::new();

ENV.get_or_init(|| std::env::var(TEMPDIR_IN_ENV).map(|s| PathBuf::from(s)).ok())
.as_ref()
}

/// Network of peers
pub struct Network {
peers: Vec<NetworkPeer>,
Expand Down Expand Up @@ -444,12 +454,15 @@ impl NetworkPeer {
socket_addr!(127.0.0.1:*port_p2p),
key_pair.public_key().clone(),
);
let temp_dir = Arc::new(
tempfile::Builder::new()
.keep(true)
.tempdir()
.expect("temp dirs are available in the system"),
);
let temp_dir = Arc::new({
let mut builder = tempfile::Builder::new();
builder.keep(true).prefix(TEMPDIR_PREFIX);
match tempdir_in() {
Some(path) => builder.tempdir_in(path),
None => builder.tempdir(),
}
.expect("temp dirs must be available in the system")
});

let (events, _rx) = broadcast::channel(32);
let (block_height, _rx) = watch::channel(None);
Expand Down

0 comments on commit 574e713

Please sign in to comment.