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

pyproject.toml, ruff, Python 3.10, update CI #82

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/flake8.yml → .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Flake8
name: Linter

on:
push:
Expand All @@ -12,12 +12,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python 3.8
uses: actions/setup-python@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: '3.10'

- name: Install pre-commit hooks
run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ jobs:
group: ${{ github.workflow }}-${{ github.ref }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel build
pip install build virtualenv

# PyPI package
- name: Build Python package
Expand All @@ -48,7 +48,7 @@ jobs:
python -m sphinx docs/ docs/_build/ -b html

- name: Deploy documentation to Github pages
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build
Expand All @@ -70,7 +70,7 @@ jobs:

- name: Create release on Github
id: create_release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
python-version: [ '3.8', '3.9', '3.10', '3.11' ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
18 changes: 15 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@
# $ pre-commit install
# $ pre-commit run --all-files
#
#
default_language_version:
python: python3.10

repos:
- repo: https://github.com/pycqa/flake8
rev: '5.0.4'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.8
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: flake8
- id: codespell
additional_dependencies:
- tomli
28 changes: 16 additions & 12 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ you should get the newest development version from Github_::

git clone https://github.com/audeering/sphinx-audeering-theme/
cd sphinx-audeering-theme
# Create virutal environment for this project
# Create virtual environment for this project
# e.g.
# virtualenv --python="python3" $HOME/.envs/sphinx-audeering-theme
# source $HOME/.envs/sphinx-audeering-theme/bin/activate
Expand All @@ -37,9 +37,11 @@ Coding Convention
-----------------

We follow the PEP8_ convention for Python code
and check for correct syntax with flake8_.
Exceptions are defined under the ``[flake8]`` section
in :file:`setup.cfg`.
and check for correct syntax with ruff_.
In addition,
we check for common spelling errors with codespell_.
Both tools and possible exceptions
are defined in :file:`pyproject.toml`.

The checks are executed in the CI using `pre-commit`_.
You can enable those checks locally by executing::
Expand All @@ -48,23 +50,25 @@ You can enable those checks locally by executing::
pre-commit install
pre-commit run --all-files

Afterwards flake8_ is executed
Afterwards ruff_ and codespell_ are executed
every time you create a commit.

You can also install flake8_
You can also install ruff_ and codespell_
and call it directly::

pip install flake8 # consider system wide installation
flake8
pip install ruff codespell # consider system wide installation
ruff check .
codespell

It can be restricted to specific folders::

flake8 audfoo/ tests/
ruff check sphinx_audeering_theme/ tests/
codespell sphinx_audeering_theme/ tests/

.. _codespell: https://github.com/codespell-project/codespell/
.. _PEP8: http://www.python.org/dev/peps/pep-0008/
.. _flake8: https://flake8.pycqa.org/en/latest/index.html
.. _pre-commit: https://pre-commit.com

.. _ruff: https://beta.ruff.rs

Building the Documentation
--------------------------
Expand All @@ -86,7 +90,7 @@ It is also possible to automatically check if all links are still valid::

python -m sphinx docs/ build/sphinx/html -b linkcheck

.. _Sphinx: https://sphinx-doc.org/
.. _Sphinx: https://sphinx-doc.org


Running the Tests
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Have a look at the installation_ and usage_ instructions as a starting point.
   :target: https://audeering.github.io/sphinx-audeering-theme/
   :alt: sphinx-audeering-theme's documentation
.. |license| image:: https://img.shields.io/badge/license-MIT-green.svg
   :target: https://github.com/audeering/sphinx-audeering-theme/blob/master/LICENSE
   :target: https://github.com/audeering/sphinx-audeering-theme/blob/main/LICENSE
   :alt: sphinx-audeering-theme's MIT license
.. |python-versions| image:: https://img.shields.io/pypi/pyversions/sphinx-audeering-theme.svg
:target: https://pypi.org/project/sphinx-audeering-theme/
Expand Down
57 changes: 32 additions & 25 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,59 @@
from subprocess import check_output
from datetime import date

import toml

import audeer


config = toml.load(audeer.path("..", "pyproject.toml"))

# Project -----------------------------------------------------------------
project = 'sphinx-audeering-theme'
author = 'Hagen Wierstorf'
# The x.y.z version read from tags
try:
version = check_output(['git', 'describe', '--tags', '--always'])
version = version.decode().strip()
except Exception:
version = '<unknown>'
title = '{} Documentation'.format(project)
project = config["project"]["name"]
author = ", ".join(author["name"] for author in config["project"]["authors"])
copyright = f"2020-{date.today().year} audEERING GmbH"
version = audeer.git_repo_version()
title = "Documentation"

# General -----------------------------------------------------------------
master_doc = 'index'
master_doc = "index"
extensions = []
source_suffix = '.rst'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
source_suffix = ".rst"
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
extensions = [
'sphinx.ext.autodoc',
"sphinx.ext.autodoc",
]
linkcheck_ignore = [
'https://sphinx-doc.org',
'http://devops.pp.audeering.com',
"https://sphinx-doc.org",
"http://devops.pp.audeering.com",
]

# HTML --------------------------------------------------------------------
html_theme = 'sphinx_audeering_theme'
html_theme = "sphinx_audeering_theme"
html_theme_options = {
'display_version': True,
'footer_links': False,
'logo_only': False,
'wide_pages': ['example-wide-pages'],
"display_version": True,
"footer_links": False,
"logo_only": False,
"wide_pages": ["example-wide-pages"],
}
html_context = {
'display_github': True,
"display_github": True,
}
html_title = title


# LaTeX -------------------------------------------------------------------
latex_elements = {
'papersize': 'a4paper',
"papersize": "a4paper",
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'sphinx-audeering-theme-{}.tex'.format(version),
title, author, 'manual'),
(
master_doc,
"sphinx-audeering-theme-{}.tex".format(version),
title,
author,
"manual",
),
]
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
audeer
sphinx
sphinx-audeering-theme
toml
Loading