Skip to content

Commit 630fab8

Browse files
ci: Use Nox (#65)
* ci: Use Nox * Support Python 3.11
1 parent 790f351 commit 630fab8

File tree

8 files changed

+84
-50
lines changed

8 files changed

+84
-50
lines changed

.flake8

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[flake8]
2+
ignore = ANN101,ANN401,W503,D105,D203,D213
3+
max-line-length = 88
4+
max-complexity = 10
5+
docstring-convention = google
6+
per-file-ignores =
7+
tests/*:ANN,DAR

.github/workflows/constraints.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
nox==2022.11.21
2+
nox-poetry==1.0.2
13
pip==22.3.1
24
poetry==1.2.2
3-
poetry-dynamic-versioning==0.21.1
4-
tox==3.27.1

.github/workflows/test.yml

+15-12
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ name: Test tap-jotform
33
on: [push]
44

55
jobs:
6-
linting:
6+
tests:
77
runs-on: ubuntu-latest
88
env:
99
PIP_CONSTRAINT: .github/workflows/constraints.txt
10+
NOXSESSION: ${{ matrix.session }}-${{ matrix.python-version }}
11+
FORCE_COLOR: "1"
1012
strategy:
1113
matrix:
1214
include:
13-
- {python-version: "3.10", session: "lint"}
14-
- {python-version: "3.10", session: "pytest"}
15-
- {python-version: "3.9", session: "pytest"}
16-
- {python-version: "3.8", session: "pytest"}
17-
- {python-version: "3.7", session: "pytest"}
15+
- {python-version: "3.10", session: "mypy"}
16+
- {python-version: "3.11", session: "tests"}
17+
- {python-version: "3.10", session: "tests"}
18+
- {python-version: "3.9", session: "tests"}
19+
- {python-version: "3.8", session: "tests"}
20+
- {python-version: "3.7", session: "tests"}
1821

1922
steps:
2023
- name: Checkout code
@@ -35,15 +38,15 @@ jobs:
3538
pipx install poetry
3639
poetry --version
3740
38-
- name: Install tox
41+
- name: Install Nox
3942
run: |
40-
pipx install tox
41-
pipx inject tox tox-poetry
42-
tox --version
43+
pipx install nox
44+
pipx inject nox nox-poetry
45+
nox --version
4346
44-
- name: Run lint command from tox.ini
47+
- name: Run Nox
4548
env:
4649
TAP_JOTFORM_API_KEY: ${{ secrets.TAP_JOTFORM_API_KEY }}
4750
TAP_JOTFORM_API_URL: "https://api.jotform.com"
4851
run: |
49-
tox -e lint
52+
nox

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ repos:
4444
- darglint
4545
- flake8-annotations
4646
- flake8-docstrings
47+
exclude: "noxfile\\.py"

noxfile.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""Nox configuration."""
2+
3+
from __future__ import annotations
4+
5+
import os
6+
import sys
7+
from textwrap import dedent
8+
9+
import nox
10+
11+
try:
12+
from nox_poetry import Session, session
13+
except ImportError:
14+
message = f"""\
15+
Nox failed to import the 'nox-poetry' package.
16+
Please install it using the following command:
17+
{sys.executable} -m pip install nox-poetry"""
18+
raise SystemExit(dedent(message)) from None
19+
20+
package = "tap-jotform"
21+
src_dir = "tap_jotform"
22+
tests_dir = "tests"
23+
24+
python_versions = ["3.11", "3.10", "3.9", "3.8", "3.7"]
25+
main_python_version = "3.10"
26+
locations = src_dir, tests_dir, "noxfile.py"
27+
nox.options.sessions = (
28+
"mypy",
29+
"tests",
30+
)
31+
32+
33+
@session(python=python_versions)
34+
def mypy(session: Session) -> None:
35+
"""Check types with mypy."""
36+
args = session.posargs or [src_dir, tests_dir]
37+
session.install(".")
38+
session.install(
39+
"mypy",
40+
"types-requests",
41+
)
42+
session.run("mypy", *args)
43+
if not session.posargs:
44+
session.run("mypy", f"--python-executable={sys.executable}", "noxfile.py")
45+
46+
47+
@session(python=python_versions)
48+
def tests(session: Session) -> None:
49+
"""Execute pytest tests and compute coverage."""
50+
deps = ["pytest"]
51+
if "GITHUB_ACTIONS" in os.environ:
52+
deps.append("pytest-github-actions-annotate-failures")
53+
54+
session.install(".")
55+
session.install(*deps)
56+
session.run("pytest", *session.posargs)

poetry.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ keywords = [
1515
]
1616

1717
[tool.poetry.dependencies]
18-
python = "<3.11,>=3.7.1"
18+
python = "<3.12,>=3.7.1"
1919
singer-sdk = "==0.14.0"
2020
requests-cache = "==0.9.7"
2121
structlog = "==22.3.0"

tox.ini

-33
This file was deleted.

0 commit comments

Comments
 (0)