Skip to content
Latchkey

Format & Lint workflow (NVIDIA/tilus)

The Format & Lint workflow from NVIDIA/tilus, explained and optimized by Latchkey.

A

CI health: A - excellent

Point runs-on at Latchkey and get 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: NVIDIA/tilus.github/workflows/format-and-lint.yamlLicense Apache-2.0View source

What it does

This is the Format & Lint workflow from the NVIDIA/tilus 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: Format & Lint

on:
  push:
    branches:
      - "pull-request/[0-9]+"

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  format-and-lint:
    if: github.repository == 'NVIDIA/tilus'
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Setup and Install Tilus
        id: setup-and-install
        uses: ./.github/actions/setup-environment
        with:
          python-version: '3.10'

      - name: Cache pre-commit environments
        uses: actions/cache@v4
        with:
          path: ~/.cache/pre-commit
          key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
          restore-keys: |
            pre-commit-${{ runner.os }}-

      - name: Install and setup pre-commit
        run: |
          echo "Pre-commit version: $(pre-commit --version)"
          pre-commit install-hooks

      - name: Run pre-commit checks
        run: |
          echo "Running all pre-commit hooks (skipping commit signature check)..."
          SKIP=check-commit-signature pre-commit run --all-files --show-diff-on-failure

      - name: Check for uncommitted changes
        run: |
          if [[ -n $(git status --porcelain) ]]; then
            echo "❌ Files were modified by pre-commit hooks. Please run 'pre-commit run --all-files' locally and commit the changes."
            echo "Modified files:"
            git status --porcelain
            echo "Showing diff:"
            git diff
            exit 1
          else
            echo "✅ No files were modified - all checks passed!"
          fi

The same workflow, on Latchkey

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

name: Format & Lint
 
on:
  push:
    branches:
      - "pull-request/[0-9]+"
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  format-and-lint:
    timeout-minutes: 30
    if: github.repository == 'NVIDIA/tilus'
    runs-on: latchkey-small
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
 
      - name: Setup and Install Tilus
        id: setup-and-install
        uses: ./.github/actions/setup-environment
        with:
          python-version: '3.10'
 
      - name: Cache pre-commit environments
        uses: actions/cache@v4
        with:
          path: ~/.cache/pre-commit
          key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
          restore-keys: |
            pre-commit-${{ runner.os }}-
 
      - name: Install and setup pre-commit
        run: |
          echo "Pre-commit version: $(pre-commit --version)"
          pre-commit install-hooks
 
      - name: Run pre-commit checks
        run: |
          echo "Running all pre-commit hooks (skipping commit signature check)..."
          SKIP=check-commit-signature pre-commit run --all-files --show-diff-on-failure
 
      - name: Check for uncommitted changes
        run: |
          if [[ -n $(git status --porcelain) ]]; then
            echo "❌ Files were modified by pre-commit hooks. Please run 'pre-commit run --all-files' locally and commit the changes."
            echo "Modified files:"
            git status --porcelain
            echo "Showing diff:"
            git diff
            exit 1
          else
            echo "✅ No files were modified - all checks passed!"
          fi
 

What changed

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