Skip to content

Commit

Permalink
Implement tox for CI tasks (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartin16 authored Apr 12, 2023
1 parent 8259d32 commit 661db2c
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 101 deletions.
13 changes: 10 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Full documentation:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
day: "saturday"
time: "8:00"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "saturday"
time: "8:00"
103 changes: 36 additions & 67 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ concurrency:
env:
LATEST_PYTHON_VER: "3.11"
LATEST_QBT_VER: "v4.5.2"
SUBMIT_COVERAGE_VERSIONS: '[ "3.11" ]'
QBITTORRENTAPI_HOST: "localhost:8080"
QBITTORRENTAPI_USERNAME: "admin"
QBITTORRENTAPI_PASSWORD: "adminadmin"
Expand All @@ -32,7 +31,6 @@ jobs:
qbittorrent-host: ${{ steps.set-outputs.outputs.qbittorrent-host }}
qbittorrent-username: ${{ steps.set-outputs.outputs.qbittorrent-username }}
qbittorrent-password: ${{ steps.set-outputs.outputs.qbittorrent-password }}
coverage-versions: ${{ steps.set-outputs.outputs.coverage-versions }}
steps:
- name: Declare Outputs
id: set-outputs
Expand All @@ -42,7 +40,6 @@ jobs:
echo "qbittorrent-host=${{ env.QBITTORRENTAPI_HOST }}" >> ${GITHUB_OUTPUT}
echo "qbittorrent-username=${{ env.QBITTORRENTAPI_USERNAME }}" >> ${GITHUB_OUTPUT}
echo "qbittorrent-password=${{ env.QBITTORRENTAPI_PASSWORD }}" >> ${GITHUB_OUTPUT}
echo "coverage-versions=${{ env.SUBMIT_COVERAGE_VERSIONS }}" >> ${GITHUB_OUTPUT}
- name: Checkout Repo
uses: actions/checkout@v3.5.1
Expand All @@ -61,9 +58,42 @@ jobs:
- name: Lint
uses: pre-commit/action@v3.0.0

package:
#######
# Verify build and packaging is successful
#######
name: Build & Verify Package
needs: verify
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3.5.1

- name: Set up Python ${{ env.LATEST_PYTHON_VER }}
uses: actions/setup-python@v4.5.0
with:
python-version: ${{ env.LATEST_PYTHON_VER }}
cache: 'pip'
cache-dependency-path: ${{ github.workspace }}/setup.cfg

- name: Install Build Tools
run: |
python -m pip install -U pip setuptools wheel
python -m pip install .[dev]
- name: Build Package
run: tox -e package

- name: Upload Package
uses: actions/upload-artifact@v3.1.2
with:
name: package
path: dist
if-no-files-found: error

Tests-qBittorrent:
name: "Release Test ${{ needs.verify.outputs.python-latest-version }} - ${{ matrix.QBT_VER }}"
needs: verify
needs: [ verify, package ]
strategy:
matrix:
QBT_VER:
Expand Down Expand Up @@ -99,11 +129,10 @@ jobs:
qbittorrent-username: ${{ needs.verify.outputs.qbittorrent-username }}
qbittorrent-password: ${{ needs.verify.outputs.qbittorrent-password }}
is-qbt-dev: ${{ matrix.IS_QBT_DEV }}
coverage-versions: ${{ needs.verify.outputs.coverage-versions }}

Tests-Python:
name: "Release Test ${{ matrix.PYTHON_VER }} - ${{ needs.verify.outputs.qbittorrent-latest-version }}"
needs: verify
needs: [ verify, package ]
strategy:
matrix:
PYTHON_VER:
Expand Down Expand Up @@ -136,7 +165,6 @@ jobs:
qbittorrent-username: ${{ needs.verify.outputs.qbittorrent-username }}
qbittorrent-password: ${{ needs.verify.outputs.qbittorrent-password }}
is-qbt-dev: false
coverage-versions: ${{ needs.verify.outputs.coverage-versions }}
runner-os: ${{ matrix.OS_VER }}

coverage:
Expand Down Expand Up @@ -171,7 +199,7 @@ jobs:
python -m coverage html --skip-covered --skip-empty
python -m coverage report --fail-under=100
- name: Upload HTML report if check failed.
- name: Upload HTML report if check failed
if: ${{ failure() }}
uses: actions/upload-artifact@v3.1.2
with:
Expand All @@ -185,37 +213,6 @@ jobs:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}


package:
#######
# Verify build and packaging is successful
#######
name: Build & Verify Package
needs: verify
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3.5.1

- name: Set up Python ${{ env.LATEST_PYTHON_VER }}
uses: actions/setup-python@v4.5.0
with:
python-version: ${{ env.LATEST_PYTHON_VER }}
cache: 'pip'
cache-dependency-path: ${{ github.workspace }}/setup.cfg

- name: Install Build Tools
run: python -m pip install -U pip setuptools wheel twine build

- name: Build Package
run: python -m build

- name: List Result
run: ls -l dist

- name: Check long_description
run: python -m twine check dist/*

install-dev:
#######
# Verify package can be installed on all platforms
Expand Down Expand Up @@ -244,31 +241,3 @@ jobs:
- name: Import Package
run: python -c "from qbittorrentapi import Client; assert Client().host == 'localhost:8080'"

docs-build:
#######
# Verify documentation build succeeds
#######
name: Verify Doc Build
needs: verify
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3.5.1

- name: Set up Python ${{ env.LATEST_PYTHON_VER }}
uses: actions/setup-python@v4.5.0
with:
python-version: ${{ env.LATEST_PYTHON_VER }}
cache: 'pip'
cache-dependency-path: ${{ github.workspace }}/setup.cfg

- name: Install requirements
run: python -m pip install .[dev]

- name: Build Docs
run: |
cd docs
sphinx-build -v -W --keep-going -E -a -b linkcheck "source" "build"
sphinx-build -v -W --keep-going -E -a -b html "source" "build"
make html
12 changes: 8 additions & 4 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ jobs:
uses: actions/setup-python@v4.5.0
with:
python-version: '3.x'
- name: Install dependencies and build

- name: Install Build Tools
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build
python -m build
python -m pip install -U pip setuptools wheel
python -m pip install .[dev]
- name: Build Package
run: tox -e package

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ on:
is-qbt-dev:
required: true
type: boolean
coverage-versions:
required: true
type: string
runner-os:
required: false
default: ubuntu-latest
Expand Down Expand Up @@ -51,6 +48,12 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v3.5.1

- name: Get packages
uses: actions/download-artifact@v3.0.2
with:
name: package
path: dist

- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4.5.0
with:
Expand All @@ -66,9 +69,14 @@ jobs:
- name: Install
run: |
python -m pip install --upgrade pip setuptools
pip install .[dev]
python -m pip install $(ls dist/qbittorrent_api-*.whl)[dev]
- name: Test
if: ${{ !contains(fromJSON('["3.6", "3.5", "2.7", "pypy2.7"]'), inputs.python-version) }}
run: tox -e py --installpkg dist/qbittorrent_api-*.whl

- name: Test (legacy)
if: contains(fromJSON('["3.6", "3.5", "2.7", "pypy2.7"]'), inputs.python-version)
run: python -m coverage run -m pytest

- name: qBittorrent Log
Expand Down
6 changes: 5 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3"
jobs:
pre_build:
- tox -e docs-lint

# Build documentation in the docs/ directory with Sphinx
sphinx:
builder: html
configuration: docs/source/conf.py
fail_on_warning: true

# Build all output formats
formats: all
Expand Down
13 changes: 13 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include *.yaml
include tox.ini
include .git-blame-ignore-revs
recursive-include docs *.bat
recursive-include docs *.py
recursive-include docs *.rst
recursive-include docs Makefile
recursive-include docs spelling_wordlist
recursive-include tests *.crt
recursive-include tests *.key
recursive-include tests *.py
recursive-include tests *.torrent
recursive-include tests *.txt
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/behavior&configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Requests Configuration
Additional HTTP Headers
***********************
* For consistency, HTTP Headers can be specified using the method above; for backwards compatability, the methods below are supported as well.
* For consistency, HTTP Headers can be specified using the method above; for backwards compatibility, the methods below are supported as well.
* Either way, these additional headers will be incorporated (using clobbering) into the rest of the headers to be sent.
* To send a custom HTTP header in all requests made from an instantiated client, declare them during instantiation:
Expand Down
19 changes: 17 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from datetime import datetime

base_path = os.path.abspath("../..")
sys.path.insert(0, base_path)
sys.path.insert(0, os.path.join(base_path, "src"))

setup_cfg = ConfigParser()
setup_cfg.read(os.path.join(base_path, "setup.cfg"))
Expand Down Expand Up @@ -76,7 +76,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
## html_static_path = ["_static"]
# html_static_path = ["_static"]

html_theme = "furo"

Expand All @@ -92,3 +92,18 @@
"python": ("https://docs.python.org/3", None),
"requests": ("https://requests.readthedocs.io/en/latest/", None),
}

# -- Options for spelling -------------------------------------------

# Spelling check needs an additional module that is not installed by default.
# Add it only if spelling check is requested so docs can be generated without it.
if "spelling" in sys.argv:
extensions.append("sphinxcontrib.spelling")

# Spelling language.
spelling_lang = "en_US"

# Location of word list.
spelling_word_list_filename = "spelling_wordlist"

spelling_ignore_pypi_package_names = True
15 changes: 15 additions & 0 deletions docs/source/spelling_wordlist
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Attrs
bc
bt
casted
Curran
errored
Errored
filepath
hostname
instantiation
kwargs
qBittorrent
Reannounce
untagged
Untrusted
30 changes: 18 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,25 @@ qbittorrentapi =

[options.extras_require]
dev =
black; python_version >= "3.7"
build
coverage[toml]
furo; python_version >= "3.7"
black == 23.3.0; python_version >= "3.7"
build == 0.10.0; python_version >= "3.7"
coverage[toml]; python_version < "3.7"
coverage[toml] == 7.2.3; python_version >= "3.7"
furo == 2023.3.27; python_version >= "3.8"
mock; python_version < "3"
mypy; python_version >= "3.7" and platform_python_implementation != "PyPy"
pre-commit
pytest
sphinx; python_version >= "3.7"
sphinx-copybutton; python_version >= "3.7"
sphinx-autodoc-typehints; python_version > "3"
types-requests
types-six
mypy == 1.2.0; python_version >= "3.7" and platform_python_implementation != "PyPy"
pre-commit; python_version < "3.8"
pre-commit == 3.0.2; python_version >= "3.8"
pytest; python_version < "3.7"
pytest == 7.3.0; python_version >= "3.7"
sphinx == 6.1.3; python_version >= "3.8"
sphinx-autodoc-typehints == 1.22; python_version > "3.7"
sphinx-copybutton == 0.5.1; python_version >= "3.7"
sphinxcontrib-spelling == 8.0.0; python_version >= "3.7"
tox == 4.4.11; python_version >= "3.7"
twine == 4.0.2; python_version >= "3.7"
types-requests == 2.28.11.17; python_version > "3"
types-six == 1.16.21.8; python_version > "3"

[options.packages.find]
where = src
Expand Down
2 changes: 1 addition & 1 deletion src/qbittorrentapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Client(
certs will cause a :class:`qbittorrentapi.exceptions.APIConnectionError` exception to be raised.
:param EXTRA_HEADERS: Dictionary of HTTP Headers to include in all requests made to qBittorrent.
:param REQUESTS_ARGS: Dictionary of configuration for Requests package: `<https://requests.readthedocs.io/en/latest/api/#requests.request>`_
:param FORCE_SCHEME_FROM_HOST: If a scheme (i.e. ``http`` or ``https``) is specifed in host, it will be used regardless
:param FORCE_SCHEME_FROM_HOST: If a scheme (i.e. ``http`` or ``https``) is specified in host, it will be used regardless
of whether qBittorrent is configured for HTTP or HTTPS communication. Normally, this client will attempt to
determine which scheme qBittorrent is actually listening on...but this can cause problems in rare cases.
:param RAISE_NOTIMPLEMENTEDERROR_FOR_UNIMPLEMENTED_API_ENDPOINTS: Some Endpoints may not be implemented in older
Expand Down
Loading

0 comments on commit 661db2c

Please sign in to comment.