Lint Python Code workflow (facebookresearch/large_concept_model)
The Lint Python Code workflow from facebookresearch/large_concept_model, explained and optimized by Latchkey.
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.
What it does
This is the Lint Python Code workflow from the facebookresearch/large_concept_model repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Lint Python Code
on:
# Trigger the workflow on push to master or any pull request
push:
pull_request:
branches:
- main
jobs:
lock_file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: uv lock --locked
linting:
runs-on: ubuntu-latest
needs: [lock_file]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: uvx ruff check .
formatting:
runs-on: ubuntu-latest
needs: [lock_file]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: uvx ruff check --select I .
- run: uvx ruff format --check .
type_consistency:
runs-on: ubuntu-latest
needs: [lock_file]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: uvx --with=types-PyYAML mypy
tests:
runs-on: ubuntu-latest
needs: [lock_file]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: uv run --extra cpu --extra eval --extra data pytest -v --full-trace
build:
runs-on: ubuntu-latest
needs: [lock_file, linting, formatting, type_consistency, tests]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: uv buildThe same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Lint Python Code on: # Trigger the workflow on push to master or any pull request push: pull_request: branches: - main concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: lock_file: timeout-minutes: 30 runs-on: latchkey-small steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - run: uv lock --locked linting: timeout-minutes: 30 runs-on: latchkey-small needs: [lock_file] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - run: uvx ruff check . formatting: timeout-minutes: 30 runs-on: latchkey-small needs: [lock_file] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - run: uvx ruff check --select I . - run: uvx ruff format --check . type_consistency: timeout-minutes: 30 runs-on: latchkey-small needs: [lock_file] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - run: uvx --with=types-PyYAML mypy tests: timeout-minutes: 30 runs-on: latchkey-small needs: [lock_file] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - run: uv run --extra cpu --extra eval --extra data pytest -v --full-trace build: timeout-minutes: 30 runs-on: latchkey-small needs: [lock_file, linting, formatting, type_consistency, tests] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup - run: uv build
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. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 6 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.