From 2ea75f23ee6f42c2a5f4e093181ffb5bdbf3c9a7 Mon Sep 17 00:00:00 2001 From: Brian Bjarke Jensen Date: Sun, 14 Sep 2025 16:57:55 +0200 Subject: [PATCH 1/4] added test coverage to CI --- pyproject.toml | 5 ++++ uv.lock | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index cb3e6f3..d8f3c00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ dev = [ "mypy>=1.17.1", "pre-commit>=4.3.0", "pytest>=8.4.1", + "pytest-cov>=7.0.0", "pyupgrade>=3.20.0", "ruff>=0.12.10", "safety>=3.6.0", @@ -46,3 +47,7 @@ warn_unreachable = true # catch unreachable code show_error_codes = true # show error codes in output explicit_package_bases = true # reduce risk of import confusion namespace_packages = true # enable namespace packages + +[tool.pytest.ini_options] +addopts = "--cov=python_utils --cov-report=term-missing" +testpaths = ["tests"] diff --git a/uv.lock b/uv.lock index b63f67b..bc4ccfb 100644 --- a/uv.lock +++ b/uv.lock @@ -155,6 +155,70 @@ wheels = [ { url = "http://10.0.0.2:5001/index/colorama/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6" }, ] +[[package]] +name = "coverage" +version = "7.10.6" +source = { registry = "http://10.0.0.2:5001/index/" } +sdist = { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6.tar.gz", hash = "sha256:f644a3ae5933a552a29dbb9aa2f90c677a875f80ebea028e5a52a4f429044b90" } +wheels = [ + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:5b2dd6059938063a2c9fee1af729d4f2af28fd1a545e9b7652861f0d752ebcea" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:388d80e56191bf846c485c14ae2bc8898aa3124d9d35903fef7d907780477634" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:90cb5b1a4670662719591aa92d0095bb41714970c0b065b02a2610172dbf0af6" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:961834e2f2b863a0e14260a9a273aff07ff7818ab6e66d2addf5628590c628f9" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bf9a19f5012dab774628491659646335b1928cfc931bf8d97b0d5918dd58033c" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:99c4283e2a0e147b9c9cc6bc9c96124de9419d6044837e9799763a0e29a7321a" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:282b1b20f45df57cc508c1e033403f02283adfb67d4c9c35a90281d81e5c52c5" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:8cdbe264f11afd69841bd8c0d83ca10b5b32853263ee62e6ac6a0ab63895f972" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp312-cp312-win32.whl", hash = "sha256:a517feaf3a0a3eca1ee985d8373135cfdedfbba3882a5eab4362bda7c7cf518d" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp312-cp312-win_amd64.whl", hash = "sha256:856986eadf41f52b214176d894a7de05331117f6035a28ac0016c0f63d887629" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp312-cp312-win_arm64.whl", hash = "sha256:acf36b8268785aad739443fa2780c16260ee3fa09d12b3a70f772ef100939d80" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ffea0575345e9ee0144dfe5701aa17f3ba546f8c3bb48db62ae101afb740e7d6" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:95d91d7317cde40a1c249d6b7382750b7e6d86fad9d8eaf4fa3f8f44cf171e80" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:3e23dd5408fe71a356b41baa82892772a4cefcf758f2ca3383d2aa39e1b7a003" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:0f3f56e4cb573755e96a16501a98bf211f100463d70275759e73f3cbc00d4f27" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:db4a1d897bbbe7339946ffa2fe60c10cc81c43fab8b062d3fcb84188688174a4" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:d8fd7879082953c156d5b13c74aa6cca37f6a6f4747b39538504c3f9c63d043d" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:28395ca3f71cd103b8c116333fa9db867f3a3e1ad6a084aa3725ae002b6583bc" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:61c950fc33d29c91b9e18540e1aed7d9f6787cc870a3e4032493bbbe641d12fc" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313-win32.whl", hash = "sha256:160c00a5e6b6bdf4e5984b0ef21fc860bc94416c41b7df4d63f536d17c38902e" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313-win_amd64.whl", hash = "sha256:628055297f3e2aa181464c3808402887643405573eb3d9de060d81531fa79d32" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313-win_arm64.whl", hash = "sha256:df4ec1f8540b0bcbe26ca7dd0f541847cc8a108b35596f9f91f59f0c060bfdd2" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:c9a8b7a34a4de3ed987f636f71881cd3b8339f61118b1aa311fbda12741bff0b" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:8dd5af36092430c2b075cee966719898f2ae87b636cefb85a653f1d0ba5d5393" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:b0353b0f0850d49ada66fdd7d0c7cdb0f86b900bb9e367024fd14a60cecc1e27" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:d6b9ae13d5d3e8aeca9ca94198aa7b3ebbc5acfada557d724f2a1f03d2c0b0df" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:675824a363cc05781b1527b39dc2587b8984965834a748177ee3c37b64ffeafb" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:692d70ea725f471a547c305f0d0fc6a73480c62fb0da726370c088ab21aed282" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:851430a9a361c7a8484a36126d1d0ff8d529d97385eacc8dfdc9bfc8c2d2cbe4" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:d9369a23186d189b2fc95cc08b8160ba242057e887d766864f7adf3c46b2df21" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313t-win32.whl", hash = "sha256:92be86fcb125e9bda0da7806afd29a3fd33fdf58fba5d60318399adf40bf37d0" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313t-win_amd64.whl", hash = "sha256:6b3039e2ca459a70c79523d39347d83b73f2f06af5624905eba7ec34d64d80b5" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp313-cp313t-win_arm64.whl", hash = "sha256:3fb99d0786fe17b228eab663d16bee2288e8724d26a199c29325aac4b0319b9b" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:6008a021907be8c4c02f37cdc3ffb258493bdebfeaf9a839f9e71dfdc47b018e" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:5e75e37f23eb144e78940b40395b42f2321951206a4f50e23cfd6e8a198d3ceb" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:0f7cb359a448e043c576f0da00aa8bfd796a01b06aa610ca453d4dde09cc1034" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:c68018e4fc4e14b5668f1353b41ccf4bc83ba355f0e1b3836861c6f042d89ac1" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:cd4b2b0707fc55afa160cd5fc33b27ccbf75ca11d81f4ec9863d5793fc6df56a" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:4cec13817a651f8804a86e4f79d815b3b28472c910e099e4d5a0e8a3b6a1d4cb" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:f2a6a8e06bbda06f78739f40bfb56c45d14eb8249d0f0ea6d4b3d48e1f7c695d" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:081b98395ced0d9bcf60ada7661a0b75f36b78b9d7e39ea0790bb4ed8da14747" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314-win32.whl", hash = "sha256:6937347c5d7d069ee776b2bf4e1212f912a9f1f141a429c475e6089462fcecc5" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314-win_amd64.whl", hash = "sha256:adec1d980fa07e60b6ef865f9e5410ba760e4e1d26f60f7e5772c73b9a5b0713" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314-win_arm64.whl", hash = "sha256:a80f7aef9535442bdcf562e5a0d5a5538ce8abe6bb209cfbf170c462ac2c2a32" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:0de434f4fbbe5af4fa7989521c655c8c779afb61c53ab561b64dcee6149e4c65" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:6e31b8155150c57e5ac43ccd289d079eb3f825187d7c66e755a055d2c85794c6" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:98cede73eb83c31e2118ae8d379c12e3e42736903a8afcca92a7218e1f2903b0" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:f863c08f4ff6b64fa8045b1e3da480f5374779ef187f07b82e0538c68cb4ff8e" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2b38261034fda87be356f2c3f42221fdb4171c3ce7658066ae449241485390d5" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:0e93b1476b79eae849dc3872faeb0bf7948fd9ea34869590bc16a2a00b9c82a7" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:ff8a991f70f4c0cf53088abf1e3886edcc87d53004c7bb94e78650b4d3dac3b5" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:ac765b026c9f33044419cbba1da913cfb82cca1b60598ac1c7a5ed6aac4621a0" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314t-win32.whl", hash = "sha256:441c357d55f4936875636ef2cfb3bee36e466dcf50df9afbd398ce79dba1ebb7" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314t-win_amd64.whl", hash = "sha256:073711de3181b2e204e4870ac83a7c4853115b42e9cd4d145f2231e12d670930" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-cp314-cp314t-win_arm64.whl", hash = "sha256:137921f2bac5559334ba66122b753db6dc5d1cf01eb7b64eb412bb0d064ef35b" }, + { url = "http://10.0.0.2:5001/index/coverage/coverage-7.10.6-py3-none-any.whl", hash = "sha256:92c4ecf6bf11b2e85fd4d8204814dc26e6a19f0c9d938c207c5cb0eadfcabbe3" }, +] + [[package]] name = "cryptography" version = "45.0.6" @@ -588,6 +652,20 @@ wheels = [ { url = "http://10.0.0.2:5001/index/pytest/pytest-8.4.1-py3-none-any.whl", hash = "sha256:539c70ba6fcead8e78eebbf1115e8b589e7565830d7d006a8723f19ac8a0afb7" }, ] +[[package]] +name = "pytest-cov" +version = "7.0.0" +source = { registry = "http://10.0.0.2:5001/index/" } +dependencies = [ + { name = "coverage" }, + { name = "pluggy" }, + { name = "pytest" }, +] +sdist = { url = "http://10.0.0.2:5001/index/pytest-cov/pytest_cov-7.0.0.tar.gz", hash = "sha256:33c97eda2e049a0c5298e91f519302a1334c26ac65c1a483d6206fd458361af1" } +wheels = [ + { url = "http://10.0.0.2:5001/index/pytest-cov/pytest_cov-7.0.0-py3-none-any.whl", hash = "sha256:3b8e9558b16cc1479da72058bdecf8073661c7f57f7d3c5f22a1c23507f2d861" }, +] + [[package]] name = "python-utils" version = "0.1.0" @@ -598,6 +676,7 @@ dev = [ { name = "mypy" }, { name = "pre-commit" }, { name = "pytest" }, + { name = "pytest-cov" }, { name = "pyupgrade" }, { name = "ruff" }, { name = "safety" }, @@ -610,6 +689,7 @@ dev = [ { name = "mypy", specifier = ">=1.17.1" }, { name = "pre-commit", specifier = ">=4.3.0" }, { name = "pytest", specifier = ">=8.4.1" }, + { name = "pytest-cov", specifier = ">=7.0.0" }, { name = "pyupgrade", specifier = ">=3.20.0" }, { name = "ruff", specifier = ">=0.12.10" }, { name = "safety", specifier = ">=3.6.0" }, From c8891f2571e522237bd4b50785bf9d1ee7add54f Mon Sep 17 00:00:00 2001 From: Brian Bjarke Jensen Date: Sun, 14 Sep 2025 17:20:33 +0200 Subject: [PATCH 2/4] CI step to add test coverage as comment to PR --- .gitea/workflows/test.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 70f6ca0..4f756ee 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -26,7 +26,22 @@ jobs: UV_LINK_MODE: copy run: uv sync - - name: Run pytest + - name: Run pytest with coverage report env: PYTHONPATH: . - run: uv run pytest + run: uv run pytest --cov=python_utils --cov-report=term-missing > coverage.txt + + - name: Post coverage summary to PR + env: + BASEPAGE_URL: ${{ secrets.BASEPAGE_URL }} + REPO_OWNER: ${{ github.repository_owner }} + REPO_NAME: ${{ github.event.repository.name }} + PR_NUMBER: ${{ github.event.pull_request.number }} + CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }} + run: | + COVERAGE=$(cat coverage.txt) + COMMENT_BODY="**Test Coverage Report:**\n\`\`\`\n$COVERAGE\n\`\`\`" + curl -s -X POST "$BASEPAGE_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" \ + -H "Authorization: token $CI_RUNNER_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"body\": \"$COMMENT_BODY\"}" From 2efdebff58a1eaa51c6b1316fc026e42809b9b30 Mon Sep 17 00:00:00 2001 From: Brian Bjarke Jensen Date: Sun, 14 Sep 2025 17:22:57 +0200 Subject: [PATCH 3/4] updated env var --- .gitea/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 4f756ee..42e74a7 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -33,7 +33,7 @@ jobs: - name: Post coverage summary to PR env: - BASEPAGE_URL: ${{ secrets.BASEPAGE_URL }} + API_URL: ${{ secrets.API_URL }} REPO_OWNER: ${{ github.repository_owner }} REPO_NAME: ${{ github.event.repository.name }} PR_NUMBER: ${{ github.event.pull_request.number }} @@ -41,7 +41,7 @@ jobs: run: | COVERAGE=$(cat coverage.txt) COMMENT_BODY="**Test Coverage Report:**\n\`\`\`\n$COVERAGE\n\`\`\`" - curl -s -X POST "$BASEPAGE_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" \ + curl -s -X POST "$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$PR_NUMBER/comments" \ -H "Authorization: token $CI_RUNNER_TOKEN" \ -H "Content-Type: application/json" \ -d "{\"body\": \"$COMMENT_BODY\"}" From 832e4d572f76853899db921593f51c18673fe0e5 Mon Sep 17 00:00:00 2001 From: Brian Bjarke Jensen Date: Sun, 14 Sep 2025 17:26:22 +0200 Subject: [PATCH 4/4] corrected variable reference --- .gitea/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 42e74a7..43b66d7 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -33,7 +33,7 @@ jobs: - name: Post coverage summary to PR env: - API_URL: ${{ secrets.API_URL }} + API_URL: ${{ vars.API_URL }} REPO_OWNER: ${{ github.repository_owner }} REPO_NAME: ${{ github.event.repository.name }} PR_NUMBER: ${{ github.event.pull_request.number }}