Skip to content

chore: Ensure openai is installed before importing init #309

chore: Ensure openai is installed before importing init

chore: Ensure openai is installed before importing init #309

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: notdiamond SDK tests
on:
pull_request:
push:
branches:
- "main"
defaults:
run:
working-directory: ./
jobs:
build:
runs-on: ubuntu-latest
continue-on-error: true
permissions:
# Gives the action the necessary permissions for publishing new
# comments in pull requests.
pull-requests: write
# Gives the action the necessary permissions for pushing data to the
# python-coverage-comment-action branch, and for editing existing
# comments (to avoid publishing multiple comments in the same PR)
contents: write
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: use correct env
run: poetry env use ${{ matrix.python-version }}
- name: Install dependencies if venv is not cached
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install -E "create rag openai" --with test && poetry run python -m nltk.downloader all
- name: Test with pytest
env:
NOTDIAMOND_API_KEY: ${{ secrets.NOTDIAMOND_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_API_VERSION: ${{ secrets.OPENAI_API_VERSION }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_API_KEY }}
AZURE_API_VERSION: ${{ secrets.AZURE_API_VERSION }}
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY }}
REPLICATE_API_KEY: ${{ secrets.REPLICATE_API_KEY }}
PPLX_API_KEY: ${{ secrets.PPLX_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
NOTDIAMOND_API_URL: ${{ vars.NOTDIAMOND_API_URL }}
run: |
PYTEST_ADDOPTS="--color=yes" poetry run coverage run --branch -m pytest -v tests/
poetry run coverage report -m
- name: coverage badge + comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
# If the coverage percentage is above or equal to this value, the badge will be green.
MINIMUM_GREEN: 80
MINIMUM_ORANGE: 50
COVERAGE_PATH: ./
- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v4
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
# If you use a different name, update COMMENT_ARTIFACT_NAME accordingly
name: python-coverage-comment-action
# If you use a different name, update COMMENT_FILENAME accordingly
path: python-coverage-comment-action.txt