guidance-ai/guidance

12 workflows · maturity 33% · 5 patterns · GitHub ↗

Security 12.5/100

Practices

✓ Matrix✓ Permissions○ Security scan○ AI review○ Cache○ Concurrency✓ Reusable workflows

Detected patterns

Security dimensions

permissions
12.5
security scan
0
supply chain
0
secret handling
0
harden runner
0

Workflows (12)

call_cpu_tests .github/workflows/call_cpu_tests.yml
Triggers
workflow_call, workflow_dispatch
Runs on
${{ inputs.os }}
Jobs
cpu_tests
Actions
astral-sh/setup-uv, codecov/codecov-action
Commands
  • uv pip install --system -e .[llamacpp,transformers,onnxruntime-genai,test] uv pip install --system accelerate # required if using smaller quantizations
  • uv pip install --system -e .[llamacpp,transformers,test] uv pip install --system accelerate # required if using smaller quantizations
  • pytest -vv --cov=guidance --cov-report=xml --cov-report=term-missing \ --selected_model ${{ inputs.model }} \ ./tests/model_integration ./tests/model_specific
View raw YAML
name: call_cpu_tests

on:
  workflow_call:
    inputs:
      os:
        required: true
        type: string
      python-version:
        required: true
        type: string
      model:
        required: true
        type: string
      codeCovPython:
        required: true
        type: string
        default: "3.12"
    secrets:
      HF_TOKEN:
        required: false
      CODECOV_TOKEN:
        required: false
  workflow_dispatch:
    inputs:
      os:
        required: false
        type: string
        default: "Large_Linux" # can instead use "Large_Windows" or the default OSes like "macos-latest"
      python-version:
        required: false
        type: string
        default: "3.12"
      model:
        required: false
        type: string
        default: "transformers_gpt2_cpu" # also try "llamacpp_llama2_7b_cpu", etc
      codeCovPython:
        required: true
        type: string
        default: "3.12"
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string

jobs:
  cpu_tests:
    runs-on: ${{ inputs.os }}
    steps:
      - name: Checkout repo at ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      - name: Set up Python ${{ inputs.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ inputs.python-version }}
      - name: Set up uv
        uses: astral-sh/setup-uv@v7
      - name: Install guidance and dependencies
        shell: bash
        if: ${{ inputs.python-version != '3.14' }}
        run: |
          uv pip install --system -e .[llamacpp,transformers,onnxruntime-genai,test]
          uv pip install --system accelerate  # required if using smaller quantizations
      - name: Install guidance and dependencies (3.14/ONNX workaround)
        # https://github.com/microsoft/onnxruntime/issues/26547
        shell: bash
        if: ${{ inputs.python-version == '3.14' }}
        run: |
          uv pip install --system -e .[llamacpp,transformers,test]
          uv pip install --system accelerate  # required if using smaller quantizations
      - name: cpu_tests for ${{ inputs.model }}
        shell: bash
        env:
          HF_TOKEN: ${{ secrets.HF_TOKEN }}
        run: |
          pytest -vv --cov=guidance --cov-report=xml --cov-report=term-missing \
            --selected_model ${{ inputs.model }} \
            ./tests/model_integration ./tests/model_specific
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v5
        if: ${{ (inputs.codeCovPython == inputs.python-version) }}
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
call_gpu_tests .github/workflows/call_gpu_tests.yml
Triggers
workflow_call, workflow_dispatch
Runs on
${{ inputs.os }}
Jobs
gpu_tests
Actions
astral-sh/setup-uv, codecov/codecov-action
Commands
  • nvidia-smi sudo apt-get --yes update sudo apt-get --yes install cuda-toolkit-12.6 echo "/usr/local/cuda-12.6/bin" >> $GITHUB_PATH
  • uv pip install --system accelerate gpustat
  • CMAKE_ARGS="-DGGML_CUDA=on" uv pip install --system -e .[llamacpp,transformers,onnxruntime-genai,test]
  • CMAKE_ARGS="-DGGML_CUDA=on" uv pip install --system -e .[llamacpp,transformers,test]
  • python -c "import torch; assert torch.cuda.is_available()"
  • pytest -vv --cov=guidance --cov-report=xml --cov-report=term-missing \ --selected_model ${{ inputs.model }} \ ./tests/model_integration ./tests/model_specific
View raw YAML
name: call_gpu_tests

on:
  workflow_call:
    inputs:
      os:
        required: true
        type: string
      python-version:
        required: true
        type: string
      model:
        required: true
        type: string
      codeCovPython:
        required: true
        type: string
        default: "3.12"
    secrets:
      HF_TOKEN:
        required: false
      CODECOV_TOKEN:
        required: false
  workflow_dispatch:
    inputs:
      os:
        required: false
        type: string
        default: "gpu-runner"
      python-version:
        required: false
        type: string
        default: "3.12"
      model:
        required: false
        type: string
        default: "llamacpp_llama2_7b_gpu" # also try "transformers_gpt2_gpu", "transformers_phi2_gpu", etc
      codeCovPython:
        required: true
        type: string
        default: "3.12"
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string

jobs:
  gpu_tests:
    runs-on: ${{ inputs.os }}
    steps:
      - name: Checkout repo at ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      - name: Set up Python ${{ inputs.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ inputs.python-version }}
      - name: Set up uv
        uses: astral-sh/setup-uv@v7
      - name: Install NVIDIA SDK
        shell: bash
        run: |
          nvidia-smi
          sudo apt-get --yes update
          sudo apt-get --yes install cuda-toolkit-12.6
          echo "/usr/local/cuda-12.6/bin" >> $GITHUB_PATH
      - name: Install other packages
        shell: bash
        run: |
          uv pip install --system accelerate gpustat
      - name: Install guidance in ${{ inputs.os }}
        shell: bash
        if: ${{ inputs.python-version != '3.14' }}
        run: |
          CMAKE_ARGS="-DGGML_CUDA=on" uv pip install --system -e .[llamacpp,transformers,onnxruntime-genai,test]
      - name: Install guidance in ${{ inputs.os }} (3.14/ONNX workaround)
        # https://github.com/microsoft/onnxruntime/issues/26547
        shell: bash
        if: ${{ inputs.python-version == '3.14' }}
        run: |
          CMAKE_ARGS="-DGGML_CUDA=on" uv pip install --system -e .[llamacpp,transformers,test]
      - name: Check GPU available
        shell: bash
        run: |
          python -c "import torch; assert torch.cuda.is_available()"
      - name: gpu_tests for ${{ inputs.model }}
        shell: bash
        env:
          HF_TOKEN: ${{ secrets.HF_TOKEN }}
        run: |
          pytest -vv --cov=guidance --cov-report=xml --cov-report=term-missing \
            --selected_model ${{ inputs.model }} \
            ./tests/model_integration ./tests/model_specific
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v5
        if: ${{ (inputs.codeCovPython == inputs.python-version) }}
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
ci_credentials matrix perms .github/workflows/ci_credentials.yml
Triggers
push, workflow_dispatch, schedule
Runs on
ubuntu-latest
Jobs
credentialed_tests
Matrix
python-version→ 3.10, 3.11, 3.12, 3.13, 3.14
Actions
astral-sh/setup-uv, codecov/codecov-action
Commands
  • uv pip install --system -e .[all,test]
  • pytest -vv --cov=guidance --cov-report=xml --cov-report=term-missing \ ./tests/need_credentials
View raw YAML
# These access secrets, so should only be run on local branches.

name: CI Tests - Credentialed
permissions:
  contents: read


on:
  push:
    branches:
      - main
  workflow_dispatch:
    inputs:
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string
  schedule:
    # * is a special character in YAML so we quote this string
    # Run at 09:00 UTC every day
    - cron:  '00 09 * * *'

jobs:
  credentialed_tests:
    runs-on: ubuntu-latest
    environment: test
    strategy:
      fail-fast: false # Don't cancel all on first failure
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
    permissions:
      id-token: write  # for Azure CLI login
    steps:
      - name: Checkout repo at ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
      - name: Set up uv
        uses: astral-sh/setup-uv@v7
      - name: Install guidance
        run: |
          uv pip install --system -e .[all,test]
      - name: Model tests
        env:
          HF_TOKEN: ${{ secrets.HF_TOKEN }}
          # Configure OpenAI
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          # Configure environment for Azure AI Studio
          AZUREAI_STUDIO_PHI4_ENDPOINT: ${{ vars.AZUREAI_STUDIO_PHI4_ENDPOINT }}
          AZUREAI_STUDIO_PHI4_MODEL_NAME: ${{ vars.AZUREAI_STUDIO_PHI4_MODEL_NAME }}
          AZUREAI_STUDIO_PHI4_KEY: ${{ secrets.AZUREAI_STUDIO_PHI4_KEY }}
          # Do not configure the environment for Azure OpenAI, so those tests will
          # be skipped. GitHub cannot authenticate.
        run: |
          pytest -vv --cov=guidance --cov-report=xml --cov-report=term-missing \
            ./tests/need_credentials
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v5
        if: ${{ (vars.CODECOV_PYTHON == matrix.python-version) }}
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
ci_docs matrix perms .github/workflows/ci_docs.yml
Triggers
push, workflow_dispatch, schedule
Runs on
Large_Linux
Jobs
check_ReadMe
Matrix
python-version→ 3.10, 3.14
Actions
astral-sh/setup-uv
Commands
  • uv pip install --system -e .[all,test]
  • python ./scripts/extract_python_from_readme.py --input_file ./README.md --output_file ./readme.py
  • python ./readme.py
View raw YAML
# These access secrets, so should only be run on local branches.

name: CI Tests - Docs
permissions:
  contents: read


on:
  push:
    branches:
      - main
  workflow_dispatch:
    inputs:
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string
  schedule:
    # * is a special character in YAML so we quote this string
    # Run at 07:00 UTC every day
    - cron:  '00 07 * * *'

jobs:
  check_ReadMe:
    runs-on: Large_Linux
    environment: test
    strategy:
      fail-fast: false # Don't cancel all on first failure
      matrix:
        python-version: ["3.10", "3.14"]
    steps:
    - name: Checkout repo at ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      uses: actions/checkout@v6
      with:
        ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v6
      with:
        python-version: ${{ matrix.python-version }}
    - name: Set up uv
      uses: astral-sh/setup-uv@v7
    - name: Install guidance
      run: |
        uv pip install --system -e .[all,test]
    - name: Extract Python code
      run: python ./scripts/extract_python_from_readme.py --input_file ./README.md --output_file ./readme.py
    - name: Run extracted Python
      run: python ./readme.py
ci_linux matrix perms .github/workflows/ci_linux.yml
Triggers
workflow_dispatch, schedule
Runs on
Jobs
cpu_small, cpu_big, gpu_tests
Matrix
exclude, exclude.model, exclude.python-version, model, python-version→ 3.10, 3.11, 3.12, 3.13, 3.14, llamacpp_llama3.2_3b_cpu, onnxruntime_phi4_mini_instruct, transformers_gpt2_cpu, transformers_gpt2_gpu, transformers_llama3_8b_cpu, transformers_phi4_mini_cpu, transformers_phi4_mini_gpu
View raw YAML
# CI Tests which run on Linux machines

# These access secrets, so should only be run on local branches.

# Ideally, the CI tests would be a single workflow, but several issues
# (especially varied OS support) mean that it is hard to keep a single
# workflow green.

name: CI Tests - Linux
permissions:
  contents: read

on:
  workflow_dispatch:
    inputs:
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string
  schedule:
    # * is a special character in YAML so we quote this string
    # Run at 09:30 UTC every day
    - cron:  '30 09 * * *'


jobs:
  cpu_small:
    strategy:
      fail-fast: false # Don't cancel all on first failure
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
        model:
          - "transformers_gpt2_cpu"
          - "llamacpp_llama3.2_3b_cpu"
    uses: ./.github/workflows/call_cpu_tests.yml
    with:
      os: Large_Linux
      python-version: ${{ matrix.python-version }}
      model: ${{ matrix.model }}
      codeCovPython: ${{ vars.CODECOV_PYTHON }}
    secrets:
      HF_TOKEN: ${{ secrets.HF_TOKEN }}
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

  cpu_big:
    strategy:
      fail-fast: false # Don't cancel all on first failure
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
        model:
          - "transformers_llama3_8b_cpu"
          - "transformers_phi4_mini_cpu"
          - "onnxruntime_phi4_mini_instruct"
        exclude:
          - model: "onnxruntime_phi4_mini_instruct"
            python-version: "3.14"  # Waiting for ONNX update
    uses: ./.github/workflows/call_cpu_tests.yml
    with:
      os: Large_Linux
      python-version: ${{ matrix.python-version }}
      model: ${{ matrix.model }}
      codeCovPython: ${{ vars.CODECOV_PYTHON }}
    secrets:
      HF_TOKEN: ${{ secrets.HF_TOKEN }}
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

  gpu_tests:
    strategy:
      fail-fast: false # Don't cancel all on first failure
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
        model:
          - "transformers_gpt2_gpu"
          - "transformers_phi4_mini_gpu"
          - "onnxruntime_phi4_mini_instruct"
        exclude:
          # https://github.com/microsoft/onnxruntime/issues/26547
          - model: "onnxruntime_phi4_mini_instruct"
            python-version: "3.14"  # Waiting for ONNX update
    uses: ./.github/workflows/call_gpu_tests.yml
    with:
      os: "gpu-runner"
      python-version: ${{ matrix.python-version }}
      model: ${{ matrix.model }}
      codeCovPython: ${{ vars.CODECOV_PYTHON }}
    secrets:
      HF_TOKEN: ${{ secrets.HF_TOKEN }}
      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
ci_macos matrix perms .github/workflows/ci_macos.yml
Triggers
workflow_dispatch, schedule
Runs on
Jobs
cpu_small
Matrix
model, python-version→ 3.10, 3.11, 3.12, 3.13, llamacpp_llama3.2_3b_cpu, transformers_gpt2_cpu
View raw YAML
# CI Tests which run on MacOS machines

# These access secrets, so should only be run on local branches.

# Ideally, the CI tests would be a single workflow, but several issues
# (especially varied OS support) mean that it is hard to keep a single
# workflow green.

# MacOS has been a particular trouble due to the small disk space
# allocations on all the VMs, leading to the --selected_model
# machinery

name: CI Tests - MacOS
permissions:
  contents: read

on:
  workflow_dispatch:
    inputs:
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string
  schedule:
    # * is a special character in YAML so we quote this string
    # Run at 09:10 UTC every day
    - cron:  '10 09 * * *'

jobs:
  cpu_small:
    strategy:
      fail-fast: false # Don't cancel all on first failure
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13"]
        model:
          - "transformers_gpt2_cpu"
          - "llamacpp_llama3.2_3b_cpu"
    uses: ./.github/workflows/call_cpu_tests.yml
    with:
      os: "macos-latest"
      python-version: ${{ matrix.python-version }}
      model: ${{ matrix.model }}
      codeCovPython: ${{ vars.CODECOV_PYTHON }}
    secrets:
      HF_TOKEN: ${{ secrets.HF_TOKEN }}
ci_windows matrix perms .github/workflows/ci_windows.yml
Triggers
workflow_dispatch, schedule
Runs on
Jobs
cpu_small, cpu_big
Matrix
exclude, exclude.model, exclude.python-version, model, python-version→ 3.10, 3.11, 3.12, 3.13, 3.14, llamacpp_llama3.2_3b_cpu, onnxruntime_phi4_mini_instruct, transformers_gpt2_cpu, transformers_llama3_8b_cpu, transformers_phi4_mini_cpu
View raw YAML
# CI Tests which run on Windows machines

# These access secrets, so should only be run on local branches.

# Ideally, the CI tests would be a single workflow, but several issues
# (especially varied OS support) mean that it is hard to keep a single
# workflow green. If there is one OS likely to lag slightly in support
# it is Windows

name: CI Tests - Windows
permissions:
  contents: read

on:
  workflow_dispatch:
    inputs:
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string
  schedule:
    # * is a special character in YAML so we quote this string
    # Run at 09:30 UTC every day
    - cron:  '30 09 * * *'

jobs:
  cpu_small:
    strategy:
      fail-fast: false # Don't cancel all on first failure
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
        model:
          - "transformers_gpt2_cpu"
          - "llamacpp_llama3.2_3b_cpu"
    uses: ./.github/workflows/call_cpu_tests.yml
    with:
      os: "Large_Windows"
      python-version: ${{ matrix.python-version }}
      model: ${{ matrix.model }}
      codeCovPython: ${{ vars.CODECOV_PYTHON }}
    secrets:
      HF_TOKEN: ${{ secrets.HF_TOKEN }}

  cpu_big:
    strategy:
      fail-fast: false # Don't cancel all on first failure
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
        model:
          - "transformers_llama3_8b_cpu"
          - "transformers_phi4_mini_cpu"
          - "onnxruntime_phi4_mini_instruct"
        exclude:
          # https://github.com/microsoft/onnxruntime/issues/26547
          - model: "onnxruntime_phi4_mini_instruct"
            python-version: "3.14"  # Waiting for ONNX update
    uses: ./.github/workflows/call_cpu_tests.yml
    with:
      os: "Large_Windows"
      python-version: ${{ matrix.python-version }}
      model: ${{ matrix.model }}
      codeCovPython: ${{ vars.CODECOV_PYTHON }}
    secrets:
      HF_TOKEN: ${{ secrets.HF_TOKEN }}
code_quality .github/workflows/code_quality.yml
Triggers
pull_request, workflow_dispatch, schedule
Runs on
ubuntu-latest, ubuntu-latest, ubuntu-latest
Jobs
format_ruff, ruff-linting, run-mypy
Actions
astral-sh/setup-uv, astral-sh/setup-uv, astral-sh/setup-uv
Commands
  • uv pip install --system -e .[dev]
  • if ! ruff format --check; then echo "::warning title=ruff format::Files need re-formatting (run 'ruff format .' locally)" exit 78 # no longer works in github, but would mark action step with a warning fi
  • # This is separate from formatting. See: # https://docs.astral.sh/ruff/formatter/#sorting-imports if ! ruff check --select I,RUF022; then echo "::warning title=ruff import::Files need import sorting (run 'ruff check --select I,RUF022 --fix' locally to auto-fix)" exit 78 # no longer works in github, but would mark action step with a warning fi
  • uv pip install --system -e .[dev]
  • ruff check
  • uv pip install --system -e .[all,dev]
  • mypy --install-types --non-interactive guidance
  • mypy guidance echo "===========================================" echo "Done"
View raw YAML
name: Code Quality

env:
  PYTHON_VERSION: "3.12"

on:
  pull_request:
  workflow_dispatch:
    inputs:
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string
  schedule:
    # Run at 10:00 UTC every day
    - cron: "00 10 * * *"


jobs:
  format_ruff:
    name: Check format with ruff
    runs-on: ubuntu-latest
    permissions:
      checks: write
    steps:
      - name: Check out repo ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: Set up uv
        uses: astral-sh/setup-uv@v7
      - name: Do dev install
        run: uv pip install --system -e .[dev]
      - name: Check format with ruff
        shell: bash
        id: check_format
        continue-on-error: true
        run: |
          if ! ruff format --check; then
            echo "::warning title=ruff format::Files need re-formatting (run 'ruff format .' locally)"
            exit 78  # no longer works in github, but would mark action step with a warning
          fi
      - name: Check imports with ruff
        shell: bash
        id: check_import
        continue-on-error: true
        run: |
          # This is separate from formatting. See:
          # https://docs.astral.sh/ruff/formatter/#sorting-imports
          if ! ruff check --select I,RUF022; then
            echo "::warning title=ruff import::Files need import sorting (run 'ruff check --select I,RUF022 --fix' locally to auto-fix)"
            exit 78  # no longer works in github, but would mark action step with a warning
          fi
      - name: Mark step with a warning
        if: ${{ steps.check_format.outcome == 'failure' || steps.check_import.outcome == 'failure' }} 
        uses: actions/github-script@v8
        with:
          script: |
            await github.rest.checks.create({
              owner: context.repo.owner,
              repo: context.repo.repo,
              name: 'Failed ruff checks',
              head_sha: context.sha,
              status: 'completed',
              conclusion: 'neutral',
              completed_at: new Date().toISOString(),
              output: {
                title: 'ruff found violations',
                summary: 'Run `ruff format . and `ruff check --select I,RUF022 --fix` locally and push the changes.'
              }
            })

  # Have a separate workflow because we don't want to enforce this at all
  # It will have too many errors initially and is likely to deter contributors
  ruff-linting:
    name: Linting with ruff
    runs-on: ubuntu-latest
    permissions:
      checks: read
    steps:
      - name: Check out repo ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: Set up uv
        uses: astral-sh/setup-uv@v7
      - name: Do dev install
        run: uv pip install --system -e .[dev]
      - name: Run ruff linting
        shell: bash
        continue-on-error: true
        run: |
          ruff check


  run-mypy:
    name: Run informational mypy
    runs-on: ubuntu-latest
    permissions:
      checks: read
    steps:
      - name: Check out repo ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: Set up uv
        uses: astral-sh/setup-uv@v7
      - name: Do guidance install
        run: uv pip install --system -e .[all,dev]
      - name: Get mypy type packages
        continue-on-error: true
        run: mypy --install-types --non-interactive guidance
      - name: Run mypy
        shell: bash
        continue-on-error: true
        run: |
          mypy guidance

          echo "==========================================="
          echo "Done"
notebook_tests matrix .github/workflows/notebook_tests.yml
Triggers
push, workflow_dispatch, schedule
Runs on
Large_Linux
Jobs
notebook_tests
Matrix
python-version→ 3.10, 3.11, 3.12, 3.13, 3.14
Actions
astral-sh/setup-uv, codecov/codecov-action
Commands
  • uv pip install --system -e .[all,llamacpp,test]
  • uv pip install --system gpustat
  • # Run the non-AOAI notebooks pytest -vv --cov=guidance --cov-report=xml --cov-report=term-missing --cov-append \ ./tests/notebooks/test_notebooks.py
View raw YAML
# These access secrets, so should only be run on local branches.

# Not part of the regular CI run, since notebook tests seem
# particularly flaky

name: CI Tests - Notebook

on:
  push:
    branches:
      - main
  workflow_dispatch:
    inputs:
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string
  schedule:
    # * is a special character in YAML so we quote this string
    # Run at 10:00 UTC every day
    - cron:  '00 10 * * *'

jobs:
  notebook_tests:
    runs-on: "Large_Linux"
    environment: test
    strategy:
      fail-fast: false # Don't cancel all on first failure
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
    permissions:
      id-token: write  # for Azure CLI login
    steps:
      - name: Checkout repo at ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
      - name: Set up uv
        uses: astral-sh/setup-uv@v7
      - name: Install guidance
        shell: bash
        run: |
          uv pip install --system -e .[all,llamacpp,test]
      - name: Install gpustat
        shell: bash
        run: |
          uv pip install --system gpustat
      - name: Notebook tests
        shell: bash
        env:
          HF_TOKEN: ${{ secrets.HF_TOKEN }}
          # Configure OpenAI
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: |
          # Run the non-AOAI notebooks
          pytest -vv --cov=guidance --cov-report=xml --cov-report=term-missing --cov-append \
            ./tests/notebooks/test_notebooks.py
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v5
        if: ${{ (vars.CODECOV_PYTHON == matrix.python-version) }}
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
pull_request matrix .github/workflows/pull_request.yml
Triggers
pull_request, workflow_dispatch, schedule
Runs on
${{ matrix.os }}
Jobs
unit_tests, cpu_tests
Matrix
model, os, python-version→ 3.10, 3.11, 3.12, 3.13, 3.14, Large_Linux, macos-latest, transformers_gpt2_cpu, ubuntu-latest, windows-latest
Actions
astral-sh/setup-uv, codecov/codecov-action
Commands
  • uv pip install --system -e .
  • python -c "import guidance"
  • uv pip install --system -e .[test-unit]
  • pytest -vv --cov=guidance --cov-report=xml --cov-report=term-missing \ ./tests/unit
View raw YAML
name: Pull Request

on:
  pull_request:
  workflow_dispatch:
    inputs:
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string
  schedule:
    # Run at 09:00 UTC every day
    - cron: "00 09 * * *"

jobs:
  unit_tests:
    strategy:
      fail-fast: false # Don't cancel all on first failure
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout repo at ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
      - name: Set up uv
        uses: astral-sh/setup-uv@v7
      - name: Minimal install
        run: |
          uv pip install --system -e .
      - name: Attempt import
        run: |
          python -c "import guidance"
      - name: Bigger install
        run: |
          uv pip install --system -e .[test-unit]
      - name: Unit Tests
        shell: bash
        run: |
          pytest -vv --cov=guidance --cov-report=xml --cov-report=term-missing \
            ./tests/unit
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v5
        if: ${{ (vars.CODECOV_PYTHON == matrix.python-version) }}
        with:
          token: ${{ secrets.CODECOV_TOKEN }}

  cpu_tests:
    strategy:
      fail-fast: false # Don't cancel all on first failure
      matrix:
        os: ["Large_Linux"]  # , "Large_Windows"]
        python-version: ["3.10", "3.14"]
        model:
          - "transformers_gpt2_cpu"
    uses: ./.github/workflows/call_cpu_tests.yml
    with:
      os: ${{ matrix.os }}
      python-version: ${{ matrix.python-version }}
      model: ${{ matrix.model }}
      codeCovPython: ${{ vars.CODECOV_PYTHON }}

  # gpu_tests:
  #   strategy:
  #     fail-fast: false # Don't cancel all on first failure
  #     matrix:
  #       os: ["gpu-runner"]
  #       python-version: ["3.10", "3.13"]
  #       model:
  #         - "transformers_gpt2_gpu"
  #         - "llamacpp_llama2_7b_gpu"
  #   uses: ./.github/workflows/call_gpu_tests.yml
  #   with:
  #     os: ${{ matrix.os }}
  #     python-version: ${{ matrix.python-version }}
  #     model: ${{ matrix.model }}
pypi_upload matrix .github/workflows/pypi_upload.yml
Triggers
release, workflow_dispatch
Runs on
ubuntu-latest, ubuntu-latest, ubuntu-latest, ${{ matrix.os }}, ubuntu-latest
Jobs
build_wheels, build_sdist, assemble_wheels, test_wheels, publish_wheels
Matrix
os, python-version→ 3.11, 3.12, macos-14, macos-latest, ubuntu-latest, windows-latest
Actions
astral-sh/setup-uv, astral-sh/setup-uv, astral-sh/setup-uv, pypa/gh-action-pypi-publish
Commands
  • uv build --wheel
  • uv build --sdist
  • uv pip install --system guidance -f ./wheelhouse/
  • uv pip install --system transformers torch
View raw YAML
name: Build wheels

on:
  release:
    types: [published]
  workflow_dispatch:  # Enable manual run
    inputs:
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string

jobs:
  build_wheels:
    name: Build wheel distribution
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo at ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      - name: Set up Python 3.11
        uses: actions/setup-python@v6
        with:
          python-version: '3.11'
      - name: Set up uv
        uses: astral-sh/setup-uv@v7

      - name: Build bdist
        run: |
          uv build --wheel

      - name: Upload bdist
        uses: actions/upload-artifact@v7
        with:
          name: bdist_files
          path: dist/*.whl

  build_sdist:
    name: Build source distribution
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo at ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      - name: Set up Python 3.11
        uses: actions/setup-python@v6
        with:
          python-version: '3.11'
      - name: Set up uv
        uses: astral-sh/setup-uv@v7

      - name: Build sdist (pep517)
        run: |
          uv build --sdist

      - name: Upload sdist
        uses: actions/upload-artifact@v7
        with:
          name: sdist_files
          path: dist/*.tar.gz


  assemble_wheels:
    name: Combine wheels
    needs: [build_wheels, build_sdist]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v8
        with:
          name: sdist_files
          path: dist
      
      - uses: actions/download-artifact@v8
        with:
          name: bdist_files
          path: dist

      - uses: actions/upload-artifact@v7
        with:
          path: ./dist/*
          name: collected_dist_files

  test_wheels:
    name: Test Wheels
    needs: [assemble_wheels]
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-14, macos-latest]
        python-version: ["3.11", "3.12"]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/download-artifact@v8
        with:
          name: collected_dist_files
          path: wheelhouse
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
      - name: Set up uv
        uses: astral-sh/setup-uv@v7
      - run: uv pip install --system guidance -f ./wheelhouse/
        name: Install guidance from wheels
      - run: uv pip install --system transformers torch
        name: Other installs
      # - run: python -c "import guidance; import transformers; lm = guidance.models.Transformers('gpt2'); lm += '1,2,3,4,5,' + guidance.gen('num', max_tokens=5, temperature=0); print(f'\n Transformers Version:{transformers.__version__}\n\n{str(lm)=}\n'); assert lm['num'].startswith('6')"
      #   name: Run smoke test

  publish_wheels:
    permissions:
      id-token: write
    name: Publish wheels on pypi
    needs: [test_wheels]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v8
        with:
          name: collected_dist_files
          path: dist

      - name: Publish package to PyPI
        uses: pypa/gh-action-pypi-publish@v1
        if: startsWith(github.ref, 'refs/tags')
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}
widget_build perms .github/workflows/widget_build.yml
Triggers
pull_request, workflow_dispatch, schedule
Runs on
ubuntu-latest
Jobs
build_widget
Commands
  • npm install
  • ./build-to-guidance.sh
View raw YAML
name: Widget Build
permissions:
  contents: read

on:
  pull_request:
  workflow_dispatch:
    inputs:
      commit_id:
        description: 'Branch or Commit ID (optional)'
        required: false
        type: string
  schedule:
    # Run at 10:00 UTC every day
    - cron: "00 10 * * *"

jobs:
  build_widget:
    defaults:
      run:
        shell: bash
        working-directory: ./client/graphpaper-inline
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo at ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
        uses: actions/checkout@v6
        with:
          ref: ${{ github.event_name == 'workflow_dispatch' && inputs.commit_id || github.sha }}
      - uses: actions/setup-node@v6
        with:
          node-version: 18
      - name: Install dependencies
        run: |
          npm install
      - name: Build
        run: |
          ./build-to-guidance.sh