autoclose comment workflow (scikit-learn/scikit-learn)
The autoclose comment workflow from scikit-learn/scikit-learn, explained and optimized by Latchkey.
- A
- CI health grade
- 85/100
- Health score
- 1
- Job per trigger
- 2
- Fixes in the optimized version
In short
- CI health: A (excellent)
- The optimized version below points runs-on at Latchkey managed runners and adds job timeouts.
What it does
This is the autoclose comment workflow from the scikit-learn/scikit-learn repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: autoclose comment
# Post comment on PRs when labeled with "autoclose".
permissions:
contents: read
pull-requests: write
on:
pull_request_target:
types:
- labeled
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
jobs:
post_comment:
name: post_comment
if: github.event.label.name == 'autoclose'
runs-on: ubuntu-latest
steps:
- name: comment on potential autoclose
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/$GH_REPO/issues/$PULL_REQUEST_NUMBER/comments \
-f "body=$BODY"
env:
BODY: >
⏰ This pull request might be automatically closed in two weeks from now.
Thank you for your contribution to scikit-learn and for the effort you have
put into this PR. This pull request does not yet meet the quality and
clarity needed for an effective review. Project maintainers have limited
time for code reviews, and our goal is to prioritize well-prepared
contributions to keep scikit-learn maintainable.
To increase the chance of a productive review, please refer to: [How do I
improve my issue or pull
request?](https://scikit-learn.org/dev/faq.html#how-do-i-improve-my-issue-or-pull-request)
As the author, you are responsible for driving this PR, which entails doing
necessary background research as well as presenting its context and your
thought process. If you are a [new
contributor](https://scikit-learn.org/dev/developers/contributing.html#new-contributors),
or do not know how to fulfill these requirements, we recommend that you
familiarise yourself with scikit-learn's development conventions via other
contribution types (e.g., reviewing PRs) before submitting code.
Scikit-learn maintainers cannot provide one-to-one guidance on this PR.
However, if you ask focused, well-researched questions, a community
member may be willing to help. 💬
If you substantially improve this PR within two weeks, a team member may
remove the `autoclose` label and the PR stays open. Cosmetic changes or
incomplete fixes will not be sufficient. Maintainers will assess
improvements on their own schedule. Please do not ping (`@`) maintainers.The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: autoclose comment
# Post comment on PRs when labeled with "autoclose".
permissions:
contents: read
pull-requests: write
on:
pull_request_target:
types:
- labeled
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
jobs:
post_comment:
timeout-minutes: 30
name: post_comment
if: github.event.label.name == 'autoclose'
runs-on: ubuntu-latest
runs-on: latchkey-small
steps:
- name: comment on potential autoclose
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/$GH_REPO/issues/$PULL_REQUEST_NUMBER/comments \
-f "body=$BODY"
env:
BODY: >
⏰ This pull request might be automatically closed in two weeks from now.
Thank you for your contribution to scikit-learn and for the effort you have
put into this PR. This pull request does not yet meet the quality and
clarity needed for an effective review. Project maintainers have limited
time for code reviews, and our goal is to prioritize well-prepared
contributions to keep scikit-learn maintainable.
To increase the chance of a productive review, please refer to: [How do I
improve my issue or pull
request?](https://scikit-learn.org/dev/faq.html#how-do-i-improve-my-issue-or-pull-request)
As the author, you are responsible for driving this PR, which entails doing
necessary background research as well as presenting its context and your
thought process. If you are a [new
contributor](https://scikit-learn.org/dev/developers/contributing.html#new-contributors),
or do not know how to fulfill these requirements, we recommend that you
familiarise yourself with scikit-learn's development conventions via other
contribution types (e.g., reviewing PRs) before submitting code.
Scikit-learn maintainers cannot provide one-to-one guidance on this PR.
However, if you ask focused, well-researched questions, a community
member may be willing to help. 💬
If you substantially improve this PR within two weeks, a team member may
remove the `autoclose` label and the PR stays open. Cosmetic changes or
incomplete fixes will not be sufficient. Maintainers will assess
improvements on their own schedule. Please do not ping (`@`) maintainers.
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. Each Linux x64 job moves to the Latchkey size matching its vCPU count,latchkey-smallfor a standard 2 vCPU runner; macOS, Windows and arm64 jobs stay as written. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job per trigger. It runs on a standard GitHub-hosted Linux x64 runner, which in a private repository bills $0.006 a minute against $0.0025 on latchkey-small, 58% lower; in a public repository like this one it is free. Estimate the monthly difference with your own run counts.