Skip to content

feat: allow to load tools from external modules #1629

feat: allow to load tools from external modules

feat: allow to load tools from external modules #1629

Workflow file for this run

name: Build
on:
push:
branches: [ master ]
tags:
- 'v*'
pull_request:
branches: [ master ]
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
jobs:
build:
name: Test ${{ matrix.os }} with `${{ matrix.extras }}` on ${{ matrix.model }}
runs-on: ${{ matrix.os }}
env:
RELEASE: false
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python_version: ['3.10']
extras: ['-E all']
model: ['openai/gpt-4o-mini', 'anthropic/claude-3-haiku-20240307']
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Install apt dependencies
run: sudo apt-get install universal-ctags pandoc tmux
- name: Install poetry
run: |
pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
cache: 'poetry'
- name: Install dependencies
run: |
make build
poetry install ${{ matrix.extras }}
- name: Install playwright
if: contains(matrix.extras, 'browser') || contains(matrix.extras, 'all')
run: poetry run playwright install chromium
# old comment: OpenAI sometimes randomly aborts connections
- name: Run tests
uses: nick-fields/retry@v2
env:
TERM: xterm
MODEL: ${{ matrix.model }}
with:
timeout_minutes: 5
max_attempts: 1 # favor pytest retries (mark with flaky)
retry_wait_seconds: 10
command: make test SLOW=true
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
MODEL: ${{ matrix.model }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: MODEL
flags: ${{ matrix.model }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
build-docker:
runs-on: ubuntu-latest
env:
SHOULD_PUSH: ${{ github.ref == 'refs/tags/v*' || github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
if: env.SHOULD_PUSH == 'true'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set environment variables
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
# Sanitize the ref name to be used as a Docker tag
SANITIZED_REF_NAME=$(echo "${GITHUB_REF_NAME}" | tr '/' '-')
echo "SANITIZED_REF_NAME=${SANITIZED_REF_NAME}" >>${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'
# First build the base image locally (needed for subsequent builds)
- name: Build Docker image (base)
uses: docker/build-push-action@v3
with:
tags: gptme:latest
file: ./scripts/Dockerfile
context: .
push: false
# Push base image to registry if on master/tag
- name: Push Docker image (base)
uses: docker/build-push-action@v3
if: env.SHOULD_PUSH == 'true'
with:
tags: |
ghcr.io/${{ env.OWNER_LC }}/gptme:latest
ghcr.io/${{ env.OWNER_LC }}/gptme:${{ env.SANITIZED_REF_NAME }}
file: ./scripts/Dockerfile
context: .
push: true
# Build and push eval image
- name: Build and push Docker image (eval)
uses: docker/build-push-action@v3
with:
tags: |
ghcr.io/${{ env.OWNER_LC }}/gptme-eval:latest
ghcr.io/${{ env.OWNER_LC }}/gptme-eval:${{ env.SANITIZED_REF_NAME }}
file: ./scripts/Dockerfile.eval
context: .
push: ${{ env.SHOULD_PUSH }}
# Now the full eval image
# NOTE: takes a long time and leads to a big (1GB+) image
#- name: Build and push Docker image (eval-full)
# uses: docker/build-push-action@v3
# with:
# tags: |
# ghcr.io/${{ env.OWNER_LC }}/gptme-eval-full:latest
# ghcr.io/${{ env.OWNER_LC }}/gptme-eval-full:${{ env.SANITIZED_REF_NAME }}
# file: ./scripts/Dockerfile.eval
# context: .
# push: true
# build-args: |
# RUST=yes
# BROWSER=yes
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'poetry'
- name: Install dependencies
run: |
make build
poetry install
- name: Check for lint
run: |
make lint
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'poetry'
- name: Install dependencies
run: |
make build
poetry install -E server -E browser
- name: Typecheck
run: |
make typecheck