Skip to content
Latchkey

pre-commit workflow (apple/axlearn)

The pre-commit workflow from apple/axlearn, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get 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: apple/axlearn.github/workflows/pre-commit.ymlLicense Apache-2.0View source

What it does

This is the pre-commit workflow from the apple/axlearn 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

permissions:
  contents: read

on: [pull_request, merge_group]

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    # resource_class: large
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
          cache: 'pip'
      - run: pip install --upgrade pip
      - run: pip install uv
      - run: uv venv
      - run: |
          echo ".venv/bin" >> $GITHUB_PATH
          echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
      - run: uv pip install '.[core,audio,orbax,dev,gcp,vertexai_tensorboard,open_api]'
      # pylint uses approx 12GB of memory during this run, look into split to decrease?
      - run: |
          # Start memory monitor as a background process.
          { .github/scripts/monitor_memory.sh & } || true
          MONITOR_PID=$!
          # A short sleep to wait for monitor process to start.
          sleep 1

          # Start pre-commit check.
          echo "====== Starting pre-commit... ======"
          pre-commit run --all-files
          echo "====== pre-commit completed. ======"

          # Clean up memory monitor process.
          if kill -0 $MONITOR_PID 2>/dev/null; then
            echo "Manually stopping monitor process..."
            kill $MONITOR_PID || true
          fi

The same workflow, on Latchkey

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

name: pre-commit
 
permissions:
  contents: read
 
on: [pull_request, merge_group]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pre-commit:
    timeout-minutes: 30
    runs-on: latchkey-small
    # resource_class: large
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
          cache: 'pip'
      - run: pip install --upgrade pip
      - run: pip install uv
      - run: uv venv
      - run: |
          echo ".venv/bin" >> $GITHUB_PATH
          echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
      - run: uv pip install '.[core,audio,orbax,dev,gcp,vertexai_tensorboard,open_api]'
      # pylint uses approx 12GB of memory during this run, look into split to decrease?
      - run: |
          # Start memory monitor as a background process.
          { .github/scripts/monitor_memory.sh & } || true
          MONITOR_PID=$!
          # A short sleep to wait for monitor process to start.
          sleep 1
 
          # Start pre-commit check.
          echo "====== Starting pre-commit... ======"
          pre-commit run --all-files
          echo "====== pre-commit completed. ======"
 
          # Clean up memory monitor process.
          if kill -0 $MONITOR_PID 2>/dev/null; then
            echo "Manually stopping monitor process..."
            kill $MONITOR_PID || true
          fi
 

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

Actions used in this workflow