Skip to content

Check independent features#567

Merged
spacebear21 merged 3 commits intopayjoin:masterfrom
DanGould:check-independent-features
Mar 13, 2025
Merged

Check independent features#567
spacebear21 merged 3 commits intopayjoin:masterfrom
DanGould:check-independent-features

Conversation

@DanGould
Copy link
Contributor

@DanGould DanGould commented Mar 8, 2025

I noticed when reviewing #558 that some intended feature combinations were broken. In particular tests didn't catch that a v2 feature gate on an error variant would break if the impl Display for that variant wasn't also gated. This led me to notice that cargo check --no-default-features --features v1 was also failing because of unavailability of thread_rng.

The first commit addresses the build failure in independent v1 build, the second creates checks for payjoin.

I am curious if @spacebear21 you think such checks are also appropriate for payjoin-cli and payjoin-directory who should be able to be compiled with independent feature combinations as well. I chose check as a happy medium tradeoff between redundant tests and independent feature combination failure. I believe with careful review this CI job should catch the vast majority of potential mistakes.

close #566

`cargo check --no-default-features --features v1` was producing an error
because `thread_rng` was not available with the given feature set.
Somehow the other feature combinations make std available.

no-std randomness would be nice for web browser embed, but we should
cross that bridge when we get to it by using the `getrandom` crate with
`js` feature enabled. For now all of our targets can depend on `std`.
@DanGould DanGould requested a review from spacebear21 March 8, 2025 16:43
@DanGould DanGould force-pushed the check-independent-features branch from ad6d321 to bf80cc7 Compare March 8, 2025 16:44
@coveralls
Copy link
Collaborator

coveralls commented Mar 8, 2025

Pull Request Test Coverage Report for Build 13815084700

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 43 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.03%) to 79.738%

Files with Coverage Reduction New Missed Lines %
payjoin-test-utils/src/lib.rs 4 97.06%
payjoin/src/io.rs 12 34.04%
payjoin-directory/src/lib.rs 27 77.64%
Totals Coverage Status
Change from base Build 13725031512: 0.03%
Covered Lines: 4569
Relevant Lines: 5730

💛 - Coveralls

@DanGould DanGould force-pushed the check-independent-features branch 5 times, most recently from 9e78355 to d2d041f Compare March 8, 2025 16:52
v1, directory, v2, and _multiparty ought to compile on their own and
with --all-features enabled. Ensure this in CI.

I chose `check` as a happy medium tradeoff between redundant tests and
independent feature combination failure. I believe with careful review
this CI job should catch the vast majority of potential mistakes.

`--locked` cannot be used because of the many feature combinations.
@spacebear21
Copy link
Collaborator

if such checks are also appropriate for payjoin-cli and payjoin-directory who should be able to be compiled with independent feature combinations as well

Yes, the CI overhead of cargo check seems low enough that I don't see a good reason not to.

Actually I wonder if we should make this check a part of lint.sh and just run cargo clippy for each independent feature? That way we also get the benefit of flagging e.g. unused code warnings.

@DanGould
Copy link
Contributor Author

I see no obvious reason not to cargo clippy instead. Will rework to do that.

`payjoin/{v1,directory,v2,_multiparty}` ought to compile on their own in
addition to with --all-features enabled. `payjoin-cli/{v1,v2}` ought to
do the same. Ensure this in CI with recursive lint.sh.

`cargo clippy` replaces `cargo check` for this purpose since it doesn't
take much longer to run and it also flags issues like unused code.
@DanGould
Copy link
Contributor Author

Updated to use cargo clippy and include payjoin-cli independent features to get the benefit of unused code warnings as well. This replaces cargo check but leaves it in the history to document the rationale.

Copy link
Collaborator

@benalleng benalleng left a comment

Choose a reason for hiding this comment

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

tACK. Tested both from the main repo dir and observed the independent feature lints for payjoin and payjoin-cli as well tested within each crate

Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

ACK be60b68

@spacebear21
Copy link
Collaborator

Did you leave out payjoin-directory intentionally?

@spacebear21 spacebear21 merged commit 1aac845 into payjoin:master Mar 13, 2025
7 checks passed
@DanGould
Copy link
Contributor Author

I did leave out payjoin-directory and payjoin-test-utils intentionally. They're included in the top level lint cargo clippy --all-targets --keep-going --all-features -- -D warnings and don't require independent feature checks as far as I understand.

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.

Independent features must be checked in CI

4 participants