Check PR title workflow (TorchIO-project/torchio)
The Check PR title workflow from TorchIO-project/torchio, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Check PR title workflow from the TorchIO-project/torchio repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: "Check PR title"
on:
pull_request:
types: [edited, opened, synchronize, reopened]
permissions:
pull-requests: read
jobs:
pr-title-check:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login != 'allcontributors[bot]' }}
steps:
# Echo the user's login
- name: Echo user login
run: echo ${{ github.event.pull_request.user.login }}
- uses: naveenk1223/action-pr-title@master
with:
# ^ Start of string
# [A-Z] First character must be an uppercase ASCII letter
# [a-zA-Z]* Followed by zero or more ASCII letters
# (?<![^s]s) Negative lookbehind: disallow a single 's' at the end of the first word
# ( .+)+ At least one space and one or more characters (requires more words)
# [^.] Final character must not be a period
# $ End of string
regex: "^[A-Z][a-zA-Z]*(?<![^s]s)( .+)+[^.]$"
# Valid titles:
# - "Do something"
# - "Address something"
# Invalid title:
# - "do something"
# - "Do something."
# - "Does something"
# - "Do"
# - "Addresses something"
min_length: 10
max_length: 72
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: "Check PR title" on: pull_request: types: [edited, opened, synchronize, reopened] permissions: pull-requests: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: pr-title-check: timeout-minutes: 30 runs-on: latchkey-small if: ${{ github.event.pull_request.user.login != 'allcontributors[bot]' }} steps: # Echo the user's login - name: Echo user login run: echo ${{ github.event.pull_request.user.login }} - uses: naveenk1223/action-pr-title@master with: # ^ Start of string # [A-Z] First character must be an uppercase ASCII letter # [a-zA-Z]* Followed by zero or more ASCII letters # (?<![^s]s) Negative lookbehind: disallow a single 's' at the end of the first word # ( .+)+ At least one space and one or more characters (requires more words) # [^.] Final character must not be a period # $ End of string regex: "^[A-Z][a-zA-Z]*(?<![^s]s)( .+)+[^.]$" # Valid titles: # - "Do something" # - "Address something" # Invalid title: # - "do something" # - "Do something." # - "Does something" # - "Do" # - "Addresses something" min_length: 10 max_length: 72
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.