From 23a2e14f1cba625ba92376ba1581c4892a8b31a2 Mon Sep 17 00:00:00 2001 From: nucccc Date: Sun, 1 Jun 2025 14:09:56 +0200 Subject: [PATCH 1/7] set up coverage file --- .coveragerc | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..2e7b2d4 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,4 @@ +[coverage:run] +relative_files = true +omit = + tests/* \ No newline at end of file From 43a43599b65b21dd8dc389e68e9e6e265e48de9e Mon Sep 17 00:00:00 2001 From: nucccc Date: Mon, 30 Jun 2025 21:25:28 +0200 Subject: [PATCH 2/7] tried to write coverage workflow --- .github/workflows/.cov.yml | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/.cov.yml diff --git a/.github/workflows/.cov.yml b/.github/workflows/.cov.yml new file mode 100644 index 0000000..8abe037 --- /dev/null +++ b/.github/workflows/.cov.yml @@ -0,0 +1,45 @@ +name: + cov + +on: + push + +jobs: + cov-job: + runs-on: ubuntu-latest + name: checking coverage + permissions: + pull-requests: write + contents: write + steps: + - uses: actions/checkout@v3 + + - name: set up python + id: setup-python + uses: actions/setup-python@v4 + with: + python-version: 3 + + - name: syncing uv + run: uv sync --all-extras + + - name: activating uv venv + run: source .venv/bin/activate + + - name: launching coverage + run: coverage run -m pytest + + - name: cov_comment + id: coverage_comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ github.token }} + + - name: Store Pull Request comment to be posted + uses: actions/upload-artifact@v3 + if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' + with: + # If you use a different name, update COMMENT_ARTIFACT_NAME accordingly + name: python-coverage-comment-action + # If you use a different name, update COMMENT_FILENAME accordingly + path: python-coverage-comment-action.txt \ No newline at end of file From 7ebf9b07d5584a7654ccc19e01ebc6d814063456 Mon Sep 17 00:00:00 2001 From: nucccc Date: Mon, 30 Jun 2025 21:28:01 +0200 Subject: [PATCH 3/7] update to v4 update action version --- .github/workflows/.cov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/.cov.yml b/.github/workflows/.cov.yml index 8abe037..1e4f6a3 100644 --- a/.github/workflows/.cov.yml +++ b/.github/workflows/.cov.yml @@ -36,7 +36,7 @@ jobs: GITHUB_TOKEN: ${{ github.token }} - name: Store Pull Request comment to be posted - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' with: # If you use a different name, update COMMENT_ARTIFACT_NAME accordingly From 5b5e599f54d68f9a091c61b0f24f4facd3ff56b1 Mon Sep 17 00:00:00 2001 From: nucccc Date: Mon, 30 Jun 2025 21:29:58 +0200 Subject: [PATCH 4/7] adding step to install uv --- .github/workflows/.cov.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/.cov.yml b/.github/workflows/.cov.yml index 1e4f6a3..fba4df8 100644 --- a/.github/workflows/.cov.yml +++ b/.github/workflows/.cov.yml @@ -20,6 +20,9 @@ jobs: with: python-version: 3 + - name: installing uv + run: pip install uv + - name: syncing uv run: uv sync --all-extras From 49ee0b0c1fc297831e26ac591b75a7e45d89da2f Mon Sep 17 00:00:00 2001 From: nucccc Date: Mon, 30 Jun 2025 21:33:31 +0200 Subject: [PATCH 5/7] activating .venv and launching coverage in the same command --- .github/workflows/.cov.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/.cov.yml b/.github/workflows/.cov.yml index fba4df8..ef3b11b 100644 --- a/.github/workflows/.cov.yml +++ b/.github/workflows/.cov.yml @@ -27,10 +27,10 @@ jobs: run: uv sync --all-extras - name: activating uv venv - run: source .venv/bin/activate + run: source .venv/bin/activate && coverage run -m pytest - - name: launching coverage - run: coverage run -m pytest +# - name: launching coverage +# run: coverage run -m pytest - name: cov_comment id: coverage_comment From f6097781dd1e27fd2905a36160b16ce1f56d8e7a Mon Sep 17 00:00:00 2001 From: nucccc Date: Mon, 30 Jun 2025 21:35:42 +0200 Subject: [PATCH 6/7] adding coverage badge to readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fadc3a7..61e1936 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # sqlmodelgen +![Coverage badge](https://raw.githubusercontent.com/nucccc/sqlmodelgen/python-coverage-comment-action-data/badge.svg) + `sqlmodelgen` is a library to generate models for the **sqlmodel** library ([repo](https://github.com/fastapi/sqlmodel), [official docs](https://sqlmodel.tiangolo.com/)). It accepts in input the following sources: From 5a501b2e4ef5f966b1c4b52be93df03edf6d4c80 Mon Sep 17 00:00:00 2001 From: nucccc Date: Mon, 30 Jun 2025 21:40:18 +0200 Subject: [PATCH 7/7] set minimum green threshold --- .github/workflows/.cov.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/.cov.yml b/.github/workflows/.cov.yml index ef3b11b..d8a54b7 100644 --- a/.github/workflows/.cov.yml +++ b/.github/workflows/.cov.yml @@ -37,6 +37,7 @@ jobs: uses: py-cov-action/python-coverage-comment-action@v3 with: GITHUB_TOKEN: ${{ github.token }} + MINIMUM_GREEN: 90 - name: Store Pull Request comment to be posted uses: actions/upload-artifact@v4