Skip to content
Latchkey

Pre-commit workflow (cocoindex-io/cocoindex-code)

The Pre-commit workflow from cocoindex-io/cocoindex-code, explained and optimized by Latchkey.

C

CI health: C - fair

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: cocoindex-io/cocoindex-code.github/workflows/pre-commit.ymlLicense Apache-2.0View source

What it does

This is the Pre-commit workflow from the cocoindex-io/cocoindex-code 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: Pre-commit

on:
  pull_request:
  push:
    branches:
      - main

jobs:
  pre-commit:
    runs-on: ${{ matrix.os }}
    # Free-threaded Python (3.14t) lacks pre-built wheels for tokenizers;
    # the fallback source build is fragile across macOS toolchain updates.
    continue-on-error: ${{ matrix.python-version == '3.14t' }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        python-version: ['3.11', '3.14t']
        exclude:
          # pywin32 doesn't have wheels for Python 3.14t (free-threaded) on Windows yet
          - os: windows-latest
            python-version: '3.14t'
          # tokenizers has no free-threaded wheel; the source-build fallback
          # fails to link on macOS arm64 since an Apr 2026 runner-image update.
          # Standard Python 3.14 (non-FT) users are unaffected - they pick up
          # tokenizers' abi3 wheel. Re-enable once HuggingFace/tokenizers ships
          # free-threaded wheels (or switch to a newer litellm that drops the
          # tokenizers dep).
          - os: macos-latest
            python-version: '3.14t'
    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v5
        with:
          enable-cache: true

      - name: Install dependencies
        run: uv sync --python ${{ matrix.python-version }} --python-preference only-managed

      - name: Lint & format (prek)
        run: uv run prek run --all-files --verbose --show-diff-on-failure --skip pytest

      - name: Test (pytest)
        run: uv run pytest tests/ -v

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Pre-commit
 
on:
  pull_request:
  push:
    branches:
      - main
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pre-commit:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    # Free-threaded Python (3.14t) lacks pre-built wheels for tokenizers;
    # the fallback source build is fragile across macOS toolchain updates.
    continue-on-error: ${{ matrix.python-version == '3.14t' }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        python-version: ['3.11', '3.14t']
        exclude:
          # pywin32 doesn't have wheels for Python 3.14t (free-threaded) on Windows yet
          - os: windows-latest
            python-version: '3.14t'
          # tokenizers has no free-threaded wheel; the source-build fallback
          # fails to link on macOS arm64 since an Apr 2026 runner-image update.
          # Standard Python 3.14 (non-FT) users are unaffected - they pick up
          # tokenizers' abi3 wheel. Re-enable once HuggingFace/tokenizers ships
          # free-threaded wheels (or switch to a newer litellm that drops the
          # tokenizers dep).
          - os: macos-latest
            python-version: '3.14t'
    steps:
      - uses: actions/checkout@v4
 
      - name: Install uv
        uses: astral-sh/setup-uv@v5
        with:
          enable-cache: true
 
      - name: Install dependencies
        run: uv sync --python ${{ matrix.python-version }} --python-preference only-managed
 
      - name: Lint & format (prek)
        run: uv run prek run --all-files --verbose --show-diff-on-failure --skip pytest
 
      - name: Test (pytest)
        run: uv run pytest tests/ -v
 

What changed

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 (6 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow