PR Size Labeler workflow (krkn-chaos/krkn)
The PR Size Labeler workflow from krkn-chaos/krkn, explained and optimized by Latchkey.
A
CI health: A - excellent
Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the PR Size Labeler workflow from the krkn-chaos/krkn 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
workflow (.yml)
name: PR Size Labeler
on:
pull_request_target:
types: [opened, synchronize, reopened, edited]
permissions:
pull-requests: write
issues: write
contents: read
jobs:
size-label:
runs-on: ubuntu-latest
steps:
- name: Label PR by size
uses: codelytv/pr-size-labeler@095a41fca88b8764fd9e008ad269bcdb82bb38b9 # v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
xs_label: "size/xs"
xs_max_size: "10"
s_label: "size/s"
s_max_size: "100"
m_label: "size/m"
m_max_size: "500"
l_label: "size/l"
l_max_size: "1000"
xl_label: "size/xl"
fail_if_xl: "false"
message_if_xl: >
This PR exceeds the recommended size of 1000 lines.
Please consider splitting it into smaller, focused PRs to make
it easier to review and reduce the risk of regressions.
files_to_ignore: "requirements.txt *.lock"
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: PR Size Labeler on: pull_request_target: types: [opened, synchronize, reopened, edited] permissions: pull-requests: write issues: write contents: read jobs: size-label: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Label PR by size uses: codelytv/pr-size-labeler@095a41fca88b8764fd9e008ad269bcdb82bb38b9 # v1 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} xs_label: "size/xs" xs_max_size: "10" s_label: "size/s" s_max_size: "100" m_label: "size/m" m_max_size: "500" l_label: "size/l" l_max_size: "1000" xl_label: "size/xl" fail_if_xl: "false" message_if_xl: > This PR exceeds the recommended size of 1000 lines. Please consider splitting it into smaller, focused PRs to make it easier to review and reduce the risk of regressions. files_to_ignore: "requirements.txt *.lock"
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. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.