Skip to content

Commit 3585a73

Browse files
committed
project: Add CodeCov reporting
Add a Github workflow and configuration file for CodeCov. Create more visibility about the coverage in PRs. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent 2115fa9 commit 3585a73

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed

.codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Let CodeCov post a comment in PRs for the coverage of changes.
2+
3+
comment:
4+
layout: "reach, diff, flags, files"
5+
behavior: default
6+
require_changes: false
7+
require_base: false
8+
require_head: true
9+
hide_project_coverage: false
10+
branches:
11+
- "main"

.github/workflows/test.yml

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jobs:
1414
os: [ubuntu-latest, macos-latest, windows-latest]
1515
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1616
steps:
17-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
- name: Checkout
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1819
# This is enough to find many quoting issues
1920
with:
2021
path: "./check out"
@@ -23,9 +24,55 @@ jobs:
2324
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
2425
with:
2526
python-version: ${{ matrix.python-version }}
27+
2628
- name: Display Python version
2729
run: python -c "import sys; print(sys.version); print(sys.platform)"
28-
- name: install tox
30+
31+
- name: Install tox
2932
run: pip3 install tox
30-
- name: tox
33+
34+
- name: Run tox
3135
run: tox -c 'check out' -- -W error
36+
37+
- name: Upload coverage reports
38+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
39+
with:
40+
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
41+
path: "./check out/.coverage"
42+
include-hidden-files: true
43+
44+
coverage-report:
45+
runs-on: ubuntu-latest
46+
needs: ["build"]
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
50+
51+
- name: Set up Python
52+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
53+
with:
54+
python-version: '3.13'
55+
56+
- name: Download all coverage artifacts
57+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
58+
59+
- name: Install coverage
60+
run: pip3 install coverage
61+
62+
- name: Create coverage report
63+
run: |
64+
coverage combine coverage-*/.coverage
65+
coverage xml
66+
67+
- name: Upload combined coverage report
68+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
69+
with:
70+
name: coverage-combined
71+
path: coverage.xml
72+
73+
- name: Upload coverage to Codecov
74+
if: github.repository_owner == 'zephyrproject-rtos'
75+
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
76+
with:
77+
token: ${{ secrets.CODECOV_TOKEN }}
78+
slug: ${{ github.repository_owner }}/west

pyproject.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ include-package-data = true
4545
where = ["src"]
4646
namespaces = false
4747

48+
[tool.coverage.run]
49+
relative_files = true
50+
omit = [
51+
"*/tmp/*",
52+
]
53+
54+
[tool.coverage.report]
55+
omit = [
56+
"*/tmp/*",
57+
]
58+
59+
[tool.coverage.paths]
60+
source = [
61+
"src/west",
62+
"*/site-packages/west",
63+
"*/src/west",
64+
]
65+
4866
[tool.ruff]
4967
line-length = 100
5068

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ setenv =
3838
# For instance: ./.tox/py3/tmp/
3939
TOXTEMPDIR={envtmpdir}
4040
commands =
41-
python -m pytest --cov-report=html --cov=west {posargs:tests} --basetemp='{envtmpdir}/pytest with space/'
41+
python -m pytest --cov-report=html --cov-config=pyproject.toml --cov=west {posargs:tests} --basetemp='{envtmpdir}/pytest with space/'
4242
python -m flake8 --config='{toxinidir}'/tox.ini '{toxinidir}'
4343
python -m ruff check '{toxinidir}'
4444
python -m mypy --config-file='{toxinidir}'/tox.ini --package=west

0 commit comments

Comments
 (0)