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

.github/workflows: Refactor CI jobs #3090

Merged
merged 31 commits into from
Nov 18, 2022
Merged

.github/workflows: Refactor CI jobs #3090

merged 31 commits into from
Nov 18, 2022

Conversation

thomaseizinger
Copy link
Contributor

@thomaseizinger thomaseizinger commented Nov 7, 2022

Description

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.

Links to any relevant issues

Depends-On: #3131

Open Questions

We could merge cross and feature_matrix together by adding another matrix variable that is either set to --all-features or --features="mdns ...". Should we?

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

This includes warnings from the latest stable clippy but also for
the next beta.
To reuse this, we rename it to what it actually does: Gathering
all crates that are published to crates.io.
Overall, we want to:

- 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.

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.

`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.
@thomaseizinger

This comment was marked as outdated.

@thomaseizinger thomaseizinger requested a review from a team November 8, 2022 04:37
@thomaseizinger thomaseizinger marked this pull request as ready for review November 8, 2022 04:37
@mergify

This comment was marked as resolved.

@galargh
Copy link
Contributor

galargh commented Nov 8, 2022

Before this can be merged, you need to adjust the required checks in the settings please @mxinden !

@thomaseizinger You can propose the changes to branch protection rules for this repo here: https://github.com/libp2p/github-mgmt/blob/6ca111c9ce1cdb0ffd6a5c09054e4a5d1ed67067/github/libp2p.yml#L3965

.github/workflows/ci.yml Outdated Show resolved Hide resolved
test "$ALL_FEATURES" = "$FULL_FEATURE"

gather_published_crates:
Copy link
Contributor

@galargh galargh Nov 8, 2022

Choose a reason for hiding this comment

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

Since test depends on it, my suggestion would be to place this job above it. Not a requirement but it'd make it easier to read.

Copy link
Contributor Author

@thomaseizinger thomaseizinger Nov 8, 2022

Choose a reason for hiding this comment

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

I usually follow a different philosophy:

The most important functions jobs should be at the top. Assuming sufficiently descriptive names, you shouldn't need the implementation of a function job to continue reading and understanding what is happening.

If you do the reverse - putting all "leaf"1 jobs at the top - you end up reading a lot of unrelated snippets before getting to the parts that actually matter.

Footnotes

  1. As in, the leafs in a dependency-tree.

@thomaseizinger
Copy link
Contributor Author

Before this can be merged, you need to adjust the required checks in the settings please @mxinden !

@thomaseizinger You can propose the changes to branch protection rules for this repo here: https://github.com/libp2p/github-mgmt/blob/6ca111c9ce1cdb0ffd6a5c09054e4a5d1ed67067/github/libp2p.yml#L3965

Awesome, I had no idea this was all represented as code! Loving it!

I'll send a patch!

thomaseizinger added a commit to thomaseizinger/github-mgmt that referenced this pull request Nov 9, 2022
thomaseizinger added a commit to thomaseizinger/github-mgmt that referenced this pull request Nov 9, 2022
@thomaseizinger
Copy link
Contributor Author

Before this can be merged, you need to adjust the required checks in the settings please @mxinden !

@thomaseizinger You can propose the changes to branch protection rules for this repo here: https://github.com/libp2p/github-mgmt/blob/6ca111c9ce1cdb0ffd6a5c09054e4a5d1ed67067/github/libp2p.yml#L3965

Awesome, I had no idea this was all represented as code! Loving it!

I'll send a patch!

Done here: libp2p/github-mgmt#73

@mergify

This comment was marked as resolved.

@thomaseizinger
Copy link
Contributor Author

With this setup, our pretty much all jobs within the CI workflow finish around the 5min mark: https://github.com/libp2p/rust-libp2p/actions/runs/3467657544/usage

Once we merge #3023, I expect this number to go down even more. Many of our crates spend ~1-2minutes compiling the entire workspace because they depend on libp2p for testing.

Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Sorry for the delay Thomas.
LGTM, superb work 👌

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

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for putting so much time into making our life easier!

If I understand the changes to the rust-version field correctly, they are just updating the field to the reality, i.e. we depended on these versions before but didn't make it explicit. Thus this is not a breaking change.

@thomaseizinger what do you think of mentioning this in the root CHANGELOG.md anyways? Just so that there is no surprise for people.

@thomaseizinger
Copy link
Contributor Author

If I understand the changes to the rust-version field correctly, they are just updating the field to the reality, i.e. we depended on these versions before but didn't make it explicit. Thus this is not a breaking change.

Correct. From here on, we can track that more accurately now!

@thomaseizinger what do you think of mentioning this in the root CHANGELOG.md anyways? Just so that there is no surprise for people.

I think it makes sense to mention this in the changelog entry of each crate.

I'll push a patch for that tomorrow (unless someone beats me to it).

@mergify
Copy link
Contributor

mergify bot commented Nov 15, 2022

This pull request has merge conflicts. Could you please resolve them @thomaseizinger? 🙏

@thomaseizinger
Copy link
Contributor Author

thomaseizinger commented Nov 17, 2022

I am tagging this as ready to merge. It won't automatically merge until we fix #3131 and merge libp2p/github-mgmt#73.

@mergify
Copy link
Contributor

mergify bot commented Nov 17, 2022

This pull request has merge conflicts. Could you please resolve them @thomaseizinger? 🙏

@thomaseizinger
Copy link
Contributor Author

The WebRTC job is failing because #3141. I'd appreciate if we can merge libp2p/github-mgmt#73 so this can finally go in!

@mergify mergify bot merged commit 0c85839 into master Nov 18, 2022
@thomaseizinger
Copy link
Contributor Author

Thanks for merging this! Very exciting!

@thomaseizinger
Copy link
Contributor Author

So, we are blowing the total cache limit with this setup which means we effectively don't have any caching ...

https://github.com/libp2p/rust-libp2p/actions/caches

@mxinden
Copy link
Member

mxinden commented Nov 25, 2022

With many pull requests tested using this setup: The per-crate test run is very helpful!

@thomaseizinger
Copy link
Contributor Author

With many pull requests tested using this setup: The per-crate test run is very helpful!

Good to hear! Just need to get the caching working now.

I am considering to make a "cache factory" workflow that only runs on master and make the PR workflows only restore but never save the cache.

@thomaseizinger thomaseizinger deleted the 2951-ci-matrix branch February 24, 2023 14:46
umgefahren pushed a commit to umgefahren/rust-libp2p that referenced this pull request 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More comprehensive CI test matrix
5 participants