@@ -57,33 +57,69 @@ jobs:
5757 - name : Lint
5858 run : poetry run ruff check .
5959
60- - name : Run pytest
61- run : poetry run pytest --cov=openapi_python_client --cov-report=term-missing tests end_to_end_tests/test_end_to_end.py --basetemp=tests/tmp
60+ - name : Run pytest without coverage
61+ if : matrix.os != 'ubuntu-latest'
62+ run : poetry run pytest tests end_to_end_tests/test_end_to_end.py --basetemp=tests/tmp
6263 env :
6364 TASKIPY : true
6465
65- - name : Generate coverage report
66- shell : bash
67- run : poetry run coverage xml -o coverage-${{ matrix.os }}-${{ matrix.python }}.xml
66+ - name : Run pytest with coverage
67+ if : matrix.os == 'ubuntu-latest'
68+ run : poetry run pytest --cov=openapi_python_client --cov-report=term-missing tests end_to_end_tests/test_end_to_end.py --basetemp=tests/tmp
69+ env :
70+ TASKIPY : true
71+
72+ - run : mv .coverage .coverage.${{ matrix.python }}
73+ if : matrix.os == 'ubuntu-latest'
6874
6975 - name : Store coverage report
7076 uses : actions/upload-artifact@v4.0.0
77+ if : matrix.os == 'ubuntu-latest'
7178 with :
72- name : coverage-${{ matrix.os }}-${{ matrix.python }}
73- path : coverage-${{ matrix.os }}-${{ matrix.python }}.xml
79+ name : coverage-${{ matrix.python }}
80+ path : .coverage.${{ matrix.python }}
81+ if-no-files-found : error
7482
75- upload_coverage :
83+ coverage :
84+ name : Combine & check coverage
7685 needs : test
7786 runs-on : ubuntu-latest
7887 steps :
7988 - uses : actions/checkout@v4.1.1
89+ - uses : actions/setup-python@v4
90+ with :
91+ python-version : " 3.12"
8092 - name : Download coverage reports
81- uses : actions/download-artifact@v4.0 .0
93+ uses : actions/download-artifact@v4.1 .0
8294 with :
83- path : coverage-report
84- - uses : codecov/codecov-action@v3.1.4
95+ merge-multiple : true
96+
97+ - name : Create Virtual Environment
98+ run : python -m venv .venv
99+
100+ - name : Combine coverage & fail if it's <100%.
101+ run : |
102+ # Install coverage
103+ .venv/bin/pip install --upgrade coverage[toml]
104+
105+ # Find all of the downloaded coverage reports and combine them
106+ .venv/bin/python -m coverage combine
107+
108+ # Create html report
109+ .venv/bin/python -m coverage html --skip-covered --skip-empty
110+
111+ # Report in Markdown and write to summary.
112+ .venv/bin/python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
113+
114+ # Report again and fail if under 100%.
115+ .venv/bin/python -m coverage report --fail-under=100
116+
117+ - name : Upload HTML report if check failed.
118+ uses : actions/upload-artifact@v4.0.0
85119 with :
86- files : " coverage-report/**/*.xml"
120+ name : html-report
121+ path : htmlcov
122+ if : ${{ failure() }}
87123
88124 integration :
89125 name : Integration Tests
0 commit comments