pre-commit workflow (okteto/okteto)
The pre-commit workflow from okteto/okteto, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the pre-commit workflow from the okteto/okteto 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: pre-commit
on: [pull_request]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
pre-commit:
name: Run pre-commit # https://pre-commit.com/
runs-on: ubuntu-latest
steps:
- name: 'Checkout ${{ github.ref }} ( ${{ github.sha }} )'
uses: actions/checkout@v7
- uses: actions/setup-python@v6 # https://www.python.org/
with:
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Install dependencies # https://pip.pypa.io/en/stable/
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> "$GITHUB_ENV"
- uses: actions/cache@v6
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: pre-commit run --all-files
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: pre-commit on: [pull_request] permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} jobs: pre-commit: timeout-minutes: 30 name: Run pre-commit # https://pre-commit.com/ runs-on: latchkey-small steps: - name: 'Checkout ${{ github.ref }} ( ${{ github.sha }} )' uses: actions/checkout@v7 - uses: actions/setup-python@v6 # https://www.python.org/ with: cache: 'pip' python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified - name: Install dependencies # https://pip.pypa.io/en/stable/ run: | python -m pip install --upgrade pip pip install pre-commit - name: set PY run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> "$GITHUB_ENV" - uses: actions/cache@v6 with: path: ~/.cache/pre-commit key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} - name: Run pre-commit run: pre-commit run --all-files
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. - Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.