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

More comprehensive CI test matrix #2951

Closed
thomaseizinger opened this issue Sep 29, 2022 · 14 comments · Fixed by #3090
Closed

More comprehensive CI test matrix #2951

thomaseizinger opened this issue Sep 29, 2022 · 14 comments · Fixed by #3090
Labels
difficulty:easy getting-started Issues that can be tackled if you don't know the internals of libp2p very well help wanted

Comments

@thomaseizinger
Copy link
Contributor

Description

Change our CI to run on:

  • latest stable
  • latest beta
  • our MSRV

Motivation

MSRV: We set a rust-version in our manifest but we don't actually run CI against that version.
Beta: Rust beta's are cut 6 week before landing on stable. This gives us enough time to know ahead of time, which lints are coming and also to notify the Rust devs in case anything that is about to hit stable breaks our build.

Current Implementation

We only run CI against latest stable Rust.

Are you planning to do it yourself in a pull request?

Maybe.

@thomaseizinger thomaseizinger added difficulty:easy help wanted getting-started Issues that can be tackled if you don't know the internals of libp2p very well labels Sep 29, 2022
@umgefahren
Copy link
Contributor

Just a general question on MSRV: I never quite understood why that was a thing. Are there any real reasons not to use the latest version of Rust stable?

@thomaseizinger
Copy link
Contributor Author

Just a general question on MSRV: I never quite understood why that was a thing. Are there any real reasons not to use the latest version of Rust stable?

Yes, multiple reasons in fact:

  • Not all users use rustup to install Rust. Some rely on the version that comes with their package manager. Distros update a lot less frequently than Rust. Debian stable for example ships with Rust 1.48.
  • For compliance reasons, companies might have a process that toolchain updates need to go through before they can be used in their product. For industries like aviation and cars, these regulations are very strict. After all, a software bug might kill people. See this podcast episode if you are interested.
  • Despite going through nightly and a 6 week beta, new releases are a lot less vetted than older ones, so even without strict regulations, you might want to stay a couple of versions behind latest stable to f.e. not disrupt your development process as much.

Even ignoring all of that, depending on newer features will cause compilation with an older compiler to break. According to semver, breaking changes need to come with an appropriate bump. If we ignore this part, we are violating semver which can cause major headaches because software like cargo implements these rules when running its dependency version resolution algorithm. Software will just break from one day to another then without the user taking an explicit action.

Thus, even if we don't have a strict MSRV policy, our CI should tell us if we are making a breaking change because we are bumping the MSRV :)

@umgefahren
Copy link
Contributor

Those are some very good reasons. Thanks a lot for explaining! I will take a spin at implanting this issue if I've got the time then

@umgefahren
Copy link
Contributor

I didn't find any GitHub Action that did what I was looking for. Gonna write my own.

@thomaseizinger
Copy link
Contributor Author

I didn't find any GitHub Action that did what I was looking for. Gonna write my own.

There should be no need for a GitHub action really. We just need a matrix :)

See https://github.com/Restioson/xtra/blob/master/.github/workflows/ci.yml for example.

@umgefahren
Copy link
Contributor

Oh, than there has been a misunderstanding. I thought you wanted an Action to tell you what the MSRV for a crate is. If it's just a very big matrix were we test a lot of versions, that is easier.

@thomaseizinger
Copy link
Contributor Author

Oh, than there has been a misunderstanding. I thought you wanted an Action to tell you what the MSRV for a crate is. If it's just a very big matrix were we test a lot of versions, that is easier.

You can get the MSRV from the manifest with some shell scripting: https://github.com/testcontainers/testcontainers-rs/blob/d7534a56d4313c8c707a1975d70874eff8a67d69/.github/workflows/ci.yml#L11

@umgefahren
Copy link
Contributor

Adding a CI for that was a very good idea 😅, as it turns out we actually don't compile on Rust 1.60.0 (as we say), because a dependency of multihash (in the latest version), arbitrary (also latest version), uses core::array::from_fn which is a Rust 1.63 feature (very good though).

@thomaseizinger
Copy link
Contributor Author

At the moment, we have a rust-version attribute in all of our crates. If we want to take this seriously, then we should really verify the MSRV of each individual crate. I think that would require us to split out the jobs per crate, similarly to what we are attempting to do in #2647.

Note that we only need to run a cargo build --all-features for the MSRV version. dev-dependencies and tests don't need to respect MSRV.

The matrix for stable and beta should only apply to tests and clippy. Those we can run on the full workspace as we currently do.

@umgefahren
Copy link
Contributor

But how should i handle the invalid rust-version?

@thomaseizinger
Copy link
Contributor Author

But how should i handle the invalid rust-version?

We just need to set it to the correct one, i.e. what it effectively is.

@thomaseizinger
Copy link
Contributor Author

#2996 mentions another error case where a regular cargo test failed, likely because the required features are not specified. I think our CI missed that because we don't check the default configuration of every crate.

@thomaseizinger
Copy link
Contributor Author

Not running CI on beta causes unrelated CI failures on new stable releases: https://github.com/libp2p/rust-libp2p/actions/runs/3390658695/jobs/5635053146

@thomaseizinger
Copy link
Contributor Author

As noted on #2289, it would be useful to have a feature for all protocols/transports and then selectively test whether it all builds with only tokio or async-std enabled!

@thomaseizinger thomaseizinger changed the title Run CI on multiple rust versions More comprehensive CI test matrix Nov 6, 2022
@mergify mergify bot closed this as completed in #3090 Nov 18, 2022
mergify bot pushed a commit that referenced this issue Nov 18, 2022
We refactor our continuous integration workflow with the following goals in mind:

- Run as few jobs as possible
- Have the jobs finish as fast as possible
- Have the jobs redo as little work as possible

There are only so many jobs that GitHub Actions will run in parallel.
Thus, it makes sense to not create massive matrices but instead group
things together meaningfully.

The new `test` job will:

- Run once for each crate
- Ensure that the crate compiles on its specified MSRV
- Ensure that the tests pass
- Ensure that there are no semver violations

This is an improvement to before because we are running all of these
in parallel which speeds up execution and highlights more errors at
once. Previously, tests run later in the pipeline would not get run
at all until you make sure the "first" one passes.

We also previously did not verify the MSRV of each crate, making the
setting in the `Cargo.toml` rather pointless.

The new `cross` job supersedes the existing `wasm` job.

This is an improvement because we now also compile the crate for
windows and MacOS. Something that wasn't checked before.
We assume that checking MSRV and the tests under Linux is good enough.
Hence, this job only checks for compile-errors.

The new `feature_matrix` ensures we compile correctly with certain feature combinations.

`libp2p` exposes a fair few feature-flags. Some of the combinations
are worth checking independently. For the moment, this concerns only
the executor related transports together with the executor flags but
this list can easily be extended.

The new `clippy` job runs for `stable` and `beta` rust.

Clippy gets continuously extended with new lints. Up until now, we would only
learn about those as soon as a new version of Rust is released and CI would
run the new lints. This leads to unrelated failures in CI. Running clippy on with `beta`
Rust gives us a heads-up of 6 weeks before these lints land on stable.

Fixes #2951.
umgefahren pushed a commit to umgefahren/rust-libp2p that referenced this issue Mar 8, 2024
We refactor our continuous integration workflow with the following goals in mind:

- Run as few jobs as possible
- Have the jobs finish as fast as possible
- Have the jobs redo as little work as possible

There are only so many jobs that GitHub Actions will run in parallel.
Thus, it makes sense to not create massive matrices but instead group
things together meaningfully.

The new `test` job will:

- Run once for each crate
- Ensure that the crate compiles on its specified MSRV
- Ensure that the tests pass
- Ensure that there are no semver violations

This is an improvement to before because we are running all of these
in parallel which speeds up execution and highlights more errors at
once. Previously, tests run later in the pipeline would not get run
at all until you make sure the "first" one passes.

We also previously did not verify the MSRV of each crate, making the
setting in the `Cargo.toml` rather pointless.

The new `cross` job supersedes the existing `wasm` job.

This is an improvement because we now also compile the crate for
windows and MacOS. Something that wasn't checked before.
We assume that checking MSRV and the tests under Linux is good enough.
Hence, this job only checks for compile-errors.

The new `feature_matrix` ensures we compile correctly with certain feature combinations.

`libp2p` exposes a fair few feature-flags. Some of the combinations
are worth checking independently. For the moment, this concerns only
the executor related transports together with the executor flags but
this list can easily be extended.

The new `clippy` job runs for `stable` and `beta` rust.

Clippy gets continuously extended with new lints. Up until now, we would only
learn about those as soon as a new version of Rust is released and CI would
run the new lints. This leads to unrelated failures in CI. Running clippy on with `beta`
Rust gives us a heads-up of 6 weeks before these lints land on stable.

Fixes libp2p#2951.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty:easy getting-started Issues that can be tackled if you don't know the internals of libp2p very well help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants