Skip to content

Commit

Permalink
Fix GitHub actions and docs generation (#10)
Browse files Browse the repository at this point in the history
* Fix GitHub workflows and docs generation

* Remove superfluous workflows yml

* Update pyproject.toml

* Remove docs/requirements.txt, adapt github/workflows/build.yml

* Adapt setup.py

* Adapt setup.cfg metadata fields to hold underscore-separated fields

* Add path to .readthedocs.yml

* Adapt docs/conf.py

* Add setuptools and wheel to build.yml, remove specific python version from .readthedocs.yml

* Fix typo in env.yml, adapt setup.cfg

* Bugfix setup.cfg

* Update pyproject.toml, remove .travis.yml, update Automated Tests badge link
  • Loading branch information
daberer authored Jan 27, 2025
1 parent cabada5 commit 8ba123f
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 122 deletions.
48 changes: 30 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ name: Automated Tests
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: "0 11 * * 1" # Every Monday at 11 UTC
- cron: "0 9 * * 1" # Every Monday at 9 UTC

jobs:
build:
Expand All @@ -25,33 +26,32 @@ jobs:
with:
submodules: true
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v2.0.1
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channel-priority: flexible
environment-file: environment.yml
activate-environment: flagit
auto-activate-base: false
- name: Print environment infos
shell: bash -l {0}
run: |
conda info -a
conda list
pip list
which pip
which python
- name: Export Environment
- name: Install base package and run tests
shell: bash -l {0}
run: |
mkdir -p .artifacts
filename=env_py${{ matrix.python-version }}_${{ matrix.os }}.yml
conda env export --no-builds | grep -v "prefix" > .artifacts/$filename
- name: Install package and test
pip install -e .[testing]
pytest # run only basic tests, see setup.cfg
- name: Export Environment
shell: bash -l {0}
run: |
pip install .
pytest
mkdir -p artifacts
filename=env_py${{ matrix.python-version }}_${{ matrix.os }}.yml
conda env export --no-builds | grep -v "prefix" > artifacts/$filename
- name: Upload Coverage
shell: bash -l {0}
run: |
Expand All @@ -63,15 +63,23 @@ jobs:
- name: Create wheel and dist package
shell: bash -l {0}
run: |
pip install setuptools_scm
# build dist on linux
python setup.py sdist --dist-dir .artifacts/dist
ls .artifacts/dist
pip install setuptools setuptools_scm wheel
# Create source distribution (sdist) and wheel distribution
python setup.py sdist --dist-dir artifacts/dist
python setup.py bdist_wheel --dist-dir artifacts/dist
# Verify the contents of the artifacts directory
ls artifacts/dist
# Validate the built distribution files
pip install twine
twine check artifacts/dist/*
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: .artifacts/*
name: Artifacts-py${{ matrix.python-version }}-${{ matrix.os }}
path: artifacts/*
coveralls:
name: Submit Coveralls 👚
needs: build
Expand All @@ -95,6 +103,10 @@ jobs:
echo "GITHUB_REPOSITORY = $GITHUB_REPOSITORY"
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: Artifacts
pattern: Artifacts-*
merge-multiple: true
- name: Display downloaded files
run: ls -aR
- name: Upload to PyPI
Expand All @@ -105,4 +117,4 @@ jobs:
verify_metadata: true
packages_dir: Artifacts/dist/
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }} # this needs to be uploaded to github actions secrets
password: ${{ secrets.PYPI_API_TOKEN }} # this needs to be uploaded to github actions secrets
19 changes: 12 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
version: 2

sphinx:
configuration: docs/conf.py

formats:
- pdf
build:
os: ubuntu-20.04
tools:
python: mambaforge-4.10

python:
version: 3.7
install:
- requirements: docs/requirements.txt
- method: pip
path: .

sphinx:
configuration: docs/conf.py

conda:
environment: docs/env.yml
57 changes: 0 additions & 57 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Contributors
* Daniel Aberer <[email protected]>
* Angelika Xaver <[email protected]>
* Wolfgang Preimesberger <[email protected]>
* Kasjen Kramer <[email protected]>
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ Version 0.2
- Adapt code for internal use
- Bugfix D06 rolling mean calculation
- Bugfix case of multiple precipitation sensors

Version 0.3
===========

- Detect ancillary column
- Fix automated tests and docs
- Use list as only optional input to specify flag procedures
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
flagit
======

.. image:: https://github.com/TUW-GEO/flagit/workflows/Automated%20Tests/badge.svg?branch=main
.. image:: https://github.com/TUW-GEO/flagit/actions/workflows/build.yml/badge.svg?branch=main
:target: https://github.com/TUW-GEO/flagit/actions

.. image:: https://coveralls.io/repos/github/TUW-GEO/flagit/badge.svg?branch=main
Expand Down
48 changes: 31 additions & 17 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
import inspect
import shutil

__location__ = os.path.join(os.getcwd(), os.path.dirname(
inspect.getfile(inspect.currentframe())))
__location__ = os.path.join(
os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe()))
)

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -43,30 +44,42 @@

try:
import sphinx
from pkg_resources import parse_version

cmd_line_template = "sphinx-apidoc -f -o {outputdir} {moduledir}"

cmd_line_template = (
"sphinx-apidoc --implicit-namespaces -f -o {outputdir} {moduledir}"
)
cmd_line = cmd_line_template.format(outputdir=output_dir, moduledir=module_dir)

args = cmd_line.split(" ")
if parse_version(sphinx.__version__) >= parse_version('1.7'):
if tuple(sphinx.__version__.split(".")) >= ("1", "7"):
# This is a rudimentary parse_version to avoid external dependencies
args = args[1:]

apidoc.main(args)
except Exception as e:
print("Running `sphinx-apidoc` failed!\n{}".format(e))

# -- General configuration -----------------------------------------------------
# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo',
'sphinx.ext.autosummary', 'sphinx.ext.viewcode', 'sphinx.ext.coverage',
'sphinx.ext.doctest', 'sphinx.ext.ifconfig', 'sphinx.ext.mathjax',
'sphinx.ext.napoleon']
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.ifconfig",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"nbsphinx",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -262,11 +275,12 @@
# -- External mapping ------------------------------------------------------------
python_version = '.'.join(map(str, sys.version_info[0:2]))
intersphinx_mapping = {
'sphinx': ('http://www.sphinx-doc.org/en/stable', None),
'python': ('https://docs.python.org/' + python_version, None),
'matplotlib': ('https://matplotlib.org', None),
'numpy': ('https://docs.scipy.org/doc/numpy', None),
'sklearn': ('http://scikit-learn.org/stable', None),
'pandas': ('http://pandas.pydata.org/pandas-docs/stable', None),
'scipy': ('https://docs.scipy.org/doc/scipy/reference', None),
"sphinx": ("http://www.sphinx-doc.org/en/stable", None),
"python": ("https://docs.python.org/" + python_version, None),
"matplotlib": ("https://matplotlib.org", None),
"numpy": ("https://docs.scipy.org/doc/numpy", None),
"sklearn": ("https://scikit-learn.org/stable", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
"scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
"pyscaffold": ("https://pyscaffold.org/en/stable", None),
}
17 changes: 17 additions & 0 deletions docs/env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To keep the RTD build as small as possible, we define a separate .yml here
name: docs
channels:
- conda-forge
- defaults
dependencies:
- python=3.10
- ipykernel
- nbsphinx
- mock
- pillow
- sphinx<7
- sphinx_rtd_theme
- pip
- pip:
- recommonmark
- readthedocs-sphinx-ext
1 change: 0 additions & 1 deletion docs/requirements.txt

This file was deleted.

11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
[build-system]
# AVOID CHANGING REQUIRES: IT WILL BE UPDATED BY PYSCAFFOLD!
requires = ["setuptools>=46.1.0", "setuptools_scm[toml]>=5", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
version_scheme = "no-guess-dev"

[tool.pytest.ini_options]
pythonpath = ["src"]
pythonpath = ["src"]
addopts = "--cov=flagit --cov-report=term-missing --verbose"
Loading

0 comments on commit 8ba123f

Please sign in to comment.