Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Switch coverage to gcovr #403

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 16 additions & 19 deletions .github/workflows/step_coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ jobs:
with:
fetch-depth: 0
- uses: lukka/get-cmake@latest
- name: Get test coverage for ${{ matrix.coverage }}
- name: Run CMake workflow
uses: lukka/run-cmake@v10.3
with:
workflowPreset: "ci-coverage-${{ matrix.coverage }}"
- name: Get lcov data
uses: danielealbano/lcov-action@v3
with:
# Note lcov-action prepends and appends wild-cards *. Account for those
# https://github.com/danielealbano/lcov-action/issues/11
remove_patterns: /test/,/cmake-build*/
- name: Get coverage data
# TODO: Switch to tagged release
uses: threeal/gcovr-action@xml-out
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: ${{ matrix.coverage }} coverage
files: coverage.info
disable_search: true
plugin: noop
files: coverage-gcovr.xml
flags: ${{ matrix.coverage }}
verbose: true

Expand All @@ -52,27 +51,25 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Setup spglib
- name: Build spglib
run: |
python -m pip install --upgrade pip
pip install -e .[test-cov] \
--config-settings=cmake.define.CMAKE_C_COMPILER=gcc \
--config-settings=cmake.define.SPGLIB_WITH_TESTS=ON \
--config-settings=cmake.define.SPGLIB_TEST_COVERAGE=ON \
--config-settings=build-dir=build
--config-settings=build-dir=cmake-build-coverage
- name: Test pytest with coverage
run: pytest --cov=spglib
- name: Get lcov data
uses: danielealbano/lcov-action@v3
with:
# Note lcov-action prepends and appends wild-cards *. Account for those
# https://github.com/danielealbano/lcov-action/issues/11
remove_patterns: /test/,/cmake-build*/,/tmp/
run: pytest --cov --cov-report=xml:coverage-pytest.xml
- name: Get coverage data
# TODO: Switch to tagged release
uses: threeal/gcovr-action@xml-out
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: python_api coverage
files: coverage.info,.coverage
disable_search: true
plugin: noop
files: coverage-gcovr.xml,coverage-pytest.xml
flags: python_api
verbose: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ venv
env
.venv
.env

coverage.xml
36 changes: 23 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ dependencies = [
"importlib-resources; python_version<'3.10'",
]
authors = [
{name="Atsushi Togo", email="atz.togo@gmail.com"},
{ name = "Atsushi Togo", email = "atz.togo@gmail.com" },
]
maintainers = [
{name="Atsushi Togo", email="atz.togo@gmail.com"},
{name="Cristian Le", email="git@lecris.dev"},
{name="Kohei Shinohara", email="kshinohara0508@gmail.com"},
{ name = "Atsushi Togo", email = "atz.togo@gmail.com" },
{ name = "Cristian Le", email = "git@lecris.dev" },
{ name = "Kohei Shinohara", email = "kshinohara0508@gmail.com" },
]
classifiers = [
"Topic :: Scientific/Engineering :: Physics",
Expand Down Expand Up @@ -124,20 +124,20 @@ markers = [

[tool.coverage.run]
command_line = '-m pytest'
# TODO: Cannot report relative to project path because we cannot do editable installs yet
#source = ['python/spglib']
source = ['spglib']
source = [
"python/spglib",
]

[tool.ruff]
line-length = 88
extend-select = [
"F", # pyflakes
"F", # pyflakes
# "W", # pycodestyle-warnings
"E", # pycodestyle-errors
"E", # pycodestyle-errors
# "C90", # mccabe
"I", # isort
"I", # isort
# "N", # pep8-naming
"D", # pydocstyle
"D", # pydocstyle
# "UP", # pyupgrade
# "YTT", # flake8-2020
# "ANN", # flake8-annotations
Expand Down Expand Up @@ -184,9 +184,9 @@ extend-ignore = [
"D101",
"D102",
"D103",
"D203", # Confilct with D211
"D203", # Confilct with D211
"D205",
"D213", # Conflict with D212
"D213", # Conflict with D212
]
exclude = [
"database",
Expand All @@ -209,3 +209,13 @@ skip = "doc/references.bib"

[tool.check-wheel-contents]
ignore = "W002"

[tool.gcovr]
cobertura = "coverage-gcovr.xml"
exclude = [
"src/msg_database.c",
"src/spg_database.c",
]
gcov-ignore-errors = [
"source_not_found",
]