Skip to content
Latchkey

Test code workflow (gdsfactory/gdsfactory)

The Test code workflow from gdsfactory/gdsfactory, 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: gdsfactory/gdsfactory.github/workflows/test_code.ymlLicense MITView source

What it does

This is the Test code workflow from the gdsfactory/gdsfactory 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: Test code
on:
  workflow_dispatch:
  pull_request:
  push:
      branches:
        - main
permissions:
  contents: read
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v7.0.0
    - uses: actions/setup-python@v6
    - uses: pre-commit/action@v3.0.1

  test_code:
    runs-on: ${{ matrix.os }}
    strategy:
      max-parallel: 12
      matrix:
        python-version: ["3.11", "3.13"]
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v7.0.0
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          make install test-data
      - name: Test with pytest
        run: |
          make test

  test_code_coverage:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      code-quality: write
    steps:
      - uses: actions/checkout@v7.0.0
        with:
          ref: ${{ github.event.pull_request.head.sha || github.sha }}
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "3.11"
      - name: Install uv
        uses: astral-sh/setup-uv@v7
      - name: Install dependencies
        run: |
          make install test-data
      - name: Test with pytest
        run: |
          make cov
      - name: Upload coverage to GitHub
        if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
        uses: actions/upload-code-coverage@v1
        with:
          file: coverage.xml
          language: Python
          label: code-coverage/pytest
          fail-on-error: false
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v7
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          fail_ci_if_error: false

  test_samples:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7.0.0
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "3.11"
      - name: Install uv
        uses: astral-sh/setup-uv@v7
      - name: Install dependencies
        run: |
          make install test-data
      - name: Test with pytest
        run: |
          make test-samples

  type_consistency:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7.0.0
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.11"
      - run: make install
      - run: uv run mypy gdsfactory/

  run-ty:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        python-version:
          - "3.11"
          - "3.13"
        os: [ubuntu-latest]
    steps:
      - uses: actions/checkout@v7.0.0
      - uses: astral-sh/setup-uv@v7
      - name: Run ty check
        run: uv run --extra dev ty check gdsfactory || true

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: Test code
on:
  workflow_dispatch:
  pull_request:
  push:
      branches:
        - main
permissions:
  contents: read
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pre-commit:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
    - uses: actions/checkout@v7.0.0
    - uses: actions/setup-python@v6
      with:
        cache: 'pip'
    - uses: pre-commit/action@v3.0.1
 
  test_code:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    strategy:
      max-parallel: 12
      matrix:
        python-version: ["3.11", "3.13"]
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v7.0.0
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          make install test-data
      - name: Test with pytest
        run: |
          make test
 
  test_code_coverage:
    timeout-minutes: 30
    runs-on: latchkey-small
    permissions:
      contents: read
      code-quality: write
    steps:
      - uses: actions/checkout@v7.0.0
        with:
          ref: ${{ github.event.pull_request.head.sha || github.sha }}
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: "3.11"
      - name: Install uv
        uses: astral-sh/setup-uv@v7
      - name: Install dependencies
        run: |
          make install test-data
      - name: Test with pytest
        run: |
          make cov
      - name: Upload coverage to GitHub
        if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
        uses: actions/upload-code-coverage@v1
        with:
          file: coverage.xml
          language: Python
          label: code-coverage/pytest
          fail-on-error: false
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v7
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          fail_ci_if_error: false
 
  test_samples:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v7.0.0
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: "3.11"
      - name: Install uv
        uses: astral-sh/setup-uv@v7
      - name: Install dependencies
        run: |
          make install test-data
      - name: Test with pytest
        run: |
          make test-samples
 
  type_consistency:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v7.0.0
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.11"
      - run: make install
      - run: uv run mypy gdsfactory/
 
  run-ty:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        python-version:
          - "3.11"
          - "3.13"
        os: [ubuntu-latest]
    steps:
      - uses: actions/checkout@v7.0.0
      - uses: astral-sh/setup-uv@v7
      - name: Run ty check
        run: uv run --extra dev ty check gdsfactory || true
 

What changed

3 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

This workflow runs 6 jobs (12 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow