From 8b613cafea032478a5773fd666f9bb4e7b316948 Mon Sep 17 00:00:00 2001 From: Jarkko Jaakola Date: Tue, 11 Jun 2024 14:15:04 +0300 Subject: [PATCH] chore: add coverage report --- .github/workflows/tests.yml | 47 ++++++++++++++++++++++++++++++++++--- GNUmakefile | 8 +++++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d376a1e19..ff0ab7369 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.8', '3.9', '3.10', '3.11' ] + #python-version: [ '3.8', '3.9', '3.10', '3.11' ] + python-version: [ '3.10', '3.11'] env: PYTEST_ADDOPTS: >- --log-dir=/tmp/ci-logs @@ -36,8 +37,12 @@ jobs: python-version: ${{ matrix.python-version }} - run: make install version - - run: make unit-tests - - run: make integration-tests PYTEST_ARGS="--random-order" + - run: make unit-tests-coverage + env: + COVERAGE_FILE: ".coverage.${{ matrix.python_version }}" + - run: make integration-tests-coverage PYTEST_ARGS="--random-order" + env: + COVERAGE_FILE: ".coverage.${{ matrix.python_version }}" - name: Archive logs uses: actions/upload-artifact@v4 @@ -45,3 +50,39 @@ jobs: with: name: karapace-integration-test-logs-${{ matrix.python-version }} path: /tmp/ci-logs + - name: Archive coverage file + uses: actions/upload-artifact@v4 + with: + name: coverage-${{ matrix.python_version }} + path: .coverage.${{ matrix.python_version }} + + coverage: + name: Coverage report + runs-on: ubuntu-latest + needs: tests + permissions: + pull-requests: write + contents: write + steps: + - uses: actions/checkout@v4 + + - name: Download coverage + id: download_coverage + uses: actions/download-artifact@v4 + with: + pattern: coverate-* + merge-multiple: true + + - name: Post coverage comment + id: post_coverage_comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MERGE_COVERAGE_FILES: true + + - name: Store PR coment to be posted + uses: actions/upload-artifact@v4 + if: steps.post_coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' + with: + name: python-coverage-comment-action + path: python-coverage-comment-action.txt diff --git a/GNUmakefile b/GNUmakefile index 9d5c53a06..aea5c49e5 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -69,6 +69,14 @@ integration-tests: karapace/version.py venv/.deps $(PYTHON) -m pytest -s -vvv $(PYTEST_ARGS) tests/integration/ rm -fr runtime/* +.PHONY: unit-tests-coverage +unit-tests-coverage: + $(MAKE) PYTEST_ARGS="--cov=karapace --cov-append" unit-tests + +.PHONY: integration-tests-coverage +integration-tests-coverage: + $(MAKE) PYTEST_ARGS="--cov=karapace --cov-append" integration-tests + .PHONY: clean clean: rm -fr ./kafka_* ./*.egg-info/ ./dist/ ./karapace/version.py