Pull-request workflow (vkbottle/vkbottle)
The Pull-request workflow from vkbottle/vkbottle, 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 Pull-request workflow from the vkbottle/vkbottle repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Pull-request
'on':
pull_request:
branches:
- master
- dev
defaults:
run:
shell: bash
jobs:
pre-commit:
if: github.repository == 'vkbottle/vkbottle'
runs-on: ubuntu-latest
env:
PRE_COMMIT_CACHE_DIR: ${{ github.workspace }}/.pre-commit-cache
permissions:
actions: write
steps:
- name: Ensure pre-commit cache directory exists
run: mkdir -p "$PRE_COMMIT_CACHE_DIR"
- name: Load pre-commit cache
id: cached-pre-commit
uses: actions/cache/restore@v5
with:
key: pre-commit-3.10-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml', 'pyproject.toml', 'poetry.lock') }}
restore-keys: |
pre-commit-3.10-${{ runner.os }}-
path: ${{ env.PRE_COMMIT_CACHE_DIR }}
- name: Checkout code
uses: asottile/workflows/.github/actions/fast-checkout@v1.11.0
with:
fetch-depth: 0
- name: Install poetry and dependencies
uses: ./.github/actions/install-dependencies
with:
os: ubuntu-latest
python-version: "3.10"
- name: Run pre-commit
run: |
export PRE_COMMIT_HOME="$PRE_COMMIT_CACHE_DIR"
poetry run pre-commit run \
--from-ref ${{ github.event.pull_request.base.sha }} \
--to-ref ${{ github.event.pull_request.head.sha }} \
--show-diff-on-failure --color=always
- name: Save pre-commit cache
if: always() && steps.cached-pre-commit.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
key: ${{ steps.cached-pre-commit.outputs.cache-primary-key }}
path: ${{ env.PRE_COMMIT_CACHE_DIR }}
- uses: pre-commit-ci/lite-action@v1.1.0
if: always()
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Pull-request 'on': pull_request: branches: - master - dev defaults: run: shell: bash concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: pre-commit: timeout-minutes: 30 if: github.repository == 'vkbottle/vkbottle' runs-on: latchkey-small env: PRE_COMMIT_CACHE_DIR: ${{ github.workspace }}/.pre-commit-cache permissions: actions: write steps: - name: Ensure pre-commit cache directory exists run: mkdir -p "$PRE_COMMIT_CACHE_DIR" - name: Load pre-commit cache id: cached-pre-commit uses: actions/cache/restore@v5 with: key: pre-commit-3.10-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml', 'pyproject.toml', 'poetry.lock') }} restore-keys: | pre-commit-3.10-${{ runner.os }}- path: ${{ env.PRE_COMMIT_CACHE_DIR }} - name: Checkout code uses: asottile/workflows/.github/actions/fast-checkout@v1.11.0 with: fetch-depth: 0 - name: Install poetry and dependencies uses: ./.github/actions/install-dependencies with: os: ubuntu-latest python-version: "3.10" - name: Run pre-commit run: | export PRE_COMMIT_HOME="$PRE_COMMIT_CACHE_DIR" poetry run pre-commit run \ --from-ref ${{ github.event.pull_request.base.sha }} \ --to-ref ${{ github.event.pull_request.head.sha }} \ --show-diff-on-failure --color=always - name: Save pre-commit cache if: always() && steps.cached-pre-commit.outputs.cache-hit != 'true' uses: actions/cache/save@v5 with: key: ${{ steps.cached-pre-commit.outputs.cache-primary-key }} path: ${{ env.PRE_COMMIT_CACHE_DIR }} - uses: pre-commit-ci/lite-action@v1.1.0 if: always()
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.
2 third-party actions are referenced by a movable tag. Pin them 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.