Files
Anthias/.github/workflows/test-runner.yml

93 lines
2.5 KiB
YAML

name: Test Runner
on:
workflow_call:
inputs:
test-type:
description: 'Type of tests to run (typescript or python)'
required: true
type: string
python-version:
description: 'Python version to use'
required: false
default: '3.11'
type: string
jobs:
run-tests:
name: Run ${{ inputs.test-type }} tests
runs-on: ubuntu-24.04
env:
COMPOSE_FILE: docker-compose.test.yml
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: '0.9.17'
- name: Install dependencies
run: |
uv venv
uv pip install --group docker-image-builder
- name: Build Containers
run: |
uv run python -m tools.image_builder \
--dockerfiles-only \
--disable-cache-mounts \
--service celery \
--service redis \
--service test
- name: Start the test container
run: |
docker compose up -d --build
- name: Run TypeScript tests
if: inputs.test-type == 'typescript'
run: |
docker compose exec anthias-test \
npm install
docker compose exec anthias-test \
npm run test
- name: Run Python unit tests
if: inputs.test-type == 'python'
run: |
docker compose exec anthias-test \
./manage.py test --noinput --parallel --exclude-tag=integration
- name: Setup integration test environment
if: inputs.test-type == 'python'
run: |
docker compose exec anthias-test \
bash ./bin/prepare_test_environment.sh -s
- name: Run Python integration tests
if: inputs.test-type == 'python'
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: |
docker compose exec anthias-test \
./manage.py test --noinput --tag=integration
- name: Upload coverage reports to Codecov
if: inputs.test-type == 'python'
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Stop the test container
run: |
docker compose down