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

workflows: add cancel-pr-tests to cancel CI on PR closure #147501

Merged
merged 1 commit into from
Oct 1, 2023

Conversation

ZhongRuoyu
Copy link
Member

@ZhongRuoyu ZhongRuoyu commented Sep 30, 2023

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

Continue running the tests after a PR is closed is a waste of our CI resources, so let's cancel the tests when a PR is closed.

The check-ci-status command has been refactored to support this.

To try the updated check-ci-status command:

export CI=1 GITHUB_REPOSITORY=Homebrew/homebrew-core GITHUB_OUTPUT=/dev/null
# Existing functionality: check if long-timeout label can be removed
brew check-ci-status --debug --long-timeout-label $pr_number
# New: check if workflow on CI is cancellable
# If true, return its workflow ID; otherwise, return null
brew check-ci-status --debug --cancel $pr_number

@ZhongRuoyu ZhongRuoyu requested review from MikeMcQuaid and a team as code owners September 30, 2023 04:25
@github-actions github-actions bot added automerge-skip `brew pr-automerge` will skip this pull request workflows PR modifies GitHub Actions workflow files labels Sep 30, 2023
Continue running the tests after a PR is closed is a waste of our CI
resources, so let's cancel the tests when a PR is closed.

The `check-ci-status` command has been refactored to support this.
Copy link
Member

@MikeMcQuaid MikeMcQuaid 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!

@ZhongRuoyu
Copy link
Member Author

Let's merge this; I'll try it out in a test PR.

@ZhongRuoyu ZhongRuoyu added this pull request to the merge queue Oct 1, 2023
Merged via the queue into Homebrew:master with commit f9c285e Oct 1, 2023
15 checks passed
@ZhongRuoyu ZhongRuoyu deleted the cancel-pr-tests branch October 1, 2023 15:35
@ZhongRuoyu ZhongRuoyu mentioned this pull request Oct 1, 2023
6 tasks
@ZhongRuoyu
Copy link
Member Author

ZhongRuoyu commented Oct 1, 2023

This workflow works 🎉 (see https://github.com/Homebrew/homebrew-core/actions/runs/6371658945?pr=148503).

However, it doesn't take care of the case where the PR is closed and later reopened, because the current logic in the check-ci-status command always checks the first run (which in other cases should be the only one). See #148503 (comment) for details. #148530 should fix this. (Update: yes, this is now fixed.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge-skip `brew pr-automerge` will skip this pull request workflows PR modifies GitHub Actions workflow files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants