Skip to content

Commit

Permalink
Update testing and docs
Browse files Browse the repository at this point in the history
First steps towards #1203
  • Loading branch information
cthoyt committed Oct 17, 2024
1 parent 8d07ce2 commit 740a761
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 53 deletions.
70 changes: 34 additions & 36 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file configures the continuous integration (CI) system on GitHub.
# Introductory materials can be found here: https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions.
# Documentation for editing this file can be found here: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

name: Tests

on:
Expand All @@ -8,49 +12,48 @@ on:

jobs:
lint:
name: Lint
name: Code Quality
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.12", "3.9" ]
tox-command: ["manifest", "lint", "pyroma", "mypy"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: "Install uv"
uses: "astral-sh/setup-uv@v3"
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: "Run command"
run: |
pip install tox tox-uv
- name: Check manifest
run: tox -e manifest
- name: Check code quality with flake8
run: tox -e flake8
- name: Check package metadata with Pyroma
run: tox -e pyroma
- name: Check static typing with MyPy
run: tox -e mypy
uvx -p ${{ matrix.python-version }} --with tox-uv tox -e ${{ matrix.tox-command }}
docs:
name: Documentation
runs-on: ubuntu-latest
strategy:
matrix:
# We only test documentation on the latest version
# sphinx 8.0 / sphinx-rtd-theme 3.0 discontinued Python 3.9 support
# a year early, which prompted re-thinking about this.
python-version: [ "3.12" ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: "Install uv"
uses: "astral-sh/setup-uv@v3"
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Install dependencies
run: |
pip install tox tox-uv
sudo apt-get install graphviz
- name: Check RST conformity with doc8
run: tox -e doc8
run: uvx -p ${{ matrix.python-version }} --with tox-uv tox -e doc8
- name: Check docstring coverage
run: tox -e docstr-coverage
run: uvx -p ${{ matrix.python-version }} --with tox-uv tox -e docstr-coverage
- name: Check documentation build with Sphinx
run: tox -e docs-test
run: uvx -p ${{ matrix.python-version }} --with tox-uv tox -e docs-test
tests:
name: Tests
runs-on: ${{ matrix.os }}
Expand All @@ -60,22 +63,17 @@ jobs:
python-version: [ "3.12", "3.9" ]
pydantic: [ "pydantic1", "pydantic2" ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: "Install uv"
uses: "astral-sh/setup-uv@v3"
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install tox tox-uv
- name: Test with pytest
run:
tox -e py-${{ matrix.pydantic }}
- name: Doctests
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Test with pytest and generate coverage file
run:
tox -e doctests
uvx -p ${{ matrix.python-version }} --with tox-uv tox -e py-${{ matrix.pydantic }}
- name: Upload coverage report to codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
if: success()
with:
file: coverage.xml
56 changes: 39 additions & 17 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
"""
Configuration file for the Sphinx documentation builder.
# -- Path setup --------------------------------------------------------------
This file does only contain a selection of the most common options. For a
full list see the documentation:
http://www.sphinx-doc.org/en/master/config
# 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
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
-- Path setup --------------------------------------------------------------
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
documentation root, use ``os.path.abspath`` to make it absolute, like shown here.
"""

import os
import re
Expand All @@ -31,13 +30,26 @@

# The short X.Y version.
parsed_version = re.match(
"(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?:-(?P<release>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+(?P<build>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?",
r"(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?:-(?P<release>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+(?P<build>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?",
release,
)
version = parsed_version.expand("\g<major>.\g<minor>.\g<patch>")
version = parsed_version.expand(r"\g<major>.\g<minor>.\g<patch>")

if parsed_version.group("release"):
tags.add("prerelease")
tags.add("prerelease") # noqa: F821


# See https://about.readthedocs.com/blog/2024/07/addons-by-default/
# Define the canonical URL if you are using a custom domain on Read the Docs
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")

# See https://about.readthedocs.com/blog/2024/07/addons-by-default/
# Tell Jinja2 templates the build is running on Read the Docs
if os.environ.get("READTHEDOCS", "") == "True":
if "html_context" not in globals():
html_context = {}
html_context["READTHEDOCS"] = True # noqa: F821


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

Expand Down Expand Up @@ -80,7 +92,9 @@
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"
source_suffix = {
".rst": "restructuredtext",
}

# The master toctree document.
master_doc = "index"
Expand Down Expand Up @@ -137,7 +151,7 @@
# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = "Bioregistrydoc"
htmlhelp_basename = "bioregistry_doc"

# -- Options for LaTeX output ------------------------------------------------

Expand Down Expand Up @@ -225,10 +239,18 @@
# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
# Note: don't add trailing slashes, since sphinx adds "/objects.inv" to the end
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"rdflib": ("https://rdflib.readthedocs.io/en/stable/", None),
"pandas": ("https://pandas.pydata.org/docs", None),
}

autoclass_content = "both"

# Don't sort alphabetically, explained at:
# https://stackoverflow.com/questions/37209921/python-how-not-to-sort-sphinx-output-in-alphabetical-order
autodoc_member_order = "bysource"

todo_include_todos = True
todo_emit_warnings = True

0 comments on commit 740a761

Please sign in to comment.