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

Improve GitHub Actions for faster checks and better readability #3377

Merged
merged 11 commits into from
Jan 25, 2022

Conversation

gustavovalverde
Copy link
Member

@gustavovalverde gustavovalverde commented Jan 21, 2022

Motivation

All GitHub Actions workflows that are triggered by an event, are being run independently of the files or folder changed. Making all PRs take the same amount of CI time and going through the whole test suite.

Depending on the files being changed, specific workflows must run, not all of them if not needed.

Related to: #3359
Depends-On: #3386

Solution

  • Move linting and styling to a specific workflow, making each workflow have a specific responsibility
  • Add paths to workflows triggered by a GitHub event
  • CI: Do not run twice (on push to main and PRs to main), just run on PRs as Mergify also runs the CI before merging with the latest tip from main. Just run on changes to Rust files, Cargo files, or the Dockerfile.
  • Coverage: Same as CI; excluding the Dockerfile.
  • Docs: Just when the book/ folder is changed or any firebase configuration.
  • Lint: Just run on changes to Rust files or the Clippy configuration.
  • Test: Same as CI; adding the book/ folder.

Review

The whole @ZcashFoundation/zebra-team should review this.

Follow Up Work

Add Check deny.toml crate dependencies and validate licenses to the list of required checks for each PR, in the Zebra GitHub repository settings.

Another PR will include better use of GitHub variables, removing not-needed steps, using major versions on actions, and allowing automatic bug fixes. It will also improve overall readability and secret management.

Edit: Moving pull-request (zealous-zebra) to a GitHub Action.

Lint on push to all branches, except for main, as this action will be required to merge.

Just run the lint action when a Rust file is changed, as it won't make sense to run it on other scenarios.

DRY with uneeded jobs
@gustavovalverde gustavovalverde added A-devops Area: Pipelines, CI/CD and Dockerfiles P-High 🔥 labels Jan 21, 2022
@gustavovalverde gustavovalverde self-assigned this Jan 21, 2022
@codecov
Copy link

codecov bot commented Jan 21, 2022

Codecov Report

Merging #3377 (ed4f4ce) into main (499ae89) will decrease coverage by 0.07%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #3377      +/-   ##
==========================================
- Coverage   78.34%   78.26%   -0.08%     
==========================================
  Files         267      267              
  Lines       31526    31526              
==========================================
- Hits        24698    24675      -23     
- Misses       6828     6851      +23     

@mpguerra
Copy link
Contributor

I wonder which tests we want to run when tagging a new release, e.g PR #3256

These PRs typically change:

  • CHANGELOG.md
  • README.md
  • zebra-network/src/constants.rs < this is probably the riskiest change...
  • Cargo.lock, and
  • all of the Cargo.toml files for the crates for which we are incrementing the release number.

On the one hand it would be nice to run the whole test suite, on the other hand it doesn't really seem necessary and can delay tagging the release sometimes...

@ZcashFoundation/zebra-team any thoughts?

@teor2345
Copy link
Contributor

teor2345 commented Jan 23, 2022

I don't think there's any way to avoid running the full test suite for changes to these files:

  • zebra-network/src/constants.rs
  • Cargo.lock

Since cargo lock can change dependency versions, we need to run the full test suite on any changes to these files. We could automate updating the user agent in the zebra network constants, but that wouldn't actually change the overall risk of tagging a release.

Instead, if our tests are running too slowly, we should consider paying for a bigger machine to run tests on.

Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

This seems like a useful change, but the path inclusions could be quite risky.

How do we know that we haven't accidentally missed some paths that should be checked?
How will we make sure we keep the list of paths up to date as we make changes to Zebra?

Can we exclude paths that we are sure aren't needed, rather than trying to track all of the paths that are needed?
Using an exclude list is less risky, because if we forget to exclude some files, then CI just becomes a bit slower. But if we forget to include some files, we can merge bugs into the zebra main branch.

I also wonder about the GitHub CI cache limit. We are already hitting that limit, and adding more jobs will increase our cache usage. So we should check that this new set of jobs is actually faster, particularly after the caches have been populated.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/coverage.yml Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/docs.yml Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/coverage.yml Outdated Show resolved Hide resolved
.github/workflows/lint.yml Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
Also refactor this to use a more redable and change prone cargo-deny-action. And move this actions out of the clippy-deps job, as this are more related to CI than linting.
Add advisories checks in a different PR
@gustavovalverde
Copy link
Member Author

How do we know that we haven't accidentally missed some paths that should be checked?
How will we make sure we keep the list of paths up to date as we make changes to Zebra?

At least for the most critical workflows (CI, Coverage, Lint, and Test), we're covering over 99% of the codebase with:

  • **/*.rs

And considering most critical changes with:

  • **/*.txt
  • **/Cargo.toml
  • **/Cargo.lock

@teor2345
Copy link
Contributor

How do we know that we haven't accidentally missed some paths that should be checked?
How will we make sure we keep the list of paths up to date as we make changes to Zebra?

At least for the most critical workflows (CI, Coverage, Lint, and Test), we're covering over 99% of the codebase

Ok, that seems fine for now. If some bugs get through CI, we can fix it then.

Copy link
Contributor

@teor2345 teor2345 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, thanks for splitting out the functionality changes into a separate PR.

I just have a few questions about when jobs need to run.

.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/coverage.yml Outdated Show resolved Hide resolved
@teor2345 teor2345 dismissed their stale review January 25, 2022 05:22

Major issues got fixed

@teor2345
Copy link
Contributor

@gustavovalverde this PR splits a CI job that is required to merge. So we need to add the new Check deny.toml crate dependencies and validate licenses job to the Zebra GitHub repository config.

(The dependency checks are important, so they should be required to merge.)

@teor2345 teor2345 linked an issue Jan 25, 2022 that may be closed by this pull request
If we only run CI on branches that are going to merge to main, then PR series become a lot harder to test. (Because each PR is based on the previous PR, not main.)
@teor2345 teor2345 self-requested a review January 25, 2022 05:49
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

This looks good to me, but maybe we should get @dconnolly to do a review as well.

@gustavovalverde gustavovalverde merged commit 6373a95 into main Jan 25, 2022
@gustavovalverde gustavovalverde deleted the ci-refactor-actions branch January 25, 2022 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-devops Area: Pipelines, CI/CD and Dockerfiles
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop ignoring dependency changes in the Cargo.lock up-to-date check
3 participants