Skip to content

Commit

Permalink
CI: Initial code coverage configuration with Codecov (OSGeo#3905)
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored Jun 27, 2024
1 parent ab79e43 commit 6748067
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 5 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
python -m pip install --upgrade pip
pip install -r .github/workflows/python_requirements.txt
pip install -r .github/workflows/optional_requirements.txt
pip install pytest pytest-timeout pytest-github-actions-annotate-failures pytest-xdist
pip install pytest pytest-timeout pytest-github-actions-annotate-failures pytest-xdist pytest-cov
- name: Create installation directory
run: |
Expand All @@ -70,6 +70,10 @@ jobs:
run: |
echo "$HOME/install/bin" >> $GITHUB_PATH
- name: Print installed versions
if: always()
run: .github/workflows/print_versions.sh

- name: Test executing of the grass command
run: .github/workflows/test_simple.sh

Expand All @@ -86,12 +90,18 @@ jobs:
export PYTHONPATH=`grass --config python_path`:$PYTHONPATH
export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH
pytest --verbose --color=yes --durations=0 --durations-min=0.5 \
--cov \
-ra . \
-m 'needs_solo_run'
- name: Print installed versions
if: always()
run: .github/workflows/print_versions.sh
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
verbose: true
flags: pytest-python-${{ matrix.python-version }}
name: pytest-python-${{ matrix.python-version }}
token: ${{ secrets.CODECOV_TOKEN }}

pytest-success:
name: pytest Result
needs:
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,9 @@ html/
latex/
lib/*/html/
lib/*/latex/

# Ignore code coverage files
*.gcov
*.gcno
*.gcda
.coverage
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,15 @@ cleandistdirs:
cleanscriptstrings:
rm -f locale/scriptstrings/*.c 2>/dev/null

clean: cleandistdirs cleanscriptstrings cleandocs
clean: cleandistdirs cleanscriptstrings cleandocs code-coverage-clean

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

code-coverage-clean:
-find . -type f \( -name "*.gcda" -o -name "*.gcno" -o -name "*.gcov" \) -delete
-rm -f .coverage

distclean: clean
-rm -f config.cache config.log config.status config.status.$(ARCH) 2>/dev/null
-rm -f ChangeLog ChangeLog.bak $(ERRORLOG) grass.pc
Expand Down
114 changes: 114 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
# When modifying this file, please validate using
# curl -X POST --data-binary @codecov.yml https://codecov.io/validate

coverage:
status:
project:
default:
target: auto # auto compares coverage to the previous base commit
informational: true
patch:
default:
informational: true

# Disable PR comments initially, until it is possible to have the information as a job summary
comment: false

github_checks:
# Until more tests are added, disable GitHub checks annotation when added lines aren't covered by tests
annotations: false

component_management:
individual_components:
- component_id: modules_database # this is an identifier that should not be changed
name: db # this is a display name, and can be changed freely
paths:
- db/**
- lib/db/**
- scripts/db.*/**
- component_id: modules_display
name: display
paths:
- display/**
- lib/display/**
- scripts/d.*/**
- component_id: modules_general
name: general
paths:
- general/**
- scripts/g.*/**
- component_id: gui
name: gui
paths:
- gui/**
- component_id: modules_imagery
name: imagery
paths:
- imagery/**
- lib/imagery/**
- scripts/i.*/**
- component_id: man
name: man
paths:
- man/**
- component_id: modules_misc
name: imagery
paths:
- misc/**
- scripts/m.*/**
- component_id: modules_postscript
name: ps
paths:
- ps/**
- component_id: modules_raster
name: raster
paths:
- raster/**
- lib/raster/**
- scripts/r.*/**
- component_id: modules_raster3d
name: raster3d
paths:
- raster3d/**
- lib/raster3d/**
- scripts/r3.*/**
- component_id: modules_temporal
name: temporal
paths:
- temporal/**
- lib/temporal/**
- scripts/t.*/**
- component_id: modules_vector
name: vector
paths:
- vector/**
- lib/vector/**
- scripts/v.*/**
- component_id: utils
paths:
- utils/**
- component_id: scripts
paths:
- scripts/**
- component_id: library
name: lib
paths:
- lib/**
- component_id: python_pygrass
name: pygrass
paths:
- python/grass/pygrass/**
- component_id: python_gunittest
name: gunittest
paths:
- python/grass/gunittest/**
- component_id: notebooks
name: notebooks (jupyter)
paths:
- python/grass/jupyter/**
- "**/*.ipynb"
- component_id: python_library
name: python library
paths:
- python/grass/**

0 comments on commit 6748067

Please sign in to comment.