Skip to content
Latchkey

CI workflow (huggingface/evaluate)

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

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: huggingface/evaluate.github/workflows/ci.ymlLicense Apache-2.0View source

What it does

This is the CI workflow from the huggingface/evaluate 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: CI

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main
      - ci-*

env:
  HF_ALLOW_CODE_EVAL: 1
  CI_HEADERS: ${{ secrets.CI_HEADERS }}

jobs:

  check_code_quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd  # v6.0.2
      - name: Set up Python
        uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c  # v4
        with:
          python-version: "3.9"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install .[quality]
      - name: Check quality
        run: |
          black --check --line-length 119 --target-version py36 tests src metrics comparisons measurements
          isort --check-only tests src metrics comparisons measurements
          flake8 tests src metrics

  test:
    needs: check_code_quality
    strategy:
      fail-fast: false
      matrix:
        test: ['unit', 'parity']
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd  # v6.0.2
        with:
          fetch-depth: 0
      - name: Set up Python 3.9
        uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c  # v4
        with:
          python-version: "3.9"
      - name: Upgrade pip
        run: python -m pip install --upgrade pip
      - name: Install dependencies
        run: |
          pip install .[tests]
          pip install -r additional-tests-requirements.txt --no-deps
      - name: Test with pytest
        if: ${{ matrix.test == 'unit' }}
        run: |
          python -m pytest -n 2 --dist loadfile -sv ./tests/ --ignore=./tests/test_trainer_evaluator_parity.py
      - name: Integration test with transformers
        if: ${{ matrix.test == 'parity' }}
        run: |
          python -m pytest -n 2 --dist loadfile -sv ./tests/test_trainer_evaluator_parity.py

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: CI
 
on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main
      - ci-*
 
env:
  HF_ALLOW_CODE_EVAL: 1
  CI_HEADERS: ${{ secrets.CI_HEADERS }}
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
 
  check_code_quality:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd  # v6.0.2
      - name: Set up Python
        uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c  # v4
        with:
          cache: 'pip'
          python-version: "3.9"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install .[quality]
      - name: Check quality
        run: |
          black --check --line-length 119 --target-version py36 tests src metrics comparisons measurements
          isort --check-only tests src metrics comparisons measurements
          flake8 tests src metrics
 
  test:
    timeout-minutes: 30
    needs: check_code_quality
    strategy:
      fail-fast: false
      matrix:
        test: ['unit', 'parity']
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd  # v6.0.2
        with:
          fetch-depth: 0
      - name: Set up Python 3.9
        uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c  # v4
        with:
          cache: 'pip'
          python-version: "3.9"
      - name: Upgrade pip
        run: python -m pip install --upgrade pip
      - name: Install dependencies
        run: |
          pip install .[tests]
          pip install -r additional-tests-requirements.txt --no-deps
      - name: Test with pytest
        if: ${{ matrix.test == 'unit' }}
        run: |
          python -m pytest -n 2 --dist loadfile -sv ./tests/ --ignore=./tests/test_trainer_evaluator_parity.py
      - name: Integration test with transformers
        if: ${{ matrix.test == 'parity' }}
        run: |
          python -m pytest -n 2 --dist loadfile -sv ./tests/test_trainer_evaluator_parity.py
 

What changed

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:

This workflow runs 2 jobs (5 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