Skip to content

chore: check external types in CI#643

Merged
Frando merged 4 commits into
mainfrom
Frando/check-external-types
May 11, 2026
Merged

chore: check external types in CI#643
Frando merged 4 commits into
mainfrom
Frando/check-external-types

Conversation

@Frando
Copy link
Copy Markdown
Member

@Frando Frando commented May 7, 2026

Description

This adds a cargo make task and CI job to ensure that no foreign crates appear in the public API apart from those explicitly allow-listed.

Change checklist

  • Self-review.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Performance Comparison Report

aa29e0e3ea7ebb1b4fdaaed3ac4594fe8b0bbb23 - artifacts

No results available

---
5ad40b1148f4a429279212ec70864e5d8d9be974 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5937.2 Mbps 7922.1 Mbps -25.1% 97.3% / 98.8%
medium-concurrent 5489.8 Mbps 7768.1 Mbps -29.3% 96.4% / 97.9%
medium-single 4159.1 Mbps 4748.9 Mbps -12.4% 96.7% / 99.0%
small-concurrent 3851.0 Mbps 5250.4 Mbps -26.7% 98.0% / 99.9%
small-single 3496.0 Mbps 4774.1 Mbps -26.8% 96.5% / 98.7%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3072.3 Mbps 4078.6 Mbps -24.7%
lan 782.4 Mbps 800.8 Mbps -2.3%
lossy 69.8 Mbps 55.9 Mbps +24.9%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 24.1% slower on average

---
428d2610874ba82d607c26d94271eb9549029a98 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5403.7 Mbps 7866.1 Mbps -31.3% 94.9% / 98.8%
medium-concurrent 5259.5 Mbps 7632.0 Mbps -31.1% 95.0% / 99.6%
medium-single 3591.4 Mbps 4750.0 Mbps -24.4% 96.8% / 150.0%
small-concurrent 3838.1 Mbps 5288.0 Mbps -27.4% 91.3% / 99.5%
small-single 3464.0 Mbps 4827.8 Mbps -28.2% 92.6% / 101.0%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3072.9 Mbps 4121.2 Mbps -25.4%
lan 782.4 Mbps 810.4 Mbps -3.5%
lossy 69.9 Mbps 69.8 Mbps ~0%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 27.9% slower on average

---
ec9ab8bfdab7cf293e25449cc1944190584adcd6 - artifacts

Raw Benchmarks (localhost)

Scenario noq upstream Delta CPU (avg/max)
large-single 5461.4 Mbps 8051.5 Mbps -32.2% 98.2% / 149.0%
medium-concurrent 5441.7 Mbps 7930.1 Mbps -31.4% 97.2% / 148.0%
medium-single 4271.6 Mbps 4658.7 Mbps -8.3% 93.5% / 101.0%
small-concurrent 3861.4 Mbps 5251.6 Mbps -26.5% 95.6% / 102.0%
small-single 3564.2 Mbps 4733.1 Mbps -24.7% 98.9% / 153.0%

Netsim Benchmarks (network simulation)

Condition noq upstream Delta
ideal 3073.2 Mbps 4064.5 Mbps -24.4%
lan 782.4 Mbps 810.4 Mbps -3.5%
lossy 69.8 Mbps 55.8 Mbps +25.1%
wan 83.8 Mbps 83.8 Mbps ~0%

Summary

noq is 25.3% slower on average

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/noq/pr/643/docs/noq/

Last updated: 2026-05-11T12:37:18Z

@n0bot n0bot Bot added this to iroh May 7, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh May 7, 2026
Copy link
Copy Markdown
Collaborator

@flub flub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking forward to having this!

Comment thread .github/workflows/ci.yml Outdated
# Pin to the nightly that the pinned `cargo-check-external-types`
# release was last tested against. Update both together.
CARGO_CHECK_EXTERNAL_TYPES_VERSION: "0.4.0"
CARGO_CHECK_EXTERNAL_TYPES_NIGHTLY: "nightly-2025-10-18"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be the wrong version because CI is currently failing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version is correct but it's not passed to the cargo make invocation. Will fix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it.

Comment thread Makefile.toml Outdated
Comment on lines +102 to +116
script = '''
set -e
fail=0
for crate in noq-udp noq-proto noq; do
echo "::group::$crate"
if ! cargo +nightly check-external-types \
--manifest-path "$crate/Cargo.toml" \
--features __all_without_fips; \
then
fail=1
fi
echo "::endgroup::"
done
exit $fail
'''
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you not set workspace = true and avoid having to iterate the crates here in a script?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where would i set workspace = true? cargo check-external-types has no support for a workspace AFAICS (but there's an open PR for it)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, on the cargo make level. Should be possible indeed, trying this out now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work, but then we also have bench, fuzz, perf, book being checked which we don't want, so I'd keep the manual loop over the crates.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can do this as well: https://sagiegurari.github.io/cargo-make/#usage-workspace-support-skip-include-members

I'd still prefer that over manually writing this script I think.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I'd like cargo make to be something everyone can run locally before pushing to a PR. And a script like this will break at least on windows. Hence why I'm looking to avoid this. (And yes, being able to execute this check locally is great!)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I managed to remove the script.

Comment thread noq-proto/Cargo.toml
Comment on lines +115 to +116
"arbitrary::Arbitrary", # gated behind `arbitrary` feature
"criterion::Criterion", # gated behind `bench` feature
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth not including those and not enabling those features for the check instead? Or is that more effort than it is worth it? I guess the odds of those accidentally ending up in our real API are pretty small.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can also list the features manually instead. Wasn't sure which way was "safer" for us.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure but I think I'd prefer keeping Arbitrary listed and running the check with all features enabled. Otherwise we could still sneak in new types under feature flags.

Note that I didn't use --all-features but a new __all_without_fips feature, because the FIPS feature of aws-lc-rs fails to build on my machine because my GCC apparently is too new. YMMV. Can switch to --all-features but would have to check first if our CI runners can build the FIPS feature.

Comment thread noq-proto/Cargo.toml
allowed_external_types = [
"arbitrary::Arbitrary", # gated behind `arbitrary` feature
"criterion::Criterion", # gated behind `bench` feature
"identity_hash::IdentityHashable",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this show up in our API?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impl identity_hash::IdentityHashable for PathId {}

impl identity_hash::IdentityHashable for PathId {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goodness that's miserable. Why can't we keep impls like that private?

Copy link
Copy Markdown
Member Author

@Frando Frando May 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can with another newtype.. #646

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, I was just complaining about rust. Wasn't asking for a solution 😄

@github-project-automation github-project-automation Bot moved this from 🚑 Needs Triage to 🏗 In progress in iroh May 11, 2026
@Frando Frando force-pushed the Frando/check-external-types branch from 5ad40b1 to 428d261 Compare May 11, 2026 09:32
@Frando
Copy link
Copy Markdown
Member Author

Frando commented May 11, 2026

Comment thread Makefile.toml Outdated
Comment on lines +112 to +113
# Install the required toolchain
rustup -q toolchain install $TOOLCHAIN -c rustc,cargo,rust-std
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, I'm not a fan of automatically installing tools. I kind of find this an anti-pattern. Can we not error and print a message with a hint of how to install it?

I know cargo-make does have this as a built-in feature too. But I've been wondering whether we should disable that by default.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the script altogether, now it fails if the toolchain is missing.

Comment thread Makefile.toml Outdated
Comment on lines +102 to +116
script = '''
set -e
fail=0
for crate in noq-udp noq-proto noq; do
echo "::group::$crate"
if ! cargo +nightly check-external-types \
--manifest-path "$crate/Cargo.toml" \
--features __all_without_fips; \
then
fail=1
fi
echo "::endgroup::"
done
exit $fail
'''
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can do this as well: https://sagiegurari.github.io/cargo-make/#usage-workspace-support-skip-include-members

I'd still prefer that over manually writing this script I think.

Comment thread noq-proto/Cargo.toml
allowed_external_types = [
"arbitrary::Arbitrary", # gated behind `arbitrary` feature
"criterion::Criterion", # gated behind `bench` feature
"identity_hash::IdentityHashable",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, I was just complaining about rust. Wasn't asking for a solution 😄

@Frando Frando requested a review from flub May 11, 2026 12:42
Copy link
Copy Markdown
Collaborator

@flub flub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks!

@Frando Frando added this pull request to the merge queue May 11, 2026
Merged via the queue into main with commit 684c3e2 May 11, 2026
39 checks passed
@Frando Frando deleted the Frando/check-external-types branch May 11, 2026 13:24
@github-project-automation github-project-automation Bot moved this from 🏗 In progress to ✅ Done in iroh May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants