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

CI: test with commited lock files #632

Merged
merged 5 commits into from
Aug 14, 2023

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Jul 20, 2023

A while back we added two lock files, one for testing with recent dependency versions and one for testing with minimal dependency versions but at the time we never used them in CI.

Move the two current lock files and use them in CI (mirroring what is done in rust-bitcoin).

@tcharding tcharding force-pushed the 07-20-ci-lock-files branch 3 times, most recently from 07c746f to 4bc5aa1 Compare July 20, 2023 03:53
@tcharding
Copy link
Member Author

tcharding commented Jul 20, 2023

The WASM test does not play nicely with the recent/minimal lock files. I'm not sure right now what is the solution, called through to contrib/_test.sh for now. hmmm, needs more thought.

@apoelstra
Copy link
Member

@tcharding could you move the rename of the lockfiles to the first commit (you can do it in its own commit, or combine it, it just needs to be the first one). That would make my local CI easier to tweak.

Then the WASM thing I think is about paths being somehow screwed up by the new script indirection. You can see that in the DO_WASM branch we edit Cargo.toml using echo, and after this PR, we're getting some sort of error related to parsing Cargo.toml.

@tcharding
Copy link
Member Author

tcharding commented Jul 21, 2023

The wasm thing was that now we run the ci script twice and in the wasm test we modify the toml file it was getting modified twice so had duplicate [lib] section. Another classic case of tunnel vision as we discussed yesterday

Caused by:
  TOML parse error at line 77, column 1
     |
  77 | [lib]
     | ^
  invalid table header
  duplicate key `lib` in document root

I saw the "invalid table header" line and immediately focused on that, I rekon I did not even read the the next line, today I read the "duplicate key" line and realised the problem immediately.

I'd hate to have to make life threatening decisions with this brain :)

@tcharding
Copy link
Member Author

Hit another issue with the wasm-bingen-backend dependency. While debugging I noticed that the lock file gets updated by, I assume, calls to wasm-pack. So I think we should just skip testing against the minim/recent lock files for WASM. Is that acceptable?

@tcharding tcharding marked this pull request as draft July 21, 2023 01:39
@tcharding
Copy link
Member Author

On ice for another day.

@apoelstra
Copy link
Member

apoelstra commented Jul 21, 2023

Hit another issue with the wasm-bingen-backend dependency. While debugging I noticed that the lock file gets updated by, I assume, calls to wasm-pack. So I think we should just skip testing against the minim/recent lock files for WASM. Is that acceptable?

I'll spend a little bit of time seeing if I can get it to run inside nix, and if so, what's involved. But I think it's fine if we just can't test this stuff properly.

@apoelstra
Copy link
Member

apoelstra commented Jul 21, 2023

So I think we should just skip testing against the minim/recent lock files for WASM. Is that acceptable?

I was able to get wasm-pack to work inside nix (sorta, because of rustwasm/wasm-pack#814 I've had to hack up some paths; and the unit tests aren't working because of "missing env" errors that our C patches should be preventing), and (a) it doesn't need to connect to the Internet, if you prod it enough, so it's not doing anything gratuitously non-deterministic; and (b) it doesn't appear to be modifying lockfiles, at least when run in a hermetic container where it can't access new versions of anything from crates.io.

I think we should investigate further.

@apoelstra
Copy link
Member

apoelstra commented Jul 21, 2023

oo https://rustwasm.github.io/wasm-pack/book/commands/build.html suggests we can add -- --locked to the wasm-pack commands. @tcharding can you try that?

Edit: I'm unconvinced that --locked actually does anything. If you run a normal cargo --locked command without a lockfile, or with an empty lockfile, it'll fail. But wasm-pack build -- --locked seems to continue to work. If you provide a corrupt lockfile, e.g. by copying Cargo.toml to Cargo.lock, you will get an error Error during execution of cargo metadata: error: failed to parse lock file at: /build/source/Cargo.lock. So it does sound like wasm-pack is doing something illegitimate with lockfiles.

But we could try --offline and see if that prevents them changing. Or we could just copy the old lockfiles again after running wasm commands.

@apoelstra
Copy link
Member

Oh, I see, the issue is that cargo options are not actually passed to cargo metadata. See https://github.com/rustwasm/wasm-pack/blob/7d6501d3cd272b7ea27034158d88bfd5c0005913/src/manifest/mod.rs#L408-L410

So indeed, wasm-pack is unconditionally running cargo metadata with no flags to prevent it from modifying the lockfile.

We should use diff or something to check that it is, but it sounds like we need to patch the lockfile afterward.

@apoelstra
Copy link
Member

I filed a bug at rustwasm/wasm-pack#1316. Meanwhile I think the workaround is easy: we copy the lockflies, run the wasm-pack commands, then copy them again. I don't think wasm-pack will actually respect the copied lockfile, but we can live with that for now.

@tcharding
Copy link
Member Author

Awesome, thanks for digging into it. I'll push it forward from here.

@tcharding
Copy link
Member Author

This needs rebasing on #641 to pass CI.

@tcharding
Copy link
Member Author

Rebase, no other changes.

@tcharding tcharding marked this pull request as ready for review August 11, 2023 01:30
@apoelstra
Copy link
Member

I don't think this PR actually uses the committed lockfiles anywhere :)

@tcharding
Copy link
Member Author

I don't think this PR actually uses the committed lockfiles anywhere :)

Epic fail. I'm confident this was a rebase fail and not me being totally retarded.

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

Choose a reason for hiding this comment

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

In f4078f8:

This warning is harmless enough, but "cargo update yields later dependencies" is neither necessary nor sufficient for us to want to update Cargo-recent.lock. I expect this warning to literally always trigger because it finds later dependencies that are incompatible with our MSRV.

Copy link
Member Author

Choose a reason for hiding this comment

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

It only runs for "recent" but I agree, and thought at the time that we added it to rust-bitcoin that it was not that useful. Didn't seem to hurt though, and since its informational I acked it. I'm happy to remove it everywhere but I'd prefer to wait till @Kixunil is back because he added it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You have to open the file in GH to see the warning so it at least won't be intrusive.

@apoelstra
Copy link
Member

Could you re-order the first commit so that the "rename the lockfiles" commit comes first? It is much easier for me to handle PRs if every commit has the lockfiles in the same place.

@tcharding
Copy link
Member Author

Can do, my bad - you asked that before once.

A while back we added two lock files that were to track dependencies of
two successful test runs, one with a minimal set of dependencies and one
with a recent set of dependencies (ie, recent dependency versions). We
never used these lock files in CI however.

In preparation for using the lock files in CI, and in order to be
uniform with `rust-bitcoin`, move the lock files to the crate root and
rename them to:

- Cargo-minimal.lock
- Cargo-recent.lock
We would like to be able to run the test script with different lock
files, in preparation for doing so move the `test.sh` script to
`_test.sh` and add a new `test.sh` that runs `_test.sh`.

Keep the outer script as `test.sh` so that we do not change the workflow
for those running the script including the github actions.
The `wasm-pack` command does not honour `cargo` flags passed to it so we
cannot use `--locked` and test against pre-made lock files. Instead just
run the WASM test from the test script wrapper.
Update the CI scripts to use the minimal/recent lockfiles, requires
using `--locked` for various `cargo` incantations.
Copy link
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 3da39c6

@apoelstra apoelstra merged commit 7058539 into rust-bitcoin:master Aug 14, 2023
24 checks passed
@tcharding tcharding deleted the 07-20-ci-lock-files branch August 15, 2023 04:41
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.

3 participants