Skip to content
Latchkey

CI workflow (browserbase/stagehand-python)

The CI workflow from browserbase/stagehand-python, explained and optimized by Latchkey.

A

CI health: A - excellent

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: browserbase/stagehand-python.github/workflows/ci.ymlLicense MITView source

What it does

This is the CI workflow from the browserbase/stagehand-python 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: CI
on:
  push:
    branches:
      - '**'
      - '!integrated/**'
      - '!stl-preview-head/**'
      - '!stl-preview-base/**'
      - '!generated'
      - '!codegen/**'
      - 'codegen/stl/**'
  pull_request:
    branches-ignore:
      - 'stl-preview-head/**'
      - 'stl-preview-base/**'

jobs:
  lint:
    timeout-minutes: 10
    name: lint
    runs-on: ${{ github.repository == 'stainless-sdks/stagehand-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
    if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Install uv
        uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
        with:
          version: '0.10.2'

      - name: Install dependencies
        run: uv sync --all-extras

      - name: Run lints
        run: ./scripts/lint

  build:
    if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
    timeout-minutes: 10
    name: build
    permissions:
      contents: read
      id-token: write
    runs-on: ${{ github.repository == 'stainless-sdks/stagehand-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Install uv
        uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
        with:
          version: '0.10.2'

      - name: Install dependencies
        run: uv sync --all-extras

      - name: Run build
        run: uv build

      - name: Get GitHub OIDC Token
        if: |-
          github.repository == 'stainless-sdks/stagehand-python' &&
          !startsWith(github.ref, 'refs/heads/stl/')
        id: github-oidc
        uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
        with:
          script: core.setOutput('github_token', await core.getIDToken());

      - name: Upload tarball
        if: |-
          github.repository == 'stainless-sdks/stagehand-python' &&
          !startsWith(github.ref, 'refs/heads/stl/')
        env:
          URL: https://pkg.stainless.com/s
          AUTH: ${{ steps.github-oidc.outputs.github_token }}
          SHA: ${{ github.sha }}
        run: ./scripts/utils/upload-artifact.sh

  test:
    timeout-minutes: 10
    name: test
    runs-on: ${{ github.repository == 'stainless-sdks/stagehand-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
    if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Install uv
        uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
        with:
          version: '0.10.2'

      - name: Bootstrap
        run: ./scripts/bootstrap

      - name: Run tests
        run: ./scripts/test

The same workflow, on Latchkey

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

name: CI
on:
  push:
    branches:
      - '**'
      - '!integrated/**'
      - '!stl-preview-head/**'
      - '!stl-preview-base/**'
      - '!generated'
      - '!codegen/**'
      - 'codegen/stl/**'
  pull_request:
    branches-ignore:
      - 'stl-preview-head/**'
      - 'stl-preview-base/**'
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  lint:
    timeout-minutes: 10
    name: lint
    runs-on: ${{ github.repository == 'stainless-sdks/stagehand-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
    if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
 
      - name: Install uv
        uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
        with:
          version: '0.10.2'
 
      - name: Install dependencies
        run: uv sync --all-extras
 
      - name: Run lints
        run: ./scripts/lint
 
  build:
    if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
    timeout-minutes: 10
    name: build
    permissions:
      contents: read
      id-token: write
    runs-on: ${{ github.repository == 'stainless-sdks/stagehand-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
 
      - name: Install uv
        uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
        with:
          version: '0.10.2'
 
      - name: Install dependencies
        run: uv sync --all-extras
 
      - name: Run build
        run: uv build
 
      - name: Get GitHub OIDC Token
        if: |-
          github.repository == 'stainless-sdks/stagehand-python' &&
          !startsWith(github.ref, 'refs/heads/stl/')
        id: github-oidc
        uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
        with:
          script: core.setOutput('github_token', await core.getIDToken());
 
      - name: Upload tarball
        if: |-
          github.repository == 'stainless-sdks/stagehand-python' &&
          !startsWith(github.ref, 'refs/heads/stl/')
        env:
          URL: https://pkg.stainless.com/s
          AUTH: ${{ steps.github-oidc.outputs.github_token }}
          SHA: ${{ github.sha }}
        run: ./scripts/utils/upload-artifact.sh
 
  test:
    timeout-minutes: 10
    name: test
    runs-on: ${{ github.repository == 'stainless-sdks/stagehand-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
    if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
 
      - name: Install uv
        uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
        with:
          version: '0.10.2'
 
      - name: Bootstrap
        run: ./scripts/bootstrap
 
      - name: Run tests
        run: ./scripts/test
 

What changed

This workflow runs 3 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