Skip to main content
EVOKORE// WORKFLOWS / tests.yml
openai/openai-agents-pythonworkflow · 132 lines

.github/workflows/tests.yml

CI / automation

View on GitHub →
name: Tests

on:
  push:
    branches:
      - main
  pull_request:
    # All PRs, including stacked PRs

permissions:
  contents: read

env:
  UV_FROZEN: "1"

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
      - name: Detect code changes
        id: changes
        run: ./.github/scripts/detect-changes.sh code "${{ github.event.pull_request.base.sha || github.event.before }}" "${{ github.sha }}"
      - name: Setup uv
        if: steps.changes.outputs.run == 'true'
        uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098
        with:
          enable-cache: true
      - name: Install dependencies
        if: steps.changes.outputs.run == 'true'
        run: make sync
      - name: Verify formatting
        if: steps.changes.outputs.run == 'true'
        run: make format-check
      - name: Run lint
        if: steps.changes.outputs.run == 'true'
        run: make lint
      - name: Skip lint
        if: steps.changes.outputs.run != 'true'
        run: echo "Skipping lint for non-code changes."

  typecheck:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
      - name: Detect code changes
        id: changes
        run: ./.github/scripts/detect-changes.sh code "${{ github.event.pull_request.base.sha || github.event.before }}" "${{ github.sha }}"
      - name: Setup uv
        if: steps.changes.outputs.run == 'true'
        uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098
        with:
          enable-cache: true
      - name: Install dependencies
        if: steps.changes.outputs.run == 'true'
        run: make sync
      - name: Run typecheck
        if: steps.changes.outputs.run == 'true'
        run: make typecheck
      - name: Skip typecheck
        if: steps.changes.outputs.run != 'true'
        run: echo "Skipping typecheck for non-code changes."

  tests:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version:
          - "3.10"
          - "3.11"
          - "3.12"
          - "3.13"
          - "3.14"
    env:
      OPENAI_API_KEY: <YOUR_API_KEY>  # Replace with your key for real tests
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
      - name: Detect code changes
        id: changes
        run: ./.github/scripts/detect-changes.sh code "${{ github.event.pull_request.base.sha || github.event.before }}" "${{ github.sha }}"
      - name: Setup uv
        if: steps.changes.outputs.run == 'true'
        uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098
        with:
          enable-cache: true
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        if: steps.changes.outputs.run == 'true'
        run: make sync
      - name: Run tests with coverage
        if: steps.changes.outputs.run == 'true' && matrix.python-version == '3.12'
        run: make coverage
      - name: Run tests
        if: steps.changes.outputs.run == 'true' && matrix.python-version != '3.12'
        run: make tests
      - name: Run async teardown stability tests
        if: steps.changes.outputs.run == 'true' && (matrix.python-version == '3.10' || matrix.python-version == '3.14')
        run: make tests-asyncio-stability
      - name: Skip tests
        if: steps.changes.outputs.run != 'true'
        run: echo "Skipping tests for non-code changes."

  build-docs:
    runs-on: ubuntu-latest
    env:
      OPENAI_API_KEY: <YOUR_API_KEY>  # Replace with your key for real tests
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
      - name: Detect docs changes
        id: changes
        run: ./.github/scripts/detect-changes.sh docs "${{ github.event.pull_request.base.sha || github.event.before }}" "${{ github.sha }}"
      - name: Setup uv
        if: steps.changes.outputs.run == 'true'
        uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098
        with:
          enable-cache: true
      - name: Install dependencies
        if: steps.changes.outputs.run == 'true'
        run: make sync
      - name: Build docs
        if: steps.changes.outputs.run == 'true'
        run: make build-docs
      - name: Skip docs build
        if: steps.changes.outputs.run != 'true'
        run: echo "Skipping docs build for non-docs changes."