Skip to content

Commit 6748067

Browse files
authored
CI: Initial code coverage configuration with Codecov (#3905)
1 parent ab79e43 commit 6748067

File tree

4 files changed

+139
-5
lines changed

4 files changed

+139
-5
lines changed

.github/workflows/pytest.yml

+14-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
python -m pip install --upgrade pip
5454
pip install -r .github/workflows/python_requirements.txt
5555
pip install -r .github/workflows/optional_requirements.txt
56-
pip install pytest pytest-timeout pytest-github-actions-annotate-failures pytest-xdist
56+
pip install pytest pytest-timeout pytest-github-actions-annotate-failures pytest-xdist pytest-cov
5757
5858
- name: Create installation directory
5959
run: |
@@ -70,6 +70,10 @@ jobs:
7070
run: |
7171
echo "$HOME/install/bin" >> $GITHUB_PATH
7272
73+
- name: Print installed versions
74+
if: always()
75+
run: .github/workflows/print_versions.sh
76+
7377
- name: Test executing of the grass command
7478
run: .github/workflows/test_simple.sh
7579

@@ -86,12 +90,18 @@ jobs:
8690
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
8791
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
8892
pytest --verbose --color=yes --durations=0 --durations-min=0.5 \
93+
--cov \
8994
-ra . \
9095
-m 'needs_solo_run'
9196
92-
- name: Print installed versions
93-
if: always()
94-
run: .github/workflows/print_versions.sh
97+
- name: Upload coverage reports to Codecov
98+
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
99+
with:
100+
verbose: true
101+
flags: pytest-python-${{ matrix.python-version }}
102+
name: pytest-python-${{ matrix.python-version }}
103+
token: ${{ secrets.CODECOV_TOKEN }}
104+
95105
pytest-success:
96106
name: pytest Result
97107
needs:

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@ html/
5959
latex/
6060
lib/*/html/
6161
lib/*/latex/
62+
63+
# Ignore code coverage files
64+
*.gcov
65+
*.gcno
66+
*.gcda
67+
.coverage

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,15 @@ cleandistdirs:
115115
cleanscriptstrings:
116116
rm -f locale/scriptstrings/*.c 2>/dev/null
117117

118-
clean: cleandistdirs cleanscriptstrings cleandocs
118+
clean: cleandistdirs cleanscriptstrings cleandocs code-coverage-clean
119119

120120
libsclean: cleandistdirs
121121
$(MAKE) clean-recursive SUBDIRS=$(LIBDIRS)
122122

123+
code-coverage-clean:
124+
-find . -type f \( -name "*.gcda" -o -name "*.gcno" -o -name "*.gcov" \) -delete
125+
-rm -f .coverage
126+
123127
distclean: clean
124128
-rm -f config.cache config.log config.status config.status.$(ARCH) 2>/dev/null
125129
-rm -f ChangeLog ChangeLog.bak $(ERRORLOG) grass.pc

codecov.yml

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
# When modifying this file, please validate using
3+
# curl -X POST --data-binary @codecov.yml https://codecov.io/validate
4+
5+
coverage:
6+
status:
7+
project:
8+
default:
9+
target: auto # auto compares coverage to the previous base commit
10+
informational: true
11+
patch:
12+
default:
13+
informational: true
14+
15+
# Disable PR comments initially, until it is possible to have the information as a job summary
16+
comment: false
17+
18+
github_checks:
19+
# Until more tests are added, disable GitHub checks annotation when added lines aren't covered by tests
20+
annotations: false
21+
22+
component_management:
23+
individual_components:
24+
- component_id: modules_database # this is an identifier that should not be changed
25+
name: db # this is a display name, and can be changed freely
26+
paths:
27+
- db/**
28+
- lib/db/**
29+
- scripts/db.*/**
30+
- component_id: modules_display
31+
name: display
32+
paths:
33+
- display/**
34+
- lib/display/**
35+
- scripts/d.*/**
36+
- component_id: modules_general
37+
name: general
38+
paths:
39+
- general/**
40+
- scripts/g.*/**
41+
- component_id: gui
42+
name: gui
43+
paths:
44+
- gui/**
45+
- component_id: modules_imagery
46+
name: imagery
47+
paths:
48+
- imagery/**
49+
- lib/imagery/**
50+
- scripts/i.*/**
51+
- component_id: man
52+
name: man
53+
paths:
54+
- man/**
55+
- component_id: modules_misc
56+
name: imagery
57+
paths:
58+
- misc/**
59+
- scripts/m.*/**
60+
- component_id: modules_postscript
61+
name: ps
62+
paths:
63+
- ps/**
64+
- component_id: modules_raster
65+
name: raster
66+
paths:
67+
- raster/**
68+
- lib/raster/**
69+
- scripts/r.*/**
70+
- component_id: modules_raster3d
71+
name: raster3d
72+
paths:
73+
- raster3d/**
74+
- lib/raster3d/**
75+
- scripts/r3.*/**
76+
- component_id: modules_temporal
77+
name: temporal
78+
paths:
79+
- temporal/**
80+
- lib/temporal/**
81+
- scripts/t.*/**
82+
- component_id: modules_vector
83+
name: vector
84+
paths:
85+
- vector/**
86+
- lib/vector/**
87+
- scripts/v.*/**
88+
- component_id: utils
89+
paths:
90+
- utils/**
91+
- component_id: scripts
92+
paths:
93+
- scripts/**
94+
- component_id: library
95+
name: lib
96+
paths:
97+
- lib/**
98+
- component_id: python_pygrass
99+
name: pygrass
100+
paths:
101+
- python/grass/pygrass/**
102+
- component_id: python_gunittest
103+
name: gunittest
104+
paths:
105+
- python/grass/gunittest/**
106+
- component_id: notebooks
107+
name: notebooks (jupyter)
108+
paths:
109+
- python/grass/jupyter/**
110+
- "**/*.ipynb"
111+
- component_id: python_library
112+
name: python library
113+
paths:
114+
- python/grass/**

0 commit comments

Comments
 (0)