dottxt-ai/outlines

5 workflows · maturity 50% · 4 patterns · GitHub ↗

Security 10/100

Practices

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

Detected patterns

Security dimensions

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

Workflows (5)

build_documentation perms .github/workflows/build_documentation.yml
Triggers
pull_request, workflow_dispatch
Runs on
ubuntu-latest
Jobs
build
Actions
rossjrw/pr-preview-action
Commands
  • pip install -r requirements-doc.txt
  • sed -i "1i site_url: https://dottxt-ai.github.io/outlines/pr-preview/pr-${PR_NUMBER}/" mkdocs.yml mkdocs build
View raw YAML
name: Build the documentation

on:
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches: [main]
  workflow_dispatch:

permissions:
  contents: write
  pull-requests: write

jobs:
  build:
    name: Build and Deploy Documentation Preview
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v4
        with:
          python-version: "3.10"

      - name: Install dependencies
        if: github.event.action != 'closed'
        run: pip install -r requirements-doc.txt

      - name: Build the documentation
        if: github.event.action != 'closed'
        env:
          GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
          PR_NUMBER: ${{ github.event.pull_request.number }}
        run: |
          sed -i "1i site_url: https://dottxt-ai.github.io/outlines/pr-preview/pr-${PR_NUMBER}/" mkdocs.yml
          mkdocs build

      - name: Deploy to PR preview
        if: github.event_name == 'pull_request'
        uses: rossjrw/pr-preview-action@v1
        with:
          source-dir: site/
          preview-branch: gh-pages
          umbrella-dir: pr-preview
          comment: false
          token: ${{ secrets.DEPLOY_TOKEN }}

      - name: Comment PR with preview link
        if: github.event_name == 'pull_request' && github.event.action != 'closed'
        uses: actions/github-script@v7
        with:
          script: |
            const prNumber = context.issue.number;
            const previewUrl = `https://dottxt-ai.github.io/outlines/pr-preview/pr-${prNumber}/`;

            // Find existing preview comment
            const comments = await github.rest.issues.listComments({
              issue_number: prNumber,
              owner: context.repo.owner,
              repo: context.repo.repo,
            });

            const botComment = comments.data.find(comment =>
              comment.user.type === 'Bot' &&
              comment.body.includes('Documentation preview')
            );

            const commentBody = `📚 **Documentation preview**: ${previewUrl}\n\n*Preview updates automatically with each commit.*`;

            // Update existing comment or create new one
            if (botComment) {
              await github.rest.issues.updateComment({
                comment_id: botComment.id,
                owner: context.repo.owner,
                repo: context.repo.repo,
                body: commentBody
              });
            } else {
              await github.rest.issues.createComment({
                issue_number: prNumber,
                owner: context.repo.owner,
                repo: context.repo.repo,
                body: commentBody
              });
            }
publish_documentation perms .github/workflows/publish_documentation.yml
Triggers
workflow_dispatch, push, release
Runs on
ubuntu-latest
Jobs
deploy
Commands
  • echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
  • pip install -r requirements-doc.txt
  • mkdocs build
  • git config user.name ${{ github.actor }} git config user.email ${{ github.actor }}@users.noreply.github.com
  • mike deploy --push --update-aliases ${{ github.ref_name }} latest mike set-default --push latest
  • mike deploy --push --update-aliases ${{ github.ref_name }} unstable
View raw YAML
name: Publish the documentation

on:
  workflow_dispatch:
  push:
    branches:
      - main
  release:
    types:
      - created

permissions:
  contents: write

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-python@v4
        with:
          python-version: 3.x
      - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
      - uses: actions/cache@v3
        with:
          key: mkdocs-material-${{ env.cache_id }}
          path: .cache
          restore-keys: |
            mkdocs-material-
      - run: pip install -r requirements-doc.txt
      - run: mkdocs build

      - name: Set up Git
        run: |
          git config user.name ${{ github.actor }}
          git config user.email ${{ github.actor }}@users.noreply.github.com

      - name: Publish Tag as latest
        env:
          GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
        if: github.event_name == 'release'
        run: |
          mike deploy --push --update-aliases ${{ github.ref_name }} latest
          mike set-default --push latest

      - name: Publish main as unstable
        env:
          GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
        if: github.event_name == 'push'
        run: |
          mike deploy --push --update-aliases ${{ github.ref_name }} unstable
release_pypi .github/workflows/release_pypi.yaml
Triggers
release
Runs on
ubuntu-latest
Jobs
release-job
Actions
pypa/gh-action-pypi-publish
Commands
  • ./.github/scripts/build_sdist_and_wheel.sh
  • grep -Rq "^Version: ${GITHUB_REF:10}$" outlines.egg-info/PKG-INFO
View raw YAML
name: Release PyPi

on:
  release:
    types:
      - created
jobs:
  release-job:
    name: Build and publish on PyPi
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: "3.10"
    - name: Build SDist and Wheel
      run: ./.github/scripts/build_sdist_and_wheel.sh
    - name: Check that the package version matches the Release name
      run: |
        grep -Rq "^Version: ${GITHUB_REF:10}$" outlines.egg-info/PKG-INFO
    - name: Publish to PyPi
      uses: pypa/gh-action-pypi-publish@v1.4.2
      with:
        user: __token__
        password: ${{ secrets.PYPI_TOKEN }}
tests matrix .github/workflows/tests.yml
Triggers
pull_request, push
Runs on
ubuntu-latest, ubuntu-latest, ubuntu-latest, ubuntu-latest
Jobs
style, tests, coverage, build-wheel
Matrix
python-version→ 3.10, 3.13
Actions
pre-commit/action
Commands
  • set -eux sudo rm -rf /usr/share/dotnet || true sudo rm -rf /opt/ghc || true sudo rm -rf /usr/local/lib/android || true sudo apt-get clean df -h
  • curl -fsSL https://ollama.com/install.sh | sh ollama --version ollama pull tinyllama
  • python -m pip install --upgrade pip pip install uv uv sync --no-group test-gpu --extra test
  • echo $MATRIX_CONTEXT export MATRIX_ID=`echo $MATRIX_CONTEXT | md5sum | cut -c 1-32` echo $MATRIX_ID echo "::set-output name=id::$MATRIX_ID"
  • rm -f .coverage* uv run coverage erase uv run python -m coverage run --branch --source=outlines --parallel-mode -m pytest -x -m 'not api_call'
  • pip install --upgrade "coverage[toml]>=5.1" diff-cover
  • python -m coverage combine python -m coverage html --skip-covered --skip-empty python -m coverage xml python -m coverage report --fail-under=100 || (python -m coverage report && exit 1)
  • ./.github/scripts/build_sdist_and_wheel.sh
View raw YAML
name: Tests

on:
  pull_request:
    branches: [main,v1.0]
  push:
    branches: [main]

jobs:
  style:
    name: Check the code style
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-python@v4
      with:
        python-version: "3.13"
    - uses: pre-commit/action@v3.0.0

  tests:
    name: Run the tests
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.10", "3.13"]
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
        cache: 'pip'
        cache-dependency-path: 'pyproject.toml'
    - name: Free disk space
      run: |
        set -eux
        sudo rm -rf /usr/share/dotnet || true
        sudo rm -rf /opt/ghc || true
        sudo rm -rf /usr/local/lib/android || true
        sudo apt-get clean
        df -h
    - name: Install Ollama
      run: |
        curl -fsSL https://ollama.com/install.sh | sh
        ollama --version
        ollama pull tinyllama
    - name: Set up test environment
      run: |
        python -m pip install --upgrade pip
        pip install uv
        uv sync --no-group test-gpu --extra test
    - name: cache HuggingFace models
      uses: actions/cache@v4
      with:
        path: ~/.cache/huggingface
        key: hf-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}
        restore-keys: |
          hf-${{ runner.os }}-
    - name: Create matrix id
      id: matrix-id
      env:
        MATRIX_CONTEXT: ${{ toJson(matrix) }}
      run: |
        echo $MATRIX_CONTEXT
        export MATRIX_ID=`echo $MATRIX_CONTEXT | md5sum | cut -c 1-32`
        echo $MATRIX_ID
        echo "::set-output name=id::$MATRIX_ID"
    - name: Run tests
      run: |
        rm -f .coverage*
        uv run coverage erase
        uv run python -m coverage run --branch --source=outlines --parallel-mode -m pytest -x -m 'not api_call'
    - name: Upload coverage data
      uses: actions/upload-artifact@v4
      with:
        name: coverage-data-${{ matrix.python-version }}
        path: .coverage.*
        if-no-files-found: ignore
        include-hidden-files: true

  coverage:
    name: Combine & check coverage.
    needs: tests
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - uses: actions/setup-python@v4
        with:
          cache: pip
          python-version: "3.11"

      - name: Set up environment
        run: |
          pip install --upgrade "coverage[toml]>=5.1" diff-cover

      - uses: actions/download-artifact@v4
        with:
          pattern: coverage-data-*
          merge-multiple: true

      - name: Combine coverage & fail if it's <100%.
        run: |
          python -m coverage combine
          python -m coverage html --skip-covered --skip-empty
          python -m coverage xml
          python -m coverage report --fail-under=100 || (python -m coverage report && exit 1)

      - name: Upload HTML report if check failed.
        uses: actions/upload-artifact@v4
        with:
          name: html-report
          path: htmlcov
          overwrite: true
        if: ${{ failure() }}

  build-wheel:
    name: Build Wheel and Test SDist
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Build SDist and Wheel
        run: ./.github/scripts/build_sdist_and_wheel.sh
tests_api_models matrix .github/workflows/tests_api_models.yml
Triggers
workflow_dispatch
Runs on
ubuntu-latest
Jobs
tests
Matrix
python-version→ 3.10
Commands
  • set -eux sudo rm -rf /usr/share/dotnet || true sudo rm -rf /opt/ghc || true sudo rm -rf /usr/local/lib/android || true sudo apt-get clean df -h
  • curl -fsSL https://ollama.com/install.sh | sh ollama --version ollama pull tinyllama
  • python -m pip install --upgrade pip pip install uv uv sync --no-group test-gpu --extra test
  • echo $MATRIX_CONTEXT export MATRIX_ID=`echo $MATRIX_CONTEXT | md5sum | cut -c 1-32` echo $MATRIX_ID echo "::set-output name=id::$MATRIX_ID"
  • uv run pytest -m 'api_call' --ignore=tests/models/test_dottxt.py
View raw YAML
name: API Models Tests

on:
  workflow_dispatch:

jobs:
  tests:
    name: Run API Models Tests
    runs-on: ubuntu-latest
    env:
      OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
      ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
      GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
      DOTTXT_API_KEY: ${{ secrets.DOTTXT_API_KEY }}
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10"]

    steps:
    - uses: actions/checkout@v3
      with:
        ref: ${{ github.ref }}

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
        cache: 'pip'
        cache-dependency-path: 'pyproject.toml'

    - name: Free disk space
      run: |
        set -eux
        sudo rm -rf /usr/share/dotnet || true
        sudo rm -rf /opt/ghc || true
        sudo rm -rf /usr/local/lib/android || true
        sudo apt-get clean
        df -h

    - name: Install Ollama
      run: |
        curl -fsSL https://ollama.com/install.sh | sh
        ollama --version
        ollama pull tinyllama

    - name: Set up test environment
      run: |
        python -m pip install --upgrade pip
        pip install uv
        uv sync --no-group test-gpu --extra test

    - name: cache HuggingFace models
      uses: actions/cache@v4
      with:
        path: ~/.cache/huggingface
        key: hf-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }}
        restore-keys: |
          hf-${{ runner.os }}-

    - name: Create matrix id
      id: matrix-id
      env:
        MATRIX_CONTEXT: ${{ toJson(matrix) }}
      run: |
        echo $MATRIX_CONTEXT
        export MATRIX_ID=`echo $MATRIX_CONTEXT | md5sum | cut -c 1-32`
        echo $MATRIX_ID
        echo "::set-output name=id::$MATRIX_ID"

    - name: Run tests
      run: |
        uv run pytest -m 'api_call' --ignore=tests/models/test_dottxt.py
      env:
        COVERAGE_FILE: .coverage.${{ steps.matrix-id.outputs.id }}