diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 1dccd483351..e799dcdb0eb 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -466,6 +466,64 @@ jobs: .tox/.coverage .tox/coverage.xml + combine-coverage: + if: ${{ success() || failure() }} + name: Combine coverage + needs: test + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v4 + with: + path: artifacts + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Upgrade setuptools and pip + run: python -m pip install -U setuptools pip + - name: Install tox + run: python -m pip install tox + - name: Collect all coverages to one dir + run: | + python -c ' + from pathlib import Path + import shutil + + src_dir = Path("artifacts") + dst_dir = Path(".") / ".tox" + dst_dir.mkdir() + for src_file in src_dir.glob("*/.coverage"): + dst_file = dst_dir / ".coverage.{}".format(src_file.parent.name[9:]) + print("{} copy to {}".format(src_file, dst_file)) + shutil.copy(str(src_file), str(dst_file))' + - name: Combine coverages + run: python -m tox -e coverage + - name: Publish html coverage + uses: actions/upload-artifact@v4 + with: + name: overall_cov_html + path: .tox/htmlcov + - name: Publish xml coverage + uses: actions/upload-artifact@v4 + with: + name: overall_cov_xml + path: .tox/coverage.xml + - uses: codecov/codecov-action@v1 + with: + file: .tox/coverage.xml + - name: Show coverage diff + run: | + pip install diff_cover + git log -n 5 --pretty=oneline + git fetch -f origin main:main || true + diff-cover .tox/coverage.xml --compare-branch=main --fail-under=95 + doc: needs: lint name: Build Doc