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

Bump min python version to 3.7 and max to 3.10 & update libs #412

Merged
merged 2 commits into from
Oct 12, 2022
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/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip==21.2.4
nox==2020.12.31
poetry==1.1.8
virtualenv==20.7.2
nox-poetry==0.8.6
pip==22.2.2
nox==2022.8.7
nox-poetry==1.0.1
poetry==1.2.2
virtualenv==20.16.5
15 changes: 8 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Release
on:
push:
branches:
- main
- master

jobs:
Expand All @@ -11,14 +12,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.1.0
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v2.2.2
uses: actions/setup-python@v4.3.0
with:
python-version: "3.8"
python-version: "3.10"

- name: Upgrade pip
run: |
Expand Down Expand Up @@ -56,21 +57,21 @@ jobs:

- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/gh-action-pypi-publish@v1.4.2
uses: pypa/gh-action-pypi-publish@v1.5.1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/gh-action-pypi-publish@v1.4.2
uses: pypa/gh-action-pypi-publish@v1.5.1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish the release notes
uses: release-drafter/release-drafter@v5.15.0
- name: Publish release notes
uses: release-drafter/release-drafter@v5.21.0
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
Expand Down
53 changes: 27 additions & 26 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: Tests

on:
push:
branches:
- master
pull_request:
types: [opened, reopened]

jobs:
tests:
Expand All @@ -14,29 +13,31 @@ jobs:
fail-fast: false
matrix:
include:
- { python-version: 3.9, os: ubuntu-latest, session: "pre-commit" }
- { python-version: 3.9, os: ubuntu-latest, session: "safety" }
# - { python-version: 3.9, os: ubuntu-latest, session: "mypy" }
# - { python-version: 3.8, os: ubuntu-latest, session: "mypy" }
# - { python-version: 3.7, os: ubuntu-latest, session: "mypy" }
- { python-version: 3.9, os: ubuntu-latest, session: "tests" }
- { python-version: 3.8, os: ubuntu-latest, session: "tests" }
- { python-version: 3.7, os: ubuntu-latest, session: "tests" }
- { python-version: 3.9, os: windows-latest, session: "tests" }
- { python-version: 3.9, os: macos-latest, session: "tests" }
# - { python-version: 3.9, os: ubuntu-latest, session: "typeguard" }
# - { python-version: 3.9, os: ubuntu-latest, session: "xdoctest" }
- { python-version: 3.8, os: ubuntu-latest, session: "docs-build" }
- { python-version: "3.10", os: ubuntu-latest, session: "pre-commit" }
- { python-version: "3.10", os: ubuntu-latest, session: "safety" }
# - { python-version: "3.10", os: ubuntu-latest, session: "mypy" }
# - { python-version: "3.9", os: ubuntu-latest, session: "mypy" }
# - { python-version: "3.8", os: ubuntu-latest, session: "mypy" }
# - { python-version: "3.7", os: ubuntu-latest, session: "mypy" }
- { python-version: "3.10", os: ubuntu-latest, session: "tests" }
- { python-version: "3.9", os: ubuntu-latest, session: "tests" }
- { python-version: "3.8", os: ubuntu-latest, session: "tests" }
- { python-version: "3.7", os: ubuntu-latest, session: "tests" }
- { python-version: "3.10", os: windows-latest, session: "tests" }
- { python-version: "3.10", os: macos-latest, session: "tests" }
# - { python-version: "3.10", os: ubuntu-latest, session: "typeguard" }
- { python-version: "3.10", os: ubuntu-latest, session: "xdoctest" }
- { python-version: "3.10", os: ubuntu-latest, session: "docs-build" }

env:
NOXSESSION: ${{ matrix.session }}

steps:
- name: Check out the repository
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.1.0

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

Expand Down Expand Up @@ -71,7 +72,7 @@ jobs:
print("::set-output name=result::{}".format(result))

- name: Restore pre-commit cache
uses: actions/cache@v2.1.6
uses: actions/cache@v3.0.10
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
Expand All @@ -85,14 +86,14 @@ jobs:

- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/upload-artifact@v2.2.4"
uses: "actions/upload-artifact@v3.1.0"
with:
name: coverage-data
path: ".coverage.*"

- name: Upload documentation
if: matrix.session == 'docs-build'
uses: actions/upload-artifact@v2.2.4
uses: actions/upload-artifact@v3.1.0
with:
name: docs
path: docs/_build
Expand All @@ -102,12 +103,12 @@ jobs:
needs: tests
steps:
- name: Check out the repository
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.1.0

- name: Set up Python 3.9
uses: actions/setup-python@v2.2.2
- name: Set up Python 3.10
uses: actions/setup-python@v4.3.0
with:
python-version: 3.9
python-version: "3.10"

- name: Upgrade pip
run: |
Expand All @@ -125,7 +126,7 @@ jobs:
nox --version

- name: Download coverage data
uses: actions/download-artifact@v2.0.10
uses: actions/download-artifact@v3.0.0
with:
name: coverage-data

Expand All @@ -138,4 +139,4 @@ jobs:
nox --force-color --session=coverage -- xml

- name: Upload coverage report
uses: codecov/codecov-action@v2.0.3
uses: codecov/codecov-action@v3.1.1
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
.mypy_cache/
/.coverage
/.coverage.*
/.nox/
/.python-version
/.pytype/
/dist/
/docs/_build/
/src/*.egg-info/
__pycache__/

# Editor
/.vscode
4 changes: 3 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ sphinx:
configuration: docs/conf.py
formats: all
python:
version: 3.8
version: 3.9
install:
- requirements: docs/requirements.txt
- path: .
build:
image: testing
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Request features on the `Issue Tracker`_.
How to set up your development environment
------------------------------------------

You need Python 3.6+ and the following tools:
You need Python 3.7+ and the following tools:

- Poetry_
- Nox_
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sphinx==4.1.2
sphinx==5.2.3
61 changes: 35 additions & 26 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,30 @@
from textwrap import dedent

import nox
import nox_poetry.patch
from nox.sessions import Session

try:
from nox_poetry import Session
from nox_poetry import session
except ImportError:
message = f"""\
Nox failed to import the 'nox-poetry' package.

Please install it using the following command:

{sys.executable} -m pip install nox-poetry"""
raise SystemExit(dedent(message)) from None


package = "freebox_api"
python_versions = ["3.7", "3.8", "3.9"]
# mypy and typgaurd temporarily deactivated by default as type hint needs rework.
python_versions = ["3.10", "3.9", "3.8", "3.7"]
nox.needs_version = ">= 2021.6.6"
nox.options.sessions = (
"pre-commit",
"safety",
# "mypy",
# "mypy",
"tests",
# "typeguard",
# "typeguard",
"xdoctest",
"docs-build",
)

Expand Down Expand Up @@ -73,7 +84,7 @@ def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
hook.write_text("\n".join(lines))


@nox.session(name="pre-commit", python="3.9")
@session(name="pre-commit", python="3.10")
def precommit(session: Session) -> None:
"""Lint using pre-commit."""
args = session.posargs or ["run", "--all-files", "--show-diff-on-failure"]
Expand All @@ -95,61 +106,59 @@ def precommit(session: Session) -> None:
activate_virtualenv_in_precommit_hooks(session)


@nox.session(python="3.9")
@session(python="3.10")
def safety(session: Session) -> None:
"""Scan dependencies for insecure packages."""
requirements = nox_poetry.export_requirements(session)
requirements = session.poetry.export_requirements()
session.install("safety")
session.run("safety", "check", f"--file={requirements}", "--bare")
session.run("safety", "check", "--full-report", f"--file={requirements}")


@nox.session(python=python_versions)
@session(python=python_versions)
def mypy(session: Session) -> None:
"""Type-check using mypy."""
args = session.posargs or ["src", "tests", "docs/conf.py"]
session.install(".")
session.install("mypy", "pytest")
session.install("mypy", "pytest", "types-requests", "types-pytz")
session.run("mypy", *args)
if not session.posargs:
session.run("mypy", f"--python-executable={sys.executable}", "noxfile.py")


@nox.session(python=python_versions)
@session(python=python_versions)
def tests(session: Session) -> None:
"""Run the test suite."""
session.install(".")
session.install("coverage[toml]", "pytest", "pygments")
session.install("coverage[toml]", "pytest", "pygments", "requests_mock")
try:
session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs)
finally:
if session.interactive:
session.notify("coverage")
session.notify("coverage", posargs=[])


@nox.session
@session
def coverage(session: Session) -> None:
"""Produce the coverage report."""
# Do not use session.posargs unless this is the only session.
has_args = session.posargs and len(session._runner.manifest) == 1
args = session.posargs if has_args else ["report"]
args = session.posargs or ["report"]

session.install("coverage[toml]")

if not has_args and any(Path().glob(".coverage.*")):
if not session.posargs and any(Path().glob(".coverage.*")):
session.run("coverage", "combine")

session.run("coverage", *args)


@nox.session(python=python_versions)
@session(python=python_versions)
def typeguard(session: Session) -> None:
"""Runtime type checking using Typeguard."""
session.install(".")
session.install("pytest", "typeguard", "pygments")
session.install("pytest", "typeguard", "pygments", "requests_mock")
session.run("pytest", f"--typeguard-packages={package}", *session.posargs)


@nox.session(python=python_versions)
@session(python=python_versions)
def xdoctest(session: Session) -> None:
"""Run examples with xdoctest."""
args = session.posargs or ["all"]
Expand All @@ -158,7 +167,7 @@ def xdoctest(session: Session) -> None:
session.run("python", "-m", "xdoctest", package, *args)


@nox.session(name="docs-build", python="3.8")
@session(name="docs-build", python="3.10")
def docs_build(session: Session) -> None:
"""Build the documentation."""
args = session.posargs or ["docs", "docs/_build"]
Expand All @@ -172,12 +181,12 @@ def docs_build(session: Session) -> None:
session.run("sphinx-build", *args)


@nox.session(python="3.8")
@session(python="3.10")
def docs(session: Session) -> None:
"""Build and serve the documentation with live reloading on file changes."""
args = session.posargs or ["--open-browser", "docs", "docs/_build"]
session.install(".")
session.install("sphinx", "sphinx-autobuild", "sphinx-rtd-theme")
session.install("sphinx", "sphinx-autobuild", "sphinx-click", "sphinx-rtd-theme")

build_dir = Path("docs", "_build")
if build_dir.exists():
Expand Down
Loading