Skip to content

Commit

Permalink
Merge pull request #303 from dbatten5/python-version
Browse files Browse the repository at this point in the history
Python version
  • Loading branch information
dbatten5 authored Jan 12, 2024
2 parents 9b1dd17 + aebf1b4 commit 58a70c6
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 420 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip==23.0.1
nox==2021.10.1
nox-poetry==0.8.6
nox==2022.11.21
nox-poetry==1.0.3
poetry==1.4.2
virtualenv==20.10.0
virtualenv==20.15.0
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v4.4.0
uses: actions/setup-python@v4.6.1
with:
python-version: "3.9"
python-version: "3.11"

- name: Upgrade pip
run: |
Expand Down
79 changes: 47 additions & 32 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,64 @@ on:

jobs:
tests:
name: ${{ matrix.session }} ${{ matrix.python-version }} / ${{ matrix.os }}
name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
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: "3.11", os: ubuntu-latest, session: "pre-commit" }
- { python: "3.11", os: ubuntu-latest, session: "safety" }
- { python: "3.11", os: ubuntu-latest, session: "mypy" }
- { python: "3.10", os: ubuntu-latest, session: "mypy" }
- { python: "3.9", os: ubuntu-latest, session: "mypy" }
- { python: "3.8", os: ubuntu-latest, session: "mypy" }
- { python: "3.11", os: ubuntu-latest, session: "tests" }
- { python: "3.10", os: ubuntu-latest, session: "tests" }
- { python: "3.9", os: ubuntu-latest, session: "tests" }
- { python: "3.8", os: ubuntu-latest, session: "tests" }
- { python: "3.11", os: windows-latest, session: "tests" }
# - { python: "3.11", os: macos-latest, session: "tests" }
- { python: "3.11", os: ubuntu-latest, session: "typeguard" }
- { python: "3.11", os: ubuntu-latest, session: "xdoctest" }

env:
NOXSESSION: ${{ matrix.session }}
FORCE_COLOR: "1"
PRE_COMMIT_COLOR: "always"

steps:
- name: Check out the repository
uses: actions/checkout@v3.5.0
uses: actions/checkout@v3

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

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Upgrade pip in virtual environments
shell: python
run: |
import os
import pip
with open(os.environ["GITHUB_ENV"], mode="a") as io:
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Compute pre-commit cache key
Expand All @@ -74,7 +88,7 @@ jobs:
print("::set-output name=result::{}".format(result))
- name: Restore pre-commit cache
uses: actions/cache@v3.3.1
uses: actions/cache@v3
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
Expand All @@ -84,11 +98,11 @@ jobs:
- name: Run Nox
run: |
nox --force-color --python=${{ matrix.python-version }}
nox --python=${{ matrix.python }}
- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/upload-artifact@v3.1.2"
uses: "actions/upload-artifact@v3"
with:
name: coverage-data
path: ".coverage.*"
Expand All @@ -98,12 +112,12 @@ jobs:
needs: tests
steps:
- name: Check out the repository
uses: actions/checkout@v3.5.0
uses: actions/checkout@v3

- name: Set up Python 3.9
uses: actions/setup-python@v4.4.0
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.9
python-version: "3.11"

- name: Upgrade pip
run: |
Expand All @@ -112,26 +126,27 @@ jobs:
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Download coverage data
uses: actions/download-artifact@v3.0.2
uses: actions/download-artifact@v3
with:
name: coverage-data

- name: Combine coverage data and display human readable report
run: |
nox --force-color --session=coverage
nox --session=coverage
- name: Create coverage report
run: |
nox --force-color --session=coverage -- xml
nox --session=coverage -- xml
- name: Upload coverage report
uses: codecov/codecov-action@v3.1.1
uses: codecov/codecov-action@v3
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ git clone [email protected]:<your username>/maison.git
cd maison
```

You'll need `python` 3.7+ to run this package. You can follow
You'll need `python` 3.8+ to run this package. You can follow
the instructions [here](https://cookiecutter-hypermodern-python.readthedocs.io/en/2021.6.15/guide.html#getting-python)
to install and use these versions.

Expand Down
29 changes: 19 additions & 10 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nox sessions."""
import os
import sys
from pathlib import Path
from textwrap import dedent
Expand All @@ -19,7 +20,7 @@


package = "maison"
python_versions = ["3.9", "3.8", "3.7", "3.6"]
python_versions = ["3.11", "3.10", "3.9", "3.8"]
nox.needs_version = ">= 2021.6.6"
nox.options.sessions = (
"pre-commit",
Expand Down Expand Up @@ -82,25 +83,27 @@ def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
hook.write_text("\n".join(lines))


@session(name="pre-commit", python="3.9")
@session(name="pre-commit", python=python_versions[0])
def precommit(session: Session) -> None:
"""Lint using pre-commit."""
args = session.posargs or ["run", "--all-files", "--show-diff-on-failure"]
args = session.posargs or [
"run",
"--all-files",
"--hook-stage=manual",
"--show-diff-on-failure",
]
session.install(
"black",
"darglint",
"ruff",
"pep8-naming",
"pre-commit",
"pre-commit-hooks",
"reorder-python-imports",
)
session.run("pre-commit", *args)
if args and args[0] == "install":
activate_virtualenv_in_precommit_hooks(session)


@session(python="3.9")
@session(python=python_versions[0])
def safety(session: Session) -> None:
"""Scan dependencies for insecure packages."""
requirements = session.poetry.export_requirements()
Expand Down Expand Up @@ -131,7 +134,7 @@ def tests(session: Session) -> None:
session.notify("coverage", posargs=[])


@session
@session(python=python_versions[0])
def coverage(session: Session) -> None:
"""Produce the coverage report."""
args = session.posargs or ["report"]
Expand All @@ -144,7 +147,7 @@ def coverage(session: Session) -> None:
session.run("coverage", *args)


@session(python=python_versions)
@session(python=python_versions[0])
def typeguard(session: Session) -> None:
"""Runtime type checking using Typeguard."""
session.install(".")
Expand All @@ -155,7 +158,13 @@ def typeguard(session: Session) -> None:
@session(python=python_versions)
def xdoctest(session: Session) -> None:
"""Run examples with xdoctest."""
args = session.posargs or ["all"]
if session.posargs:
args = [package, *session.posargs]
else:
args = [f"--modname={package}", "--command=all"]
if "FORCE_COLOR" in os.environ:
args.append("--colored=1")

session.install(".")
session.install("xdoctest[colors]")
session.run("python", "-m", "xdoctest", package, *args)
Loading

0 comments on commit 58a70c6

Please sign in to comment.