Skip to content
Latchkey

CI workflow (chardet/chardet)

The CI workflow from chardet/chardet, explained and optimized by Latchkey.

C

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.

Grade your own workflow free or run it on Latchkey →
Source: chardet/chardet.github/workflows/ci.ymlLicense 0BSDView source

What it does

This is the CI workflow from the chardet/chardet repository, a real project running GitHub Actions. It is shown here with attribution under its 0BSD license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: CI

on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.14"
      - run: uv sync
      - run: uv run prek run --all-files --show-diff-on-failure

  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
        os: [ubuntu-latest]
        include:
          - python-version: "3.14"
            os: macos-latest
          - python-version: "3.14"
            os: windows-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: ${{ matrix.python-version }}
      - run: uv sync
      - run: uv run pytest tests/ scripts/tests/ -q --tb=short --ignore=tests/test_accuracy.py --cov --cov-report=xml --cov-report=term-missing
      - name: Upload coverage to Codecov
        if: matrix.python-version == '3.14' && matrix.os == 'ubuntu-latest'
        uses: codecov/codecov-action@v5
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          slug: chardet/chardet
          fail_ci_if_error: false

  accuracy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.14"
      - run: uv sync
      - run: uv run pytest tests/test_accuracy.py -n auto -q --tb=short

  free-threaded:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.13t", "3.14t"]
        os: [ubuntu-latest, macos-latest]
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: ${{ matrix.python-version }}
      - run: uv sync
      - name: Verify GIL is disabled
        run: uv run python -c "import sys; assert not sys._is_gil_enabled(), 'GIL is not disabled'"
      - name: Run thread-safety tests
        run: uv run pytest tests/test_thread_safety.py -v -s -W error::pytest.PytestUnhandledThreadExceptionWarning
      - name: Run full test suite
        run: uv run pytest tests/ scripts/tests/ -q --tb=short --ignore=tests/test_accuracy.py --cov --cov-report=term-missing

The same workflow, on Latchkey

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

name: CI
 
on:
  push:
    branches: [main]
  pull_request:
 
permissions:
  contents: read
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  lint:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.14"
      - run: uv sync
      - run: uv run prek run --all-files --show-diff-on-failure
 
  test:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
        os: [ubuntu-latest]
        include:
          - python-version: "3.14"
            os: macos-latest
          - python-version: "3.14"
            os: windows-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: ${{ matrix.python-version }}
      - run: uv sync
      - run: uv run pytest tests/ scripts/tests/ -q --tb=short --ignore=tests/test_accuracy.py --cov --cov-report=xml --cov-report=term-missing
      - name: Upload coverage to Codecov
        if: matrix.python-version == '3.14' && matrix.os == 'ubuntu-latest'
        uses: codecov/codecov-action@v5
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          slug: chardet/chardet
          fail_ci_if_error: false
 
  accuracy:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.14"
      - run: uv sync
      - run: uv run pytest tests/test_accuracy.py -n auto -q --tb=short
 
  free-threaded:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.13t", "3.14t"]
        os: [ubuntu-latest, macos-latest]
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: ${{ matrix.python-version }}
      - run: uv sync
      - name: Verify GIL is disabled
        run: uv run python -c "import sys; assert not sys._is_gil_enabled(), 'GIL is not disabled'"
      - name: Run thread-safety tests
        run: uv run pytest tests/test_thread_safety.py -v -s -W error::pytest.PytestUnhandledThreadExceptionWarning
      - name: Run full test suite
        run: uv run pytest tests/ scripts/tests/ -q --tb=short --ignore=tests/test_accuracy.py --cov --cov-report=term-missing
 

What changed

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 4 jobs (11 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