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

Fix test action #12

Merged
merged 7 commits into from
Nov 23, 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
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
shell: bash
run: |
pip install nox
pip install nox-poetry
pip install poetry
poetry config virtualenvs.in-project true

Expand Down Expand Up @@ -81,6 +82,7 @@ jobs:
shell: bash
run: |
pip install nox
pip install nox-poetry
pip install poetry
poetry config virtualenvs.in-project true

Expand Down
38 changes: 19 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.3.0
hooks:
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: check-merge-conflict
- id: check-json
- id: end-of-file-fixer
- repo: https://github.com/timothycrosley/isort
rev: 5.9.3
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 21.9b0
rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
hooks:
- id: isort
- repo: local
hooks:
- id: flakehell
name: flakehell
description: "`Flakehell` it's a Flake8 wrapper to make it cools."
entry: flakehell
- id: flakeheaven
name: flakeheaven
description: "flakeheaven wraps flake8. (flakehell is deprecated)"
entry: flakeheaven
args: [lint]
language: python
types: [python]
require_serial: true
additional_dependencies: [
'flake8~=3.9.2',
'flakehell~=0.9.0',
'flake8-builtins~=1.5.3',
'flake8-blind-except~=0.2.0',
'flake8-logging-format~=0.6.0',
'flake8-bugbear~=21.9.2',
'flake8-annotations~=2.6.2',
'flake8>=4.0.1,<5.0.0',
'flakeheaven~=3.2.1',
'flake8-builtins~=2.0.1',
'flake8-blind-except~=0.2.1',
'flake8-logging-format~=0.9.0',
'flake8-bugbear~=22.10.27',
'flake8-annotations~=2.9.1',
'flake8-docstrings~=1.6.0',
'flake8-bandit~=2.1.2',
'darglint~=1.8.0'
'flake8-bandit==3.0.0',
'darglint~=1.8.1'
]
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[mypy]

[mypy-pytest,invoke.*,nox.*]
[mypy-pytest,invoke.*,nox.*,nox_poetry]
allow_redefinition = false
check_untyped_defs = true
ignore_errors = false
Expand Down
62 changes: 16 additions & 46 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,18 @@
"""Nox sessions."""
import platform
import tempfile
from typing import Any

import nox
from nox.sessions import Session
from nox import options
from nox_poetry import Session, session

nox.options.sessions = ["tests", "mypy"]
python_versions = ["3.7", "3.8", "3.9", "3.10"]
options.sessions = ["tests", "mypy"]
python_versions = ["3.10"]


def install_with_constraints(session: Session, *args: str, **kwargs: Any) -> None:
"""Install packages constrained by Poetry's lock file.

This function is a wrapper for nox.sessions.Session.install. It
invokes pip to install packages inside of the session's virtualenv.
Additionally, pip is passed a constraints file generated from
Poetry's lock file, to ensure that the packages are pinned to the
versions specified in poetry.lock. This allows you to manage the
packages as Poetry development dependencies.

Arguments:
session: The Session object.
args: Command-line arguments for pip.
kwargs: Additional keyword arguments for Session.install.
"""
with tempfile.NamedTemporaryFile(delete=False) as requirements:
session.run(
"poetry",
"export",
"--dev",
"--without-hashes",
"--format=requirements.txt",
f"--output={requirements.name}",
external=True,
)
session.install(f"--constraint={requirements.name}", *args, **kwargs)


@nox.session(python=python_versions)
@session(python=python_versions)
def tests(session: Session) -> None:
"""Run the test suite."""
session.install(".")
install_with_constraints(
session, "invoke", "pytest", "xdoctest", "coverage[toml]", "pytest-cov"
)
dependencies = ["invoke", "pytest", "xdoctest", "coverage[toml]", "pytest-cov"]
session.install(".", *dependencies)
try:
session.run(
"inv",
Expand All @@ -58,24 +26,26 @@ def tests(session: Session) -> None:
session.notify("coverage")


@nox.session
@session
def coverage(session: Session) -> None:
"""Produce the coverage report."""
args = session.posargs if session.posargs and len(session._runner.manifest) == 1 else []
install_with_constraints(session, "invoke", "coverage[toml]")
dependencies = ["invoke", "coverage[toml]"]
session.install(*dependencies)
session.run("inv", "coverage", *args)


@nox.session(python=python_versions)
@session(python=python_versions)
def mypy(session: Session) -> None:
"""Type-check using mypy."""
session.install(".")
install_with_constraints(session, "invoke", "mypy")
dependencies = ["invoke", "mypy"]
session.install(".", *dependencies)
session.run("inv", "mypy")


@nox.session(python="3.10")
@session(python=python_versions)
def safety(session: Session) -> None:
"""Scan dependencies for insecure packages."""
install_with_constraints(session, "invoke", "safety")
dependencies = ["invoke", "safety"]
session.install(*dependencies)
session.run("inv", "safety")
Loading