2024-01-02 23:42:00 +08:00
|
|
|
name: Run Pytest
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
2024-05-31 16:42:14 +08:00
|
|
|
paths:
|
|
|
|
- api/**
|
2024-06-02 11:30:14 +08:00
|
|
|
- docker/**
|
2024-11-06 13:55:29 +08:00
|
|
|
- .github/workflows/api-tests.yml
|
2024-05-31 16:42:14 +08:00
|
|
|
|
|
|
|
concurrency:
|
|
|
|
group: api-tests-${{ github.head_ref || github.run_id }}
|
|
|
|
cancel-in-progress: true
|
2024-01-02 23:42:00 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
test:
|
2024-06-12 14:43:03 +08:00
|
|
|
name: API Tests
|
2024-06-11 13:11:28 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
python-version:
|
|
|
|
- "3.10"
|
|
|
|
- "3.11"
|
2024-08-02 21:14:36 +08:00
|
|
|
- "3.12"
|
2024-06-11 13:11:28 +08:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
2024-11-06 13:55:29 +08:00
|
|
|
- name: Install Poetry
|
|
|
|
uses: abatilo/actions-poetry@v3
|
|
|
|
|
2024-06-11 13:11:28 +08:00
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
|
|
uses: actions/setup-python@v5
|
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
2024-11-06 13:55:29 +08:00
|
|
|
cache: poetry
|
|
|
|
cache-dependency-path: api/poetry.lock
|
2024-10-14 22:22:03 +08:00
|
|
|
|
2024-10-08 15:11:45 +08:00
|
|
|
- name: Check Poetry lockfile
|
2024-06-14 20:54:07 +08:00
|
|
|
run: |
|
2024-06-22 01:34:08 +08:00
|
|
|
poetry check -C api --lock
|
2024-06-14 20:54:07 +08:00
|
|
|
poetry show -C api
|
2024-06-11 13:11:28 +08:00
|
|
|
|
|
|
|
- name: Install dependencies
|
2024-06-12 14:43:03 +08:00
|
|
|
run: poetry install -C api --with dev
|
2024-06-11 13:11:28 +08:00
|
|
|
|
2024-10-08 15:11:45 +08:00
|
|
|
- name: Check dependencies in pyproject.toml
|
|
|
|
run: poetry run -C api bash dev/pytest/pytest_artifacts.sh
|
|
|
|
|
2024-06-11 13:11:28 +08:00
|
|
|
- name: Run Unit tests
|
|
|
|
run: poetry run -C api bash dev/pytest/pytest_unit_tests.sh
|
|
|
|
|
|
|
|
- name: Run ModelRuntime
|
|
|
|
run: poetry run -C api bash dev/pytest/pytest_model_runtime.sh
|
|
|
|
|
|
|
|
- name: Run Tool
|
|
|
|
run: poetry run -C api bash dev/pytest/pytest_tools.sh
|
|
|
|
|
2024-06-28 17:37:52 +08:00
|
|
|
- name: Set up dotenvs
|
|
|
|
run: |
|
|
|
|
cp docker/.env.example docker/.env
|
|
|
|
cp docker/middleware.env.example docker/middleware.env
|
|
|
|
|
2024-06-30 10:31:31 +08:00
|
|
|
- name: Expose Service Ports
|
|
|
|
run: sh .github/workflows/expose_service_ports.sh
|
|
|
|
|
2024-06-11 13:11:28 +08:00
|
|
|
- name: Set up Sandbox
|
2024-11-06 13:55:29 +08:00
|
|
|
uses: hoverkraft-tech/compose-action@v2.0.2
|
2024-06-11 13:11:28 +08:00
|
|
|
with:
|
|
|
|
compose-file: |
|
|
|
|
docker/docker-compose.middleware.yaml
|
|
|
|
services: |
|
|
|
|
sandbox
|
|
|
|
ssrf_proxy
|
|
|
|
|
|
|
|
- name: Run Workflow
|
|
|
|
run: poetry run -C api bash dev/pytest/pytest_workflow.sh
|