-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for python 3.12 and 3.13 (#363)
* add support for python 3.12 and 3.13 This also changes the projects default python version to 3.12 * streamline environment setup by consolidating installation steps for Poetry, Nox, and nox-poetry * update Nox command to specify Python version in CI
- Loading branch information
Showing
9 changed files
with
484 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,10 @@ jobs: | |
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python 3.9 | ||
- name: Setup Python 3.12 | ||
uses: actions/[email protected] | ||
with: | ||
python-version: '3.9' | ||
python-version: '3.12' | ||
architecture: x64 | ||
|
||
- name: Install dependencies | ||
|
@@ -74,10 +74,10 @@ jobs: | |
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
||
- name: Setup Python 3.9 | ||
- name: Setup Python 3.12 | ||
uses: actions/[email protected] | ||
with: | ||
python-version: '3.9' | ||
python-version: '3.12' | ||
architecture: x64 | ||
|
||
- name: Setup Poetry | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ jobs: | |
- name: Setup Latest Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: 3.9 | ||
python-version: 3.12 | ||
architecture: x64 | ||
|
||
- name: Setup Poetry | ||
|
@@ -49,7 +49,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.8', '3.9'] | ||
python-version: ['3.9', '3.10', '3.11', '3.13'] | ||
name: Python ${{ matrix.python-version }} | ||
steps: | ||
- name: Checkout Code | ||
|
@@ -61,11 +61,10 @@ jobs: | |
python-version: ${{ matrix.python-version }} | ||
architecture: x64 | ||
|
||
- name: Setup Nox | ||
run: pip install nox==2020.8.22 | ||
|
||
- name: Setup Poetry | ||
run: pip install poetry==1.4.2 | ||
# Install Poetry Nox and nox-poetry | ||
- name: Setup Environment | ||
run: | | ||
pip install poetry nox nox-poetry | ||
- name: Run Tests | ||
run: nox | ||
run: nox -p ${{ matrix.python-version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[mypy] | ||
allow_redefinition = True | ||
[mypy-nox.*,taskcat.*,pytest] | ||
[mypy-nox.*,taskcat.*,pytest,nox_poetry] | ||
ignore_missing_imports = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,71 @@ | ||
import tempfile | ||
"""Nox sessions.""" | ||
|
||
import sys | ||
from textwrap import dedent | ||
|
||
import nox | ||
|
||
nox.options.sessions = "lint", "mypy", "tests" | ||
try: | ||
from nox_poetry import Session, session | ||
except ImportError: | ||
message = f"""\ | ||
Nox failed to import the 'nox-poetry' package. | ||
locations = "src", "tests", "noxfile.py" | ||
Please install it using the following command: | ||
{sys.executable} -m pip install nox-poetry""" | ||
raise SystemExit(dedent(message)) from None | ||
|
||
def install_with_constraints(session, *args, **kwargs): | ||
with tempfile.NamedTemporaryFile() as requirements: | ||
session.run( | ||
"poetry", | ||
"export", | ||
"--only", | ||
"dev", | ||
"--format=requirements.txt", | ||
"--without-hashes", | ||
f"--output={requirements.name}", | ||
external=True, | ||
) | ||
session.install("-r", requirements.name, *args, **kwargs) | ||
nox.options.sessions = "mypy", "tests" | ||
|
||
locations = "src", "tests", "noxfile.py" | ||
|
||
@nox.session(python="3.9") | ||
def coverage(session): | ||
"""Upload coverage data.""" | ||
install_with_constraints(session) | ||
session.run("coverage", "xml", "--fail-under=0") | ||
session.run("codecov", *session.posargs) | ||
default_python = "3.12" | ||
|
||
python_versions = ["3.9", "3.10", "3.11", "3.12", "3.13"] | ||
|
||
@nox.session(python=["3.9", "3.8"]) | ||
def tests(session): | ||
args = session.posargs or ["--cov", "-m", "not e2e"] | ||
session.run("poetry", "install", "--only", "main", external=True) | ||
install_with_constraints( | ||
session, | ||
) | ||
session.run("pytest", *args) | ||
|
||
# @session(python=default_python) | ||
# def coverage(session: Session) -> None: | ||
# """Produce the coverage report.""" | ||
# args = session.posargs or ["report"] | ||
|
||
@nox.session(python=["3.9", "3.8"]) | ||
def lint(session): | ||
args = session.posargs or locations | ||
install_with_constraints(session) | ||
session.run("flake8", *args) | ||
# session.install("coverage[toml]") | ||
|
||
# if not session.posargs and any(Path().glob(".coverage.*")): | ||
# session.run("coverage", "combine") | ||
|
||
@nox.session(python=["3.9", "3.8"]) | ||
def mypy(session): | ||
args = session.posargs or locations | ||
install_with_constraints(session) | ||
session.run("mypy", *args) | ||
# session.run("coverage", *args) | ||
|
||
|
||
@session(python=python_versions) | ||
def tests(session: Session) -> None: | ||
"""Run the test suite.""" | ||
session.install(".") | ||
session.install("coverage[toml]", "pytest", "pygments", "pytest-mock") | ||
try: | ||
session.run( | ||
"coverage", | ||
"run", | ||
"--parallel", | ||
"-m", | ||
"pytest", | ||
"-m", | ||
"not e2e", | ||
"tests", | ||
*session.posargs, | ||
) | ||
finally: | ||
pass | ||
# if session.interactive: | ||
# session.notify("coverage", posargs=[]) | ||
|
||
|
||
@nox.session(python="3.9") | ||
def black(session): | ||
@session(python=python_versions) | ||
def mypy(session: Session) -> None: | ||
"""Type-check using mypy.""" | ||
args = session.posargs or locations | ||
install_with_constraints(session) | ||
session.run("black", *args) | ||
session.run_always("poetry", "install", external=True) | ||
session.run("mypy", *args) | ||
if not session.posargs: | ||
session.run("mypy", f"--python-executable={sys.executable}", "noxfile.py") |
Oops, something went wrong.