Skip to content

Commit

Permalink
fix: make netsim run from examples (#2959)
Browse files Browse the repository at this point in the history
## Description

Moves our netsim tests to run from an example and only test the lib part
of the code, not the full CLI & blobs.

Things left to do:
- [x] rename the example from `new` to anything that makes more sense
`netsim` runs it under `iroh-transfer`
- [x] clean up the example code
- [x] add the option to provide either a relay config or pass in at
least the relay url as an argument
- [x] continue the CI adjustment and move all invocations of the netsim
runner to run from `iroh_v2` and `integration_v2` sims (we want a less
abrupt netsim switchover)
- [x] convert the remaining sims in `chuck/netsim/sims` to the new
format
- [ ] after some time flip back the CI invocations to be regular `iroh`
and `integration` sims which includes doing the same on `netsim` and
removing the old ones

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist

- [ ] Self-review.
- [ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [ ] Tests if relevant.
- [ ] All breaking changes documented.
  • Loading branch information
Arqu authored Nov 25, 2024
1 parent 84bca40 commit f4adb94
Show file tree
Hide file tree
Showing 7 changed files with 345 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ jobs:
# TODO: We have a bunch of platform-dependent code so should
# probably run this job on the full platform matrix
- name: clippy check (all features)
run: cargo clippy --workspace --all-features --all-targets --bins --tests --benches
run: cargo clippy --workspace --all-features --all-targets --lib --bins --tests --benches --examples

- name: clippy check (no features)
run: cargo clippy --workspace --no-default-features --lib --bins --tests
run: cargo clippy --workspace --no-default-features --all-targets --lib --bins --tests --benches --examples

- name: clippy check (default features)
run: cargo clippy --workspace --all-targets
run: cargo clippy --workspace --all-targets --lib --bins --tests --benches --examples

msrv:
if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')"
Expand Down Expand Up @@ -295,7 +295,7 @@ jobs:
branch: ${{ github.ref }}
max_workers: 4
netsim_branch: "main"
sim_paths: "sims/iroh/iroh.json,sims/integration"
sim_paths: "sims/iroh_v2/iroh.json,sims/integration_v2"
pr_number: ${{ github.event.pull_request.number || '' }}

codespell:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/netsim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
branch: "main"
max_workers: 1
netsim_branch: "main"
sim_paths: "sims/iroh,sims/integration"
sim_paths: "sims/iroh_v2,sims/integration_v2"
pr_number: ""
publish_metrics: true
build_profile: "optimized-release"
Expand All @@ -53,7 +53,7 @@ jobs:
branch: ${{inputs.branch}}
max_workers: 1
netsim_branch: ${{inputs.netsim_branch}}
sim_paths: "sims/iroh"
sim_paths: "sims/iroh_v2"
pr_number: ${{inputs.pr_number}}
publish_metrics: false
build_profile: "optimized-release"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/netsim_runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
- name: Copy binaries to right location
run: |
cp target/${{inputs.build_profile}}/examples/* ../chuck/netsim/bins/
cp target/${{inputs.build_profile}}/iroh ../chuck/netsim/bins/iroh
cp target/${{inputs.build_profile}}/examples/transfer ../chuck/netsim/bins/iroh-transfer
cp target/${{inputs.build_profile}}/iroh-relay ../chuck/netsim/bins/iroh-relay
cp ../chuck/target/release/chuck ../chuck/netsim/bins/chuck
Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion iroh-net/bench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub mod s2n;
pub mod stats;

#[derive(Parser, Debug, Clone, Copy)]
#[clap(name = "bulk")]
#[clap(name = "iroh-net-bench")]
pub enum Commands {
Iroh(Opt),
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
Expand Down
7 changes: 6 additions & 1 deletion iroh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ ref-cast = "1.0.23"
# Examples
clap = { version = "4", features = ["derive"], optional = true }
indicatif = { version = "0.17", features = ["tokio"], optional = true }
parse-size = { version = "=1.0.0", optional = true } # pinned version to avoid bumping msrv to 1.81

# Documentation tests
url = { version = "2.5.0", features = ["serde"] }
Expand All @@ -74,7 +75,7 @@ test = []
discovery-pkarr-dht = ["iroh-net/discovery-pkarr-dht"]
test-utils = ["iroh-net/test-utils"]

examples = ["dep:clap", "dep:indicatif"]
examples = ["dep:clap", "dep:indicatif", "dep:parse-size"]

[dev-dependencies]
anyhow = { version = "1" }
Expand All @@ -101,3 +102,7 @@ rustdoc-args = ["--cfg", "iroh_docsrs"]
[[example]]
name = "rpc"
required-features = ["examples"]

[[example]]
name = "transfer"
required-features = ["examples"]
Loading

0 comments on commit f4adb94

Please sign in to comment.