diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index e67bd2c1c932..d914a6029b8f 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -49,23 +49,18 @@ jobs: pytest --junitxml=junit/test-results.xml --cov=dispatch --cov-report=json:coverage.json --cov-report=xml --cov-report=html export COVERAGE_TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") export FAILED_COVERAGE_PER_FILE=$(python -c "import json;from pprint import pprint;files=json.load(open('coverage.json'))['files'];covs=map(lambda k, v: (k, v['summary']['percent_covered_display']),files.keys(),files.values()); pprint(list(filter(lambda cov:int(cov[1])<${{ env.COVERAGE_SINGLE }},covs)))") - - name: pytester-cov - id: pytester-cov - uses: programmingwithalex/pytester-cov@main - with: - pytest-root-dir: '.' - cov-threshold-single: ${{ env.COVERAGE_SINGLE }} - cov-threshold-total: ${{ env.COVERAGE_TOTAL }} - - name: Coverage single fail - exit + - name: Coverage per file # TODO: Change this recommendation into a requirement. - if: ${{ steps.pytester-cov.outputs.cov-threshold-single-fail == 'true' }} run: | - echo "FAIL Recommended file(s) test coverage of ${{ env.COVERAGE_SINGLE }}% not reached." - echo "Failed file coverage(s): $FAILED_COVERAGE_PER_FILE" - # exit 1 - - name: Coverage total fail - exit + if [[ $FAILED_COVERAGE_PER_FILE < ${{ env.COVERAGE_SINGLE }} ]]; then + echo "FAIL Recommended file(s) test coverage of ${{ env.COVERAGE_SINGLE }}% not reached." + echo "Failed file coverage(s): $FAILED_COVERAGE_PER_FILE" + # exit 1 + fi + - name: Coverage total # TODO: Change this recommendation into a requirement. - if: ${{ steps.pytester-cov.outputs.cov-threshold-total-fail == 'true' }} run: | - echo "FAIL Recommended total test coverage of ${{ env.COVERAGE_TOTAL }}% not reached. Total coverage: $COVERAGE_TOTAL" - # exit 1 + if [[ $COVERAGE_TOTAL < ${{ env.COVERAGE_TOTAL }} ]]; then + echo "FAIL Recommended total test coverage of ${{ env.COVERAGE_TOTAL }}% not reached. Total coverage: $COVERAGE_TOTAL" + # exit 1 + fi