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: enable sandbox build with --no-default-features #73

Closed
wants to merge 1 commit into from

Conversation

delta1
Copy link

@delta1 delta1 commented Mar 14, 2024

I'm making a nixpkgs derivation for this repo, which is built in a sandbox with no network access.

This PR allows tests to be run with --no-default-features to disable the binary downloads in the bitcoind, elementsd, and electrumd dev dependencies. Default features will still download them.

@RCasatta
Copy link
Collaborator

utACK 3720b7d

@RCasatta RCasatta requested a review from shesek March 19, 2024 13:14
@@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"

[[package]]
name = "aes"
version = "0.8.3"
version = "0.8.4"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like this slipped in by mistake?

@shesek
Copy link
Collaborator

shesek commented Mar 19, 2024

This PR allows tests to be run with --no-default-features to disable the binary downloads

Run which tests though? This seems to disable the tests entirely, not just the binary downloads

If the goal is to skip tests entirely, couldn't the nixpkg process skip cargo test (and not install the dev deps)?

Out of curiosity, would it be possible to get nix to supply the binaries in the expected location, so that the build stage skips downloading them but the tests would still work?

@delta1
Copy link
Author

delta1 commented Mar 20, 2024

Run which tests though?

it only runs these

test rest::tests::test_parse_query_param ... ok
test rest::tests::test_parse_value_param ... ok

couldn't the nixpkg process skip cargo test

yes i'll just do that.

@delta1 delta1 closed this Mar 20, 2024
@delta1 delta1 deleted the dev-feature branch March 20, 2024 07:08
@RCasatta
Copy link
Collaborator

Out of curiosity, would it be possible to get nix to supply the binaries in the expected location, so that the build stage skips downloading them but the tests would still work?

For this purpose bitcoind crate allows to provide an env var BITCOIND_TARBALL_FILE with the expected tar.gz and then unpacks that instead of trying to download and also verify hashes

@RCasatta
Copy link
Collaborator

couldn't the nixpkg process skip cargo test

tests can be skipped but dev-dependencies are in the Cargo.lock on which tools like crane are based on, thus failing the build

It may be the case to re-consider this

@RCasatta RCasatta mentioned this pull request Mar 28, 2024
@shesek
Copy link
Collaborator

shesek commented Mar 29, 2024

Is there no way to tell crane to ignore the dev deps? Or perhaps strip them from Cargo.lock in a pre build hook?

Alternatively, maybe add an env var build option for {bitcoin,elements,electrum}d that skips downloads?

It may be the case to re-consider this

It's possible, but adding a new feature for this feels kinda hacky >.<

@RCasatta
Copy link
Collaborator

RCasatta commented Mar 29, 2024

Or perhaps strip them from Cargo.lock in a pre build hook?

this seems more hacky than adding a feature for this?

Alternatively, maybe add an env var build option for {bitcoin,elements,electrum}d that skips downloads?

the option to skip downloads is not specifying the feature to download?

@shesek
Copy link
Collaborator

shesek commented Mar 30, 2024

this seems more hacky than adding a feature for this?

Yes, stripping it like that is admittedly more hacky >.<

But this solution is at least isolated in the context where its needed and doesn't effect other upstream projects.

the option to skip downloads is not specifying the feature to download?

I'm a bit hesitant about adding a feature for this because then we have to make sure that every script or CI configuration with --no-default-features remembers to re-enable it, as well as mention this in the documentation so users know to do it. It also requires the #[cfg(feature)] gating (plus the conditional allow(dead_code) to silence warnings) added to every test.

And then, if you have another project that depends on electrs that also needs to be built in nix, it will have to forward the right features down to electrs. Right now there are no other default features so its just a simple no-default-features, but if there were it would need explicitly re-enable them and make sure to keep the list updated. (And the same goes for projects that depend on that project...)

OTOH, if this used a build time environment variable instead, it could be passed directly from the nix building environment down to the crates that need it ({bitcoin,elements,electrum}d), without having every crate in the tree before them forward it down.

@RCasatta
Copy link
Collaborator

RCasatta commented Apr 2, 2024

I am not convinced because it can cause other issues but ok.
Is something like this what you have in mind? rust-bitcoin/bitcoind#154 (review)

@shesek
Copy link
Collaborator

shesek commented Apr 3, 2024

Is something like this what you have in mind? rust-bitcoin/bitcoind#154 (review)

Yes exactly 🙏

I can do the same for electrumd

can cause other issues but ok

You mean that the env var approach can cause other issues?

@RCasatta
Copy link
Collaborator

RCasatta commented Apr 4, 2024

You mean that the env var approach can cause other issues?

Yes, like having a different version of the daemon in the PATH in comparison to the specified feature

I can do the same for electrumd

great!

shesek added a commit to shesek/electrumd that referenced this pull request Apr 5, 2024
shesek added a commit to shesek/electrumd that referenced this pull request Apr 5, 2024
shesek added a commit to shesek/electrumd that referenced this pull request Apr 5, 2024
shesek added a commit to shesek/electrumd that referenced this pull request Apr 5, 2024
shesek added a commit to shesek/electrumd that referenced this pull request Apr 5, 2024
@shesek
Copy link
Collaborator

shesek commented Apr 5, 2024

Yes, like having a different version of the daemon in the PATH in comparison to the specified feature

Well you can still use TARBALL_FILE if you intend to use the crate and want to provide the files yourself (& have them hash-verified to be correct and matching the specified version), but SKIP_DOWNLOAD seems useful for cases where you don't intend to use the crate at all?

Also, IIUC mismatching the feature version and actual version was already possible via BITCOIND_EXE, right?

I can do the same for electrumd

great!

Added to electrumd in shesek/electrumd#1

A similar change is also needed in elementsd.

And we'll also need to update electrs to use the latest {bitcoin,elements,electrum}d releases.

@RCasatta
Copy link
Collaborator

RCasatta commented Apr 5, 2024

I already did elementsd

@shesek
Copy link
Collaborator

shesek commented Apr 5, 2024

I already did elementsd

Cool! I opened #79 to update the dependencies here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants