Benrules1/sync with internal #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Test" | |
on: | |
push: | |
branches: | |
- "main" | |
paths: | |
# Always run when workflow configs change | |
- ".github/workflows/**" | |
# Run when package changes | |
- "**" | |
release: | |
types: [published] | |
pull_request: | |
branches: | |
- "main" | |
paths: | |
# Always run when workflow configs change | |
- ".github/workflows/**" | |
# Run when package changes | |
- "**" | |
workflow_dispatch: {} | |
jobs: | |
test_parser: | |
runs-on: large | |
permissions: | |
contents: read | |
id-token: write | |
needs: | |
- build_api_cpu | |
- build_api_gpu | |
strategy: | |
matrix: | |
python-version: | |
- 3.9 | |
env: | |
COMPOSE_FILE: docker-compose.gha.yaml | |
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
token_format: access_token | |
workload_identity_provider: projects/751739702614/locations/global/workloadIdentityPools/cohere-ci/providers/github | |
service_account: [email protected] | |
- uses: docker/login-action@v3 | |
with: | |
registry: us-central1-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.auth.outputs.access_token }} | |
- id: meta | |
uses: docker/metadata-action@v5 | |
- run: | | |
echo "Pulling ${DOCKER_METADATA_OUTPUT_VERSION}" | |
docker compose up --detach --no-build | |
- uses: actions/setup-python@v4 | |
id: setup_python | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
cache-dependency-path: | | |
parser/poetry.lock | |
- name: Install dependencies (tests) | |
run: | | |
pip install pytest pytest-mock | |
pip install -e sdk | |
- name: Install dependencies (parser) | |
working-directory: parser | |
run: | | |
sudo apt update && sudo apt upgrade -y | |
sudo apt install -y libmagic-dev poppler-utils tesseract-ocr libxext6 pandoc libreoffice | |
pip install -e . | |
- name: Cache nltk files | |
uses: actions/cache@v4 | |
with: | |
path: /usr/share/nltk_data | |
key: ${{ runner.os }}-nltk-${{ hashFiles('parser/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-nltk- | |
- name: Download nltk files | |
run: | | |
python -m nltk.downloader punkt --dir /usr/share/nltk_data | |
- name: Run tests (parser) | |
working-directory: parser | |
run: | | |
pytest -sv tests | |
build_api_gpu: | |
runs-on: large | |
env: | |
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/build-and-push-docker | |
with: | |
service: compass_parser/api_gpu | |
context: parser_api | |
build_contexts: compass_parser=./parser | |
workload_identity_provider: projects/751739702614/locations/global/workloadIdentityPools/cohere-ci/providers/github | |
service_account: [email protected] | |
file: parser_api/gpu.Dockerfile | |
build_api_cpu: | |
runs-on: large | |
env: | |
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/build-and-push-docker | |
with: | |
service: compass_parser/api | |
context: parser_api | |
build_contexts: compass_parser=./parser | |
workload_identity_provider: projects/751739702614/locations/global/workloadIdentityPools/cohere-ci/providers/github | |
service_account: [email protected] | |
file: parser_api/cpu.Dockerfile | |
test_client: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
strategy: | |
matrix: | |
python-version: | |
- 3.9 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
id: setup_python | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
cache-dependency-path: | | |
poetry.lock | |
- name: Install dependencies (tests) | |
run: | | |
pip install pytest pytest-asyncio pytest-mock requests-mock | |
- name: Install dependencies | |
working-directory: sdk | |
run: | | |
pip install -e . | |
- name: Run tests | |
working-directory: sdk | |
run: | | |
echo $COHERE_API_KEY | |
pytest -sv tests/test_compass_client.py |