Skip to content

Commit

Permalink
chore: add coverage report
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaakola-aiven committed Jun 12, 2024
1 parent de5d51f commit a9de5a3
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
branch = True
relative_files = True
source = karapace
46 changes: 44 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,11 +38,52 @@ jobs:

- run: make install version
- run: make unit-tests
- run: make integration-tests PYTEST_ARGS="--random-order"
env:
COVERAGE_FILE: ".coverage.${{ matrix.python-version }}"
PYTEST_ARGS: "--cov=karapace --cov-append"
#- run: make integration-tests-coverage PYTEST_ARGS="--random-order"
# env:
# COVERAGE_FILE: ".coverage.${{ matrix.python-version }}"

- name: Archive logs
uses: actions/upload-artifact@v4
if: ${{ always() }}
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: coverage-*
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
8 changes: 8 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pdbpp
# testing
filelock
pytest
pytest-cov
pytest-xdist[psutil]
pytest-timeout
pytest-random-order
Expand Down
6 changes: 6 additions & 0 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ configargparse==1.7
# via locust
confluent-kafka==2.3.0
# via -r requirements.txt
coverage[toml]==7.5.3
# via pytest-cov
cramjam==2.8.3
# via
# -r requirements.txt
Expand Down Expand Up @@ -176,9 +178,12 @@ pyrepl==0.9.0
pytest==8.2.2
# via
# -r requirements-dev.in
# pytest-cov
# pytest-random-order
# pytest-timeout
# pytest-xdist
pytest-cov==5.0.0
# via -r requirements-dev.in
pytest-random-order==1.1.1
# via -r requirements-dev.in
pytest-timeout==2.3.1
Expand Down Expand Up @@ -227,6 +232,7 @@ tenacity==8.3.0
# via -r requirements.txt
tomli==2.0.1
# via
# coverage
# locust
# pytest
typing-extensions==4.12.1
Expand Down

0 comments on commit a9de5a3

Please sign in to comment.