Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yxjiang committed Jul 17, 2024
1 parent a2ec046 commit 2acd72a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Python Tests and Coverage

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, '3.10']

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Run tests with pytest and coverage
run: |
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
- name: Check coverage threshold
run: |
coverage_percentage=$(coverage report | grep TOTAL | awk '{print $4}' | sed 's/%//')
if (( $(echo "$coverage_percentage < 80" | bc -l) )); then
echo "Coverage is below 80%. Current coverage: $coverage_percentage%"
exit 1
fi

0 comments on commit 2acd72a

Please sign in to comment.