Skip to content

tests

tests #1

Workflow file for this run

name: Test Coverage
on:
push:
branches: [main, hybrid-pipeline]
pull_request:
branches: [main, hybrid-pipeline]
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov pytest-mock pyyaml coverage-badge
pip install numpy torch transformers sentence-transformers pymilvus
- name: Run tests with coverage
run: |
pytest tests/ \
--cov=src \
--cov-report=term-missing \
--cov-report=xml \
--cov-report=html \
--tb=short \
-v
- name: Generate coverage badge
if: github.event_name == 'push' && github.ref == 'refs/heads/hybrid-pipeline'
run: |
coverage-badge -o .github/badges/coverage.svg -f
- name: Upload coverage reports to Codecov
if: github.event_name == 'push'
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-arxplorer
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload HTML coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: htmlcov/
retention-days: 7
- name: Check coverage threshold
run: |
coverage report --fail-under=70
- name: Commit coverage badge
if: github.event_name == 'push' && github.ref == 'refs/heads/hybrid-pipeline'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .github/badges/coverage.svg
git diff --staged --quiet || git commit -m "Update coverage badge [skip ci]"
git push