Skip to content

Commit

Permalink
Fix unit test failures not detected.
Browse files Browse the repository at this point in the history
  • Loading branch information
ReinderVosDeWael committed Aug 25, 2023
1 parent 5ea68e1 commit af91307
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,67 @@ on:

jobs:
unit:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: poetry
- name: Install dependencies
run: |
python -m pip install poetry
poetry install
- name: Run tests
run: poetry run pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov-report=xml:coverage.xml --cov=src tests | tee pytest-coverage.txt
id: run-tests
continue-on-error: true
run: >
poetry run pytest \
--junitxml=pytest.xml \
--cov-report=term-missing:skip-covered \
--cov-report=xml:coverage.xml \
--cov=src tests \
> ./pytest-coverage.txt;
cat ./pytest-coverage.txt;
- name: Upload pytest coverage artifacts.
uses: actions/upload-artifact@v2
with:
name: pytest-coverage
path: ./pytest-coverage.txt
- name: Upload pytest junitxml artifacts.
uses: actions/upload-artifact@v2
with:
name: pytest-junitxml
path: pytest.xml
- name: Checking testing success.
if: steps.run-tests.outcome != 'success'
run: exit 1;

coverage:
runs-on: ubuntu-latest
needs: unit
if: success() || failure()
permissions:
contents: read
pull-requests: write
steps:
- name: Get pytest artifacts
uses: actions/download-artifact@v2
with:
name: pytest-coverage
- name: Get pytest junitxml artifacts
uses: actions/download-artifact@v2
with:
name: pytest-junitxml
- name: Pytest coverage comment
if: github.event_name == 'pull_request'
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
- name: Upload coverage to Codecov
if: success() || failure()
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down

0 comments on commit af91307

Please sign in to comment.