Skip to content

Commit

Permalink
Added test_coverage.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
TreyWW committed Mar 18, 2024
1 parent c590273 commit 0cc3f85
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 43 deletions.
34 changes: 33 additions & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,36 @@ jobs:
- name: Run the test scripts
run: |
export TESTING=true
docker compose exec -T myfinances_django ./infrastructure/backend/scripts/tests/views.sh
docker compose exec -T myfinances_django ./infrastructure/backend/scripts/tests/views.sh
coverage:
name: Combine & check coverage
needs: tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: .python-version-default
cache: pip
- run: python -Im pip install --upgrade coverage[toml]
- uses: actions/download-artifact@v4
with:
pattern: coverage-data-*
merge-multiple: true

- name: Combine coverage & fail if it's <100%.
run: |
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
# Report and write to summary.
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
# Report again and fail if under 100%.
python -Im coverage report --fail-under=50
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov
if: ${{ failure() }}
42 changes: 0 additions & 42 deletions .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
@@ -1,42 +0,0 @@
name: Test Coverage
on:
push:
pull_request:

jobs:
coverage:
name: Combine & check coverage
if: always()
needs: tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
# Use latest Python, so it understands all syntax.
python-version: "3.12"

- uses: actions/download-artifact@v4
with:
pattern: coverage-data-*
merge-multiple: true

- name: "Combine coverage & fail if it's <50"
run: |
python -Im pip install --upgrade coverage[toml]
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
# Report and write to summary.
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
# Report again and fail if under 50%.
python -Im coverage report --fail-under=50
- name: Upload HTML report if check failed
uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov
if: ${{ failure() }}

0 comments on commit 0cc3f85

Please sign in to comment.