Skip to content
Latchkey

Lint workflow (ezyang/ghstack)

The Lint workflow from ezyang/ghstack, explained and optimized by Latchkey.

B

CI health: B - good

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: ezyang/ghstack.github/workflows/lint.ymlLicense MITView source

What it does

This is the Lint workflow from the ezyang/ghstack 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

workflow (.yml)
name: Lint
on:
  pull_request:
  push:
    branches:
      - main

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  lint:
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.13"]
        os: ["ubuntu-latest"]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Install uv
        uses: astral-sh/setup-uv@v5
        with:
          python-version: ${{ matrix.python-version }}
          enable-cache: true
          cache-suffix: "optional-suffix"
      - name: Run lint
        run: |
          RC=0
          # Run lintrunner on all files
          if ! uv run --frozen lintrunner --force-color --all-files --tee-json=lint.json 2> /dev/null; then
            echo ""
            echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner\`. (If you don't get the same results, run \'lintrunner init\' to update your local linter)\e[0m"
            RC=1
          fi

          # Use jq to massage the JSON lint output into GitHub Actions workflow commands.
          jq --raw-output \
            '"::\(if .severity == "advice" or .severity == "disabled" then "warning" else .severity end) file=\(.path),line=\(.line),col=\(.char),title=\(.code) \(.name)::" + (.description | gsub("\\n"; "%0A"))' \
            lint.json || true

          exit $RC

The same workflow, on Latchkey

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

name: Lint
on:
  pull_request:
  push:
    branches:
      - main
 
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true
 
jobs:
  lint:
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.13"]
        os: ["ubuntu-latest"]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Install uv
        uses: astral-sh/setup-uv@v5
        with:
          python-version: ${{ matrix.python-version }}
          enable-cache: true
          cache-suffix: "optional-suffix"
      - name: Run lint
        run: |
          RC=0
          # Run lintrunner on all files
          if ! uv run --frozen lintrunner --force-color --all-files --tee-json=lint.json 2> /dev/null; then
            echo ""
            echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner\`. (If you don't get the same results, run \'lintrunner init\' to update your local linter)\e[0m"
            RC=1
          fi
 
          # Use jq to massage the JSON lint output into GitHub Actions workflow commands.
          jq --raw-output \
            '"::\(if .severity == "advice" or .severity == "disabled" then "warning" else .severity end) file=\(.path),line=\(.line),col=\(.char),title=\(.code) \(.name)::" + (.description | gsub("\\n"; "%0A"))' \
            lint.json || true
 
          exit $RC
 

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.

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