Skip to content

Commit

Permalink
Fail if all tests do not pass and fix failing tests (#125)
Browse files Browse the repository at this point in the history
Fixes tests failing in the GitHub actions runner and GitHub actions for test coverage now fail and block merging if all tests do not pass.

Note: there are some flaky tests on GitHub runners caused by different processes trying to read the same files at once.
  • Loading branch information
benank authored Mar 21, 2022
1 parent 53f6ca6 commit 7110c15
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,29 @@ jobs:
run: pip install coverage
- name: Run tests and collect coverage
run: |
coverage run -m unittest discover -s src
cd ./src/extension/tests
echo '===============START EXTENSION TESTS...===============' >> ../../../err.txt
coverage run -m unittest discover -s . -t ../../ 2>> ../../../err.txt
echo '===============FINISH EXTENSION TESTS...===============' >> ../../../err.txt
cd ../../core/tests
echo '===============START CORE TESTS...===============' >> ../../../err.txt
coverage run -m unittest discover -s . -t ../../ 2>> ../../../err.txt
echo '===============FINISH CORE TESTS...===============' >> ../../../err.txt
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
flags: python39
name: python-39
fail_ci_if_error: true
- name: Read test output
id: getoutput
run: echo "::set-output name=contents::$(cat err.txt)"
- name: Check if all tests passed
if: contains( steps.getoutput.outputs.contents , 'FAILED (failures=' )
run: |
echo "${{ steps.getoutput.outputs.contents }}"
exit 1
codecov-python-27:
runs-on: windows-latest
steps:
Expand All @@ -39,11 +54,26 @@ jobs:
run: pip install coverage
- name: Run tests and collect coverage
run: |
coverage run -m unittest discover -s src
cd ./src/extension/tests
echo '===============START EXTENSION TESTS...===============' >> ../../../err2.txt
coverage run -m unittest discover -s . -t ../../ 2>> ../../../err2.txt
echo '===============FINISH EXTENSION TESTS...===============' >> ../../../err2.txt
cd ../../core/tests
echo '===============START CORE TESTS...===============' >> ../../../err2.txt
coverage run -m unittest discover -s . -t ../../ 2>> ../../../err2.txt
echo '===============FINISH CORE TESTS...===============' >> ../../../err2.txt
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
flags: python27
name: python-27
fail_ci_if_error: true
- name: Read test output
id: getoutput
run: echo "::set-output name=contents::$(cat err2.txt)"
- name: Check if all tests passed
if: contains( steps.getoutput.outputs.contents, 'FAILED (failures=' )
run: |
echo "${{ steps.getoutput.outputs.contents }}"
exit 1

0 comments on commit 7110c15

Please sign in to comment.