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

Test Coverage and CI improvements #72

Merged
merged 12 commits into from
Mar 4, 2024
64 changes: 64 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Testing Suite

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read

jobs:
build:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip and install coveralls
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade coveralls
- name: Install Package (editable)
run: |
python -m pip install -e ".[dev]"
- name: Check versions
run: |
python -m pip list
python -m pip check
- name: Test with pytest
run: |
pytest
coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-{{ matrix.python-version }}
COVERALLS_PARALLEL: true
COVERALLS_SERVICE_NAME: github

finish:
name: Coveralls Report
needs:
- build
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Report to Coveralls
run: |
python -m pip install --upgrade coveralls
python -m coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: github
36 changes: 0 additions & 36 deletions .github/workflows/python-app.yml

This file was deleted.

11 changes: 7 additions & 4 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ name: Upload Python Package

on:
release:
types: [published]
types:
- published

permissions:
contents: read

jobs:
deploy:

name: Publish (PyPI)
runs-on: ubuntu-latest

# We should be making use of deployment environments for this job
# https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand All @@ -31,7 +33,8 @@ jobs:
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
run: |
python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
0.5.0 (unreleased)
==================

- Added support for running `pytest` with `pytest-cov`. By @Zeitsperre
- Reworked the GitHub CI testing workflow to perform version checks as well as tests with `pytest-cov` . By @Zeitsperre

Breaking changes
^^^^^^^^^^^^^^^^

- Nested group handling:
Before this version, all groups were read, but conflicting variable names in-between groups would shadow data. Now, similarly to xarray ``open_dataset``, ``open_ncml`` accepts an optional ``group`` argument to specify which group should be read. When ``group`` is not specified, it defaults to the root group. Additionally ``group`` can be set to ``'*'`` so that every group is read and the hierarchy is flattened. In the event of conflicting variable/dimension names across groups, the conflicting name will be modified by appending ``'__n'`` where n is incremented.
- Enums are no longer transformed into CF flag_values and flag_meanings attributes, instead they are stored in the ``encoding["dtype"].metadata`` of their respective variable. This is aligned with what is done on xarray v2024.01.0
Expand Down
5 changes: 5 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage
flake8
pre-commit
pytest
pytest-cov
6 changes: 5 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[wheel]
universal = 1


[flake8]
exclude = docs
ignore = E203,E266,E501,W503,F401,E722,E402,C901
Expand All @@ -20,3 +19,8 @@ line_length=100
skip=
docs/source/conf.py
setup.py

[tool:pytest]
addopts = --cov=xncml --cov-report term-missing
omit = tests/*
testpaths = tests
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
else:
install_requires = ['xmltodict', 'xsdata', 'xarray']

if os.path.exists('requirements-dev.txt'):
with open('requirements-dev.txt') as f:
dev_install_requires = f.read().strip().split('\n')

if os.path.exists('README.md'):
with open('README.md') as f:
long_description = f.read()
Expand All @@ -37,6 +41,6 @@
python_requires='>=3.9, <4',
setup_requires=['setuptools_scm', 'setuptools>=30.3.0', 'setuptools_scm_git_archive'],
extras_require={
'dev': ['pytest', 'flake8'],
'dev': dev_install_requires,
},
)
Loading