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] automatically cancel GitHub Actions runs for outdated commits #5651

Merged
merged 1 commit into from
Dec 29, 2022

Conversation

jameslamb
Copy link
Collaborator

Proposes modifying the GitHub Actions jobs that run on every commit, such that GitHub automatically cancels in-progress runs on a given branch when a new commit is pushed to that branch.

Benefits of this change

Once a new commit has been pushed to master or to a pull request, it's not important that CI jobs for the previous commit run to completion.

Automatically cancelling those in-progress CI runs that are going to be ignored anyway is helpful because it:

  • increases the number of PRs that can be merged in a day
  • reduces the impact that one very active PR can have on throughput for the rest of the repo
  • reduces the load we place on GitHub Actions and other services the jobs hit
    • reduces the risk of triggering 409 - too many requests types of errors from services like GitHub, PyPI, CRAN, etc.
    • makes LightGBM a slightly better open source citizen (GitHub Actions is free and this project benefits from that)

It's important to remember that:

  • for everything except the CUDA jobs, we're limited to 20 concurrent jobs across all workflows and commits (docs link)
  • for the CUDA jobs, we're limited to 1 concurrent job across all workflows and commits, and we run 5 of those jobs on every commit

Notes for Reviewers

I first learned about that via this change to hypothesis: HypothesisWorks/hypothesis@b1f7a7c

See https://docs.github.com/en/actions/learn-github-actions/contexts for an explanation of the values that ${{ github.ref }} will take.

for branches the format is refs/heads/<branch_name>, for pull requests it is refs/pull/<pr_number>/merge, and for tags it is refs/tags/<tag_name>

Copy link
Collaborator

@jmoralez jmoralez left a comment

Choose a reason for hiding this comment

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

Nice! I know this will definitely help with those annoying linter errors.

@jameslamb
Copy link
Collaborator Author

Yeah! And especially with the buildup of CUDA jobs when more than one person is active on the repo at the same time.

thanks to @Zac-HD for teaching me about this during the SciPy 2022 sprints 😊

@jameslamb jameslamb merged commit 3d33c75 into master Dec 29, 2022
@jameslamb jameslamb deleted the ci/auto-cancel-ci branch December 29, 2022 16:29
@jameslamb
Copy link
Collaborator Author

Looks like this is working! I just merged a PR to master while another one's CUDA jobs were still running, and look what happened automatically:

image

Canceling since a higher priority waiting request for 'CUDA Version-refs/heads/master' exists

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed.
To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues
including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants