Skip to content
Latchkey

Auto Format with Black workflow (NVIDIA/NVFlare)

The Auto Format with Black workflow from NVIDIA/NVFlare, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, 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: NVIDIA/NVFlare.github/workflows/auto-format.ymlLicense Apache-2.0View source

What it does

This is the Auto Format with Black workflow from the NVIDIA/NVFlare 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: Auto Format with Black

on:
  repository_dispatch:
    types: [format]

jobs:
  black-format:
    runs-on: ubuntu-latest
    env:
     DIRS: "nvflare examples tests dev_tools"

    steps:
      - name: Checkout repo
        uses: NVIDIA/spark-rapids-common/checkout@main
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          fetch-depth: 0  

      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: 3.14

      # versions need to be consistent with setup.cfg
      - name: Install isort
        run: pip install isort==5.13.2

      - name: Run isort
        run: python -m isort $DIRS

      - name: Install black
        run: pip install black==25.9.0

      - name: Run black
        run: python -m black $DIRS

      - name: Install flake8
        run: pip install flake8==7.1.1

      - name: Run flake8
        run: python -m flake8 $DIRS

      - name: Commit and push changes
        run: |
          git config user.name "github-actions"
          git config user.email "github-actions@github.com"
          git add .
          git diff --cached --quiet || git commit -m "Auto format with black"
          git push

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: Auto Format with Black
 
on:
  repository_dispatch:
    types: [format]
 
jobs:
  black-format:
    timeout-minutes: 30
    runs-on: latchkey-small
    env:
     DIRS: "nvflare examples tests dev_tools"
 
    steps:
      - name: Checkout repo
        uses: NVIDIA/spark-rapids-common/checkout@main
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          fetch-depth: 0  
 
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: 3.14
 
      # versions need to be consistent with setup.cfg
      - name: Install isort
        run: pip install isort==5.13.2
 
      - name: Run isort
        run: python -m isort $DIRS
 
      - name: Install black
        run: pip install black==25.9.0
 
      - name: Run black
        run: python -m black $DIRS
 
      - name: Install flake8
        run: pip install flake8==7.1.1
 
      - name: Run flake8
        run: python -m flake8 $DIRS
 
      - name: Commit and push changes
        run: |
          git config user.name "github-actions"
          git config user.email "github-actions@github.com"
          git add .
          git diff --cached --quiet || git commit -m "Auto format with black"
          git push
 

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

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