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

Add check_msrv job to ci workflow #70

Merged
merged 3 commits into from
Oct 19, 2022
Merged

Add check_msrv job to ci workflow #70

merged 3 commits into from
Oct 19, 2022

Conversation

memark
Copy link
Contributor

@memark memark commented Oct 16, 2022

Add check_msrv job to ci workflow. Checking the MSRV specified in all places mentioned in #39:

  • Doc comment in src/lib.rs
  • .github/workflows/ci.yml
  • tests/trybuild.rs (added in Make Unalign::into_inner const #60, which hasn't merged as of this writing)
  • zerocopy-derive/tests/trybuild.rs

When running locally this check works against #60 as well.

Resolves #39.

@joshlf
Copy link
Member

joshlf commented Oct 16, 2022

Thanks, @memark! I'll give this a review once the CI tests are passing.

@AntoniosBarotsis
Copy link
Contributor

AntoniosBarotsis commented Oct 17, 2022

Hello!

I tried messing around with this for a bit cause I saw you were getting an error with no error message.

I see you used '.jobs.build_test.strategy.matrix.channel[0]' somewhere, I couldn't figure out how to get matrix variables from a different job but one (albeit slightly messy) workaround would be to define a top-level env variable with the first channel and then use that in both the matrix and in the MSRV step.

I tried doing that here but I am still getting some errors (this time with error messages!) and here are the logs. Not sure if this is of any help but I hope so :)

Note
I didn't use that said variable anywhere in the matrix yet, I just declared it to see that it works

@memark
Copy link
Contributor Author

memark commented Oct 17, 2022

Thanks, that's an interesting approach! @AntoniosBarotsis

Something I struggled/hesitated a bit about is where the "true" MSRV really lives? (If there is one?)
Right now I'm pretty much only comparing all versions I can extract. Could this variable be it? (Is the workflow the place where we'd want to store it?)

I did find out why there where no error messages btw, it was that pesky "set -e" that I blindly copied from the other jobs... After one afternoon of trials in my own repo I finally figured that one out.

@joshlf
Copy link
Member

joshlf commented Oct 17, 2022

Something I struggled/hesitated a bit about is where the "true" MSRV really lives? (If there is one?)
Right now I'm pretty much only comparing all versions I can extract. Could this variable be it? (Is the workflow the place where we'd want to store it?)

I originally tried to have a source of truth in an MSRV.txt file (see #39 (comment)). I even tried to have a source of truth just in the scope of the ci.yml file, and discovered that that would also be really difficult to do ergonomically. That's why I figured that "the same MSRV in all of the files" might be the best we could do without a lot of over-engineering.

@memark
Copy link
Contributor Author

memark commented Oct 18, 2022

That's why I figured that "the same MSRV in all of the files" might be the best we could do without a lot of over-engineering.

Understood. I've gone with this approach as well now. I think the workflow should pass now, please allow it to run.

Copy link
Member

@joshlf joshlf left a comment

Choose a reason for hiding this comment

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

Hey, sorry about the churn on this one, but I just had a realization:

  • Looking for all MSRVs is pretty brittle because it relies on the exact format of a number of different files; e.g., I could use a different expression in the trybuild.rs files, and all of a sudden the greps we're running on those files would just output nothing, which would cause this script to continue to succeed
  • It would probably be fine to not look at the trybuild.rs files - if we get the MSRV there wrong, all that will happen is that at worst the tests will fail, which we'll notice and fix
  • We'd like to do set -e to catch any errors in the script, but we can't so long as tests/trybuild.rs doesn't exist yet
  • The thing we really need to check for - the thing that would be bad if we missed - is if we're testing for a different MSRV in ci.yml than the one we have advertised in the doc comment in src/lib.rs

With all that in mind, how would you feel about making the following changes?

  • Doing set -e at the top
  • Only checking that the MSRV in src/lib.rs matches the one in ci.yml

@memark
Copy link
Contributor Author

memark commented Oct 18, 2022

Sure, I'll make those changes.

I will add though that it would have saved me a lot of time and energy if I knew that all that was required was comparing two version numbers (out of the six present in the locations listed in the issue).

As for set -e I think it makes more sense in a script that does side-effectful actions, and less in a query-based script like this. It also has the effect that if something fails (e.g. grep) all you get is "-1" without much explanation.

Since the src/lib.rs comment is not yet available in main, and we want set -e, should I then write a version of the script that doesn't work until #60 is merged? Or just wait?

@joshlf
Copy link
Member

joshlf commented Oct 18, 2022

Sure, I'll make those changes.

Thanks!

I will add though that it would have saved me a lot of time and energy if I knew that all that was required was comparing two version numbers (out of the six present in the locations listed in the issue).

Yeah, sorry about that 🙁 Didn't realize that this was the right approach until you'd already put up the code.

As for set -e I think it makes more sense in a script that does side-effectful actions, and less in a query-based script like this. It also has the effect that if something fails (e.g. grep) all you get is "-1" without much explanation.

In this particular case, we expect grep to never return a non-zero code, right? It should always find at least one matching line, so if it doesn't, we should see that error and the test should fail.

Since the src/lib.rs comment is not yet available in main, and we want set -e, should I then write a version of the script that doesn't work until #60 is merged? Or just wait?

It's up to you. I think you could also just include an MSRV section in src/lib.rs in this PR - if it merges before #60, then cool. If it doesn't, then we can rebase. But you could also just wait until #60 merges. Up to you!

@joshlf
Copy link
Member

joshlf commented Oct 18, 2022

OK, #60 has been superseded by #76, which has been merged. This should be unblocked now.

@memark
Copy link
Contributor Author

memark commented Oct 19, 2022

Just pushed a simplified version of the msrv check. Ready for review.

Copy link
Member

@joshlf joshlf left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for this, @memark! Just a few nit-pick comments, but this looks great!

.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
Copy link
Member

@joshlf joshlf left a comment

Choose a reason for hiding this comment

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

Confirmed in #79 that this test catches an MSRV mismatch:

Screen Shot 2022-10-19 at 1 59 54 PM

Thanks again for all your work on this, @memark!

@joshlf joshlf merged commit 9f79f0c into google:main Oct 19, 2022
@memark
Copy link
Contributor Author

memark commented Oct 19, 2022

Happy to help out!

joshlf pushed a commit that referenced this pull request Aug 3, 2023
Validate that the MSRV that we document in our public-facing crate
documentation is the same one that we test in CI.

Closes #39
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.

Test in CI that we have the same MSRV in all source files
3 participants