Skip to content

Integration Tests

Integration Tests #65

name: Integration Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
# Run nightly at 2 AM UTC for full integration tests
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
run_expensive_tests:
description: 'Run expensive tests'
required: false
default: 'false'
type: boolean
jobs:
integration-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
uv venv
uv pip install -e .
uv pip install pytest pytest-cov pytest-asyncio
- name: Run unit tests first
run: |
uv run pytest tests/ -v --ignore=tests/integration/ --ignore=tests/test_api/
- name: Run minimal integration tests (PR validation)
if: github.event_name == 'pull_request'
env:
CI: true
CRYPTOCOMPARE_API_KEY: ${{ secrets.CRYPTOCOMPARE_API_KEY }}
DATABENTO_API_KEY: ${{ secrets.DATABENTO_API_KEY }}
OANDA_API_KEY: ${{ secrets.OANDA_API_KEY }}
run: |
# Run only non-expensive integration tests
uv run pytest tests/integration/ -v -m "integration and not expensive" \
--cov=qdata.providers --cov-report=term-missing
- name: Run full integration tests (main branch)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
CI: true
CRYPTOCOMPARE_API_KEY: ${{ secrets.CRYPTOCOMPARE_API_KEY }}
DATABENTO_API_KEY: ${{ secrets.DATABENTO_API_KEY }}
OANDA_API_KEY: ${{ secrets.OANDA_API_KEY }}
run: |
# Run all integration tests on main branch
uv run pytest tests/integration/ -v -m "integration" \
--cov=qdata.providers --cov-report=term-missing
- name: Run expensive tests (nightly or manual)
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_expensive_tests == 'true')
env:
CI: false # Allow expensive tests
CRYPTOCOMPARE_API_KEY: ${{ secrets.CRYPTOCOMPARE_API_KEY }}
DATABENTO_API_KEY: ${{ secrets.DATABENTO_API_KEY }}
OANDA_API_KEY: ${{ secrets.OANDA_API_KEY }}
run: |
# Run all tests including expensive ones
uv run pytest tests/integration/ -v \
--cov=qdata.providers --cov-report=term-missing --cov-report=html
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: htmlcov/
- name: Check coverage threshold
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
# Ensure minimum coverage for providers
coverage_percent=$(uv run coverage report | grep "qdata/providers" | awk '{print $4}' | sed 's/%//')
if [ "$coverage_percent" -lt "60" ]; then
echo "Coverage below 60% threshold"
exit 1
fi
performance-benchmarks:
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
uv venv
uv pip install -e .
uv pip install pytest pytest-benchmark
- name: Run performance benchmarks
env:
CRYPTOCOMPARE_API_KEY: ${{ secrets.CRYPTOCOMPARE_API_KEY }}
DATABENTO_API_KEY: ${{ secrets.DATABENTO_API_KEY }}
OANDA_API_KEY: ${{ secrets.OANDA_API_KEY }}
run: |
uv run pytest tests/integration/test_real_api_integration.py::TestRealAPIIntegration::test_performance_baselines -v
- name: Store benchmark results
uses: actions/upload-artifact@v3
with:
name: benchmark-results
path: .benchmarks/