From 58a0e664e6e65e38d33cb2b6ee7fcbb440109839 Mon Sep 17 00:00:00 2001 From: "code-coverage-agent[bot]" <295130552+Code Coverage Agent@users.noreply.github.com> Date: Wed, 5 Aug 2026 05:55:28 +0000 Subject: [PATCH] Add Python code coverage reporting with Cobertura XML output Co-authored-by: pobonomo <15269857+pobonomo@users.noreply.github.com> --- .github/workflows/PR_nolicense.yml | 25 +++++++++++++++++++++++++ .github/workflows/push.yml | 24 ++++++++++++++++++++++++ setup.cfg | 9 +++++++++ tox.ini | 3 ++- 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/.github/workflows/PR_nolicense.yml b/.github/workflows/PR_nolicense.yml index 62b3f9e3..89295343 100644 --- a/.github/workflows/PR_nolicense.yml +++ b/.github/workflows/PR_nolicense.yml @@ -51,3 +51,28 @@ jobs: GUROBI_VERSION: ${{ matrix.gurobi-version }} run: | uvx tox + - name: Upload coverage artifact + if: matrix.python-version == '3.12' && matrix.gurobi-version == 'gurobi13' && github.event.pull_request.head.repo.full_name == github.repository + uses: actions/upload-artifact@v7 + with: + name: coverage-report-python + path: coverage.xml + + upload-coverage-python: + needs: test + if: ${{ !cancelled() && needs.test.result == 'success' && github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + permissions: + contents: read + code-quality: write + pull-requests: read + steps: + - name: Download coverage artifact + uses: actions/download-artifact@v8 + with: + name: coverage-report-python + - uses: actions/upload-code-coverage@v1 + with: + file: coverage.xml + language: Python + label: code-coverage-agent diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 704d22cb..51e00c8b 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -58,6 +58,12 @@ jobs: GUROBI_VERSION: ${{ matrix.gurobi-version }} run: | uvx tox + - name: Upload coverage artifact + if: matrix.python-version == '3.12' && matrix.gurobi-version == 'gurobi13' + uses: actions/upload-artifact@v7 + with: + name: coverage-report-python + path: coverage.xml examples: needs: test @@ -88,3 +94,21 @@ jobs: run: | python_version_no_dot=$(echo "${{ matrix.python-version }}" | tr -d '.') uvx tox -e py${python_version_no_dot}-examples-${{ matrix.gurobi-version }} + + upload-coverage-python: + needs: test + if: ${{ !cancelled() && needs.test.result == 'success' }} + runs-on: ubuntu-latest + permissions: + contents: read + code-quality: write + steps: + - name: Download coverage artifact + uses: actions/download-artifact@v8 + with: + name: coverage-report-python + - uses: actions/upload-code-coverage@v1 + with: + file: coverage.xml + language: Python + label: code-coverage-agent diff --git a/setup.cfg b/setup.cfg index 53fac0a0..5ea2ce95 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,3 +5,12 @@ packages = find: [options.packages.find] where = src + +[coverage:run] +source = src/gurobi_ml +branch = true + +[coverage:report] +omit = + /tmp/* + /private/* diff --git a/tox.ini b/tox.ini index 060369cc..95de2e18 100644 --- a/tox.ini +++ b/tox.ini @@ -157,7 +157,8 @@ deps = -r{toxinidir}/requirements.xgboost.txt -r{toxinidir}/requirements.lightgbm.txt commands = - pytest tests/test_sklearn \ + pytest --cov=src/gurobi_ml --cov-report=xml:coverage.xml \ + tests/test_sklearn \ tests/test_lightgbm \ tests/test_xgboost \ tests/test_keras \