Skip to content

Test with minimal dependency versions#1272

Closed
Kixunil wants to merge 1 commit intorust-bitcoin:masterfrom
Kixunil:lock-files
Closed

Test with minimal dependency versions#1272
Kixunil wants to merge 1 commit intorust-bitcoin:masterfrom
Kixunil:lock-files

Conversation

@Kixunil
Copy link
Copy Markdown
Collaborator

@Kixunil Kixunil commented Sep 14, 2022

It could happen that we unknowingly depend on a new version of a crate without updating Cargo.toml. This could couse resolution issues for downstream users. It's also unclear for outsiders to know with which dependencies did we test the crate.

This change commits two lock files: minimal and recent. minimal contains minimal depdendency versions, while recent contains dependency versions at the time of making the change.

Further, this adds CI jobs to test with both lock files, CI job for internals crate, removes old serde pinning and prints a warning if recent is no longer up to date. (We may have to override it somehow if any crate breaks MSRV.)

The documentation is also updated accordingly.

Closes #1230

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Sep 14, 2022

WTF, this runs on my machine anyone has any idea? Even bigger WTF, this fails on older Rust but it's not supposed to be nightly. Did Rust break the API?!

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Sep 14, 2022

Oh, I see now, they kept in an alias. core2 broke MSRV and it was restored in technocreatives/core2#7
Released in core2 0.3.2

apoelstra
apoelstra previously approved these changes Sep 14, 2022
Copy link
Copy Markdown
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK ffdb2f489441020a9e57d73ee1dd7910b34992a0

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Sep 14, 2022

Oh, is this actually correct? From my understanding of matrix GA option it should test with all combinations of {minimal,recent}{$rust_versions} but from logs it doesn't seem to be doing that.

@apoelstra
Copy link
Copy Markdown
Member

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Sep 14, 2022

It seems to be only testing with 1.47. Am I missing something?

@apoelstra
Copy link
Copy Markdown
Member

Oh, you're right -- I just looked for "is it actually doing the cp command somewhere". But yes, I think it's only doing 1.47.

Maybe somebody else here understands GH Actions but unfortunately you may just have to iterate a dozen times until you guess how to make it do what you want..

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Sep 14, 2022

I will re-read the docs and retry and then start pinging people if it still doesn't work. :)

It could happen that we unknowingly depend on a new version of a crate
without updating `Cargo.toml`. This could couse resolution issues for
downstream users. It's also unclear for outsiders to know with which
dependencies did we test the crate.

This change commits two lock files: `minimal` and `recent`. `minimal`
contains minimal depdendency versions, while `recent` contains
dependency versions at the time of making the change.

Further, this adds CI jobs to test with both lock files, CI job for
`internals` crate, removes old `serde` pinning and prints a warning if
`recent` is no longer up to date. (We may have to override it somehow if
any crate breaks MSRV.)

The documentation is also updated accordingly.

Closes rust-bitcoin#1230
@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Sep 14, 2022

It looks like it works. I've moved duplicate checking to lint part. (I'd love to have a separate linting job but that's for another time.)

Copy link
Copy Markdown
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 1e4487a


## External dependencies

The crate integrates with a few external librarie, most notably `serde`. These
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
The crate integrates with a few external librarie, most notably `serde`. These
The crate integrates with a few external libraries, most notably `serde`. These

cd "$crate"
./contrib/test.sh
)
done
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps to catch future mistakes when editing the test scripts we could add

	    if ! diff Cargo-$dep.lock Cargo.lock
            then
                echo "::warning Cargo.lock has been updated by test run - check for missing --locked flag"
                exit 1
            fi

then
echo Dependencies are up to date
else
echo "::warning file=Cargo-recent.lock::Dependencies could be updated"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can I ask, why the double colons in ::warning? We could use colors

echo "\e[33mWarning:\e[0m ..."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is a special signal for GitHub to show the warning at that file. Sadly one will only see it when explicitly looking at the file but that's still better than looking into logs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh cool, cheers - I've never seen that before.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Me neither, I just thought "is there a way to warn in GH actions?" and succeeded googling it. :)


if [ "$DO_LINT" = true ]
then
cargo clippy --frozen --all-features --all-targets -- -D warnings
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why use --frozen over --locked, is it because we know the order of CRATES so we know that cargo has already been run with --locked so doesn't need to hit the network again?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I previously thought --frozen does something else. I changed it to --locked but forgot in this case.

@dpc
Copy link
Copy Markdown
Contributor

dpc commented Sep 15, 2022

Any reason for all the manual file handling? I was just hoping to eventually get something like: https://github.com/fedimint/fedimint/pull/580/files working . Done automatically in the CI.

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Sep 15, 2022

@dpc Mainly I wanted for people to be able to see the tested versions somewhere. I also fear that some nightly will change Cargo.lock format like it happened before and the test will stop working.

@dpc
Copy link
Copy Markdown
Contributor

dpc commented Sep 15, 2022

Mainly I wanted for people to be able to see the tested versions somewhere.

cat Cargo.lock after the update?

I also fear that some nightly will change Cargo.lock format like it happened before and the test will stop working.

I don't know the details, but isn't min-version checking ... kind of a best effort thing anyway?

@Kixunil

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Sep 15, 2022

kind of a best effort thing anyway

Given we run whole test suite against them I don't think so. :)

@apoelstra
Copy link
Copy Markdown
Member

apoelstra commented Sep 15, 2022

I like this approach, because as @Kixunil says, you can see exactly the lockfile that's being used.

If it breaks more than once due to cargo changing its format maybe we'll have to revisit our approach.

Edit interesting idea @dpc to use cargo -Z minimal-versions and then catting the resulting lockfile..

@dpc
Copy link
Copy Markdown
Contributor

dpc commented Sep 15, 2022

I also fear that some nightly will change Cargo.lock format like it happened before and the test will stop working.

Can you please elaborate or paste some links? I don't understand what exactly changed.

I see the point or bitcoin being so widely used core library for Bitcoin Rust ecosystem that it needs a solid check here. However I'm for other projects, I'm always reluctant putting extra manual steps on the contributors.

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Sep 15, 2022

If I remember correctly a lock file produced by current MSRV can't be read by old rust-bitcoin MSRV - 1.29. You have to delete it and re-generate. If similar thing happened in nightly it'd break us.

I don't actually want contributors to randomly update dependencies. :) If it's really required we will figure it out together.

@apoelstra
Copy link
Copy Markdown
Member

Yes, there was definitely a break I remember around 1.30 or so which caused us no end of grief with the old MSRV, but I can't think of another time. So it's rare at least. And it may be that after the noise people made last time, they won't do it again :P

Copy link
Copy Markdown
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

strong concept ACK. Agree with all of @tcharding's suggestions

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Sep 17, 2022

Oh, I just remembered a good reason to not just cat the lock file: non-logged-in people can't see outputs of runs.

@tcharding
Copy link
Copy Markdown
Member

Conflicts with #1729

@apoelstra
Copy link
Copy Markdown
Member

cc rust-bitcoin/rust-secp256k1#591 which does something similar (but does not actuall test) in rust-secp

@tcharding
Copy link
Copy Markdown
Member

Have you time to bring this back to life @Kixunil or would you like me to pick it up for you?

@Kixunil
Copy link
Copy Markdown
Collaborator Author

Kixunil commented Mar 23, 2023

I'm pretty busy lately, feel free to take it if you have time!

@tcharding
Copy link
Copy Markdown
Member

No worries man, will get to it shortly. Cheers.

@tcharding
Copy link
Copy Markdown
Member

I picked up this PR over at #1764

@Kixunil Kixunil closed this Mar 30, 2023
apoelstra added a commit that referenced this pull request May 3, 2023
c4c64c0 Test with minimal dependency versions (Martin Habovstiak)
d5655d5 Bump core2 dependency from 0.3.0 -> 0.3.2 (Tobin C. Harding)

Pull request description:

  This is work originally done by Kixunil in #1272, I picked it up to help out. The only changes I made were rebasingg, updating the recent lock file, adding `--locked` to hashes contrib file,  and adding a co-developed-by tag for accountability.

  It could happen that we unknowingly depend on a new version of a crate without updating `Cargo.toml`. This could cause resolution issues for downstream users. It's also unclear for outsiders to know with which dependencies did we test the crate.

  This change commits two lock files: `minimal` and `recent`. `minimal` contains minimal dependency versions, while `recent` contains dependency versions at the time of making the change.

  Further, this adds CI jobs to test with both lock files, CI job for `internals` crate, removes old `serde` pinning and prints a warning if `recent` is no longer up to date. (We may have to override it somehow if any crate breaks MSRV.)

  The documentation is also updated accordingly.

  Closes #1230

ACKs for top commit:
  apoelstra:
    ACK c4c64c0
  Kixunil:
    ACK c4c64c0

Tree-SHA512: 7d386e96ab747f6a6bafeea828ac65bd8bb11975eaa3408acecac369cd2f235f6e9d4c57202be18a3dc2eeb2a2df532d73e4d35cd1f3fbf092eb6414c55b1524
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cargo.lock strategy

5 participants