Skip to content
Latchkey

PR Tests workflow (NVIDIA/tilus)

The PR Tests workflow from NVIDIA/tilus, explained and optimized by Latchkey.

B

CI health: B - good

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

What it does

This is the PR Tests 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: PR Tests

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

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

jobs:
  check-changes:
    if: github.repository == 'NVIDIA/tilus'
    runs-on: ubuntu-latest
    outputs:
      should_run_tests: ${{ steps.changed-tests.outputs.any_changed }}
      should_run_examples: ${{ steps.changed-examples.outputs.any_changed }}
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Check for changes in test-relevant directories
        id: changed-tests
        uses: step-security/changed-files@v46
        with:
          files: |
            tests/**
            python/**
            docs/source/_static/layout-demo/**
            pyproject.toml
          base_sha: 'origin/main'

      - name: Check for changes in examples
        id: changed-examples
        uses: step-security/changed-files@v46
        with:
          files: |
            python/**
            examples/**
            pyproject.toml
          base_sha: 'origin/main'

  test-python-compat:
    needs: check-changes
    if: github.repository == 'NVIDIA/tilus' && needs.check-changes.outputs.should_run_tests == 'true'
    runs-on: linux-amd64-gpu-l4-latest-1
    container:
      image: nvidia/cuda:13.0.0-devel-ubuntu22.04
      options: --gpus all
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Install dependencies
        env:
          DEBIAN_FRONTEND: noninteractive
        run: |
          apt-get update && apt-get install -y git cmake nodejs software-properties-common
          add-apt-repository -y ppa:deadsnakes/ppa
          apt-get update && apt-get install -y python3.10 python3.10-venv python3.10-dev \
            python3.11 python3.11-venv python3.11-dev \
            python3.12 python3.12-venv python3.12-dev \
            python3.13 python3.13-venv python3.13-dev

      - name: Mark repo as safe for git
        run: |
          git config --global --add safe.directory "$GITHUB_WORKSPACE"
          git config --system --add safe.directory "$GITHUB_WORKSPACE"

      - name: Run smoke tests across Python versions
        shell: bash
        run: |
          # Derive version from git so setuptools-scm doesn't need git access during build
          export SETUPTOOLS_SCM_PRETEND_VERSION=$(python3.10 -c "
          from setuptools_scm import get_version
          print(get_version())
          " 2>/dev/null || git describe --tags --always 2>/dev/null || echo "0.0.0")

          echo "Using version: $SETUPTOOLS_SCM_PRETEND_VERSION"

          for pyver in 3.10 3.11 3.12 3.13; do
            echo "========================================="
            echo "Testing Python $pyver"
            echo "========================================="
            python${pyver} -m venv /tmp/venv-${pyver}
            source /tmp/venv-${pyver}/bin/activate
            pip install --upgrade pip
            pip install ".[dev]"
            pytest tests/kernels/matmul/test_matmul_v2.py -v
            deactivate
            rm -rf /tmp/venv-${pyver}
          done

  test-core:
    needs: check-changes
    if: github.repository == 'NVIDIA/tilus' && needs.check-changes.outputs.should_run_tests == 'true'
    continue-on-error: true
    strategy:
      matrix:
        runner:
          - linux-amd64-gpu-l4-latest-1
    runs-on: ${{ matrix.runner }}
    container:
      image: nvidia/cuda:13.0.0-devel-ubuntu22.04
      options: --gpus all
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

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

      - name: Run main tests
        run: pytest ./tests --ignore=tests/examples/

  test-examples:
    needs: check-changes
    if: github.repository == 'NVIDIA/tilus' && needs.check-changes.outputs.should_run_examples == 'true'
    runs-on: linux-amd64-gpu-l4-latest-1
    container:
      image: nvidia/cuda:13.0.0-devel-ubuntu22.04
      options: --gpus all
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

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


      - name: Run unit tests
        run: pytest tests/examples/ -v

  all-functional-tests:
    name: All Functional Tests
    needs: [test-python-compat, test-core, test-examples]
    if: always() && github.repository == 'NVIDIA/tilus'
    runs-on: ubuntu-latest
    steps:
      - name: Check job results
        run: |
          echo "Python compat result: ${{ needs.test-python-compat.result }}"
          echo "Core tests result: ${{ needs.test-core.result }}"
          echo "Example tests result: ${{ needs.test-examples.result }}"

          # Check if any required job failed
          if [[ "${{ needs.test-python-compat.result }}" == "failure" ]] || [[ "${{ needs.test-core.result }}" == "failure" ]] || [[ "${{ needs.test-examples.result }}" == "failure" ]]; then
            echo "One or more functional tests failed"
            exit 1
          elif [[ "${{ needs.test-python-compat.result }}" == "cancelled" ]] || [[ "${{ needs.test-core.result }}" == "cancelled" ]] || [[ "${{ needs.test-examples.result }}" == "cancelled" ]]; then
            echo "One or more functional tests were cancelled"
            exit 1
          else
            echo "All functional tests passed or were skipped"
          fi

The same workflow, on Latchkey

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

name: PR Tests
 
on:
  push:
    branches:
      - "pull-request/[0-9]+"
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  check-changes:
    timeout-minutes: 30
    if: github.repository == 'NVIDIA/tilus'
    runs-on: latchkey-small
    outputs:
      should_run_tests: ${{ steps.changed-tests.outputs.any_changed }}
      should_run_examples: ${{ steps.changed-examples.outputs.any_changed }}
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
 
      - name: Check for changes in test-relevant directories
        id: changed-tests
        uses: step-security/changed-files@v46
        with:
          files: |
            tests/**
            python/**
            docs/source/_static/layout-demo/**
            pyproject.toml
          base_sha: 'origin/main'
 
      - name: Check for changes in examples
        id: changed-examples
        uses: step-security/changed-files@v46
        with:
          files: |
            python/**
            examples/**
            pyproject.toml
          base_sha: 'origin/main'
 
  test-python-compat:
    timeout-minutes: 30
    needs: check-changes
    if: github.repository == 'NVIDIA/tilus' && needs.check-changes.outputs.should_run_tests == 'true'
    runs-on: linux-amd64-gpu-l4-latest-1
    container:
      image: nvidia/cuda:13.0.0-devel-ubuntu22.04
      options: --gpus all
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
 
      - name: Install dependencies
        env:
          DEBIAN_FRONTEND: noninteractive
        run: |
          apt-get update && apt-get install -y git cmake nodejs software-properties-common
          add-apt-repository -y ppa:deadsnakes/ppa
          apt-get update && apt-get install -y python3.10 python3.10-venv python3.10-dev \
            python3.11 python3.11-venv python3.11-dev \
            python3.12 python3.12-venv python3.12-dev \
            python3.13 python3.13-venv python3.13-dev
 
      - name: Mark repo as safe for git
        run: |
          git config --global --add safe.directory "$GITHUB_WORKSPACE"
          git config --system --add safe.directory "$GITHUB_WORKSPACE"
 
      - name: Run smoke tests across Python versions
        shell: bash
        run: |
          # Derive version from git so setuptools-scm doesn't need git access during build
          export SETUPTOOLS_SCM_PRETEND_VERSION=$(python3.10 -c "
          from setuptools_scm import get_version
          print(get_version())
          " 2>/dev/null || git describe --tags --always 2>/dev/null || echo "0.0.0")
 
          echo "Using version: $SETUPTOOLS_SCM_PRETEND_VERSION"
 
          for pyver in 3.10 3.11 3.12 3.13; do
            echo "========================================="
            echo "Testing Python $pyver"
            echo "========================================="
            python${pyver} -m venv /tmp/venv-${pyver}
            source /tmp/venv-${pyver}/bin/activate
            pip install --upgrade pip
            pip install ".[dev]"
            pytest tests/kernels/matmul/test_matmul_v2.py -v
            deactivate
            rm -rf /tmp/venv-${pyver}
          done
 
  test-core:
    timeout-minutes: 30
    needs: check-changes
    if: github.repository == 'NVIDIA/tilus' && needs.check-changes.outputs.should_run_tests == 'true'
    continue-on-error: true
    strategy:
      matrix:
        runner:
          - linux-amd64-gpu-l4-latest-1
    runs-on: ${{ matrix.runner }}
    container:
      image: nvidia/cuda:13.0.0-devel-ubuntu22.04
      options: --gpus all
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
 
      - name: Setup and Install Tilus
        id: setup-and-install
        uses: ./.github/actions/setup-environment
        with:
          python-version: '3.10'
 
      - name: Run main tests
        run: pytest ./tests --ignore=tests/examples/
 
  test-examples:
    timeout-minutes: 30
    needs: check-changes
    if: github.repository == 'NVIDIA/tilus' && needs.check-changes.outputs.should_run_examples == 'true'
    runs-on: linux-amd64-gpu-l4-latest-1
    container:
      image: nvidia/cuda:13.0.0-devel-ubuntu22.04
      options: --gpus all
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
 
      - name: Setup and Install Tilus
        id: setup-and-install
        uses: ./.github/actions/setup-environment
        with:
          python-version: '3.10'
 
 
      - name: Run unit tests
        run: pytest tests/examples/ -v
 
  all-functional-tests:
    timeout-minutes: 30
    name: All Functional Tests
    needs: [test-python-compat, test-core, test-examples]
    if: always() && github.repository == 'NVIDIA/tilus'
    runs-on: latchkey-small
    steps:
      - name: Check job results
        run: |
          echo "Python compat result: ${{ needs.test-python-compat.result }}"
          echo "Core tests result: ${{ needs.test-core.result }}"
          echo "Example tests result: ${{ needs.test-examples.result }}"
 
          # Check if any required job failed
          if [[ "${{ needs.test-python-compat.result }}" == "failure" ]] || [[ "${{ needs.test-core.result }}" == "failure" ]] || [[ "${{ needs.test-examples.result }}" == "failure" ]]; then
            echo "One or more functional tests failed"
            exit 1
          elif [[ "${{ needs.test-python-compat.result }}" == "cancelled" ]] || [[ "${{ needs.test-core.result }}" == "cancelled" ]] || [[ "${{ needs.test-examples.result }}" == "cancelled" ]]; then
            echo "One or more functional tests were cancelled"
            exit 1
          else
            echo "All functional tests passed or were skipped"
          fi
 

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

Actions used in this workflow