-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathnoxfile.py
152 lines (126 loc) · 4.16 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
from __future__ import annotations
import os
import nox
from nox.sessions import Session
@nox.session(reuse_venv=True)
def format(session: Session) -> None:
"""Run automatic code formatters"""
session.run("poetry", "install", external=True)
session.run("black", ".")
session.run("isort", ".")
session.run("autoflake", "--in-place", ".")
@nox.session(reuse_venv=True)
def tests(session: Session) -> None:
"""Run the complete test suite"""
if os.environ.get("GITHUB_ACTIONS") == "true":
session.notify("test_types")
session.notify("test_style")
session.notify("test_suite")
else:
session.notify("docker_test")
@nox.session(reuse_venv=True)
def docker_test(session: Session) -> None:
"""Run the complete test suite"""
session.notify("test_create_containers")
session.notify("test_types")
session.notify("test_style")
session.notify("test_suite")
session.notify("test_cleanup_containers")
@nox.session(reuse_venv=True)
def test_create_containers(session: Session) -> None:
session.run(
"sudo",
"docker",
"compose",
"-f",
".devcontainer/docker-compose.yml",
"pull",
external=True,
)
session.run(
"sudo",
"docker",
"compose",
"-f",
".devcontainer/docker-compose.yml",
"up",
"-d",
external=True,
)
@nox.session(reuse_venv=True)
def test_cleanup_containers(session: Session) -> None:
session.run(
"sudo",
"docker",
"compose",
"-f",
".devcontainer/docker-compose.yml",
"down",
external=True,
)
session.run("git", "checkout", "--", "tests/docker_configs/", external=True)
@nox.session(reuse_venv=True)
def test_suite(session: Session) -> None:
"""Run the Python-based test suite"""
session.run("poetry", "install", external=True)
session.run(
"pytest",
"--showlocals",
"--reruns",
"3",
"--reruns-delay",
"5",
"--cov=pyarr",
"--cov-report",
"xml",
"--cov-report",
"term-missing",
"-vv",
)
@nox.session(reuse_venv=True)
def test_types(session: Session) -> None:
"""Check that typing is working as expected"""
session.run("poetry", "install", external=True)
session.run("mypy", "--show-error-codes", "pyarr")
@nox.session(reuse_venv=True)
def test_style(session: Session) -> None:
"""Check that style guidelines are being followed"""
session.run("poetry", "install", external=True)
session.run("flake8", "pyarr", "tests")
session.run(
"black",
"pyarr",
"--check",
)
session.run("isort", "pyarr", "--check-only")
session.run("autoflake", "-r", "pyarr")
session.run("interrogate", "pyarr")
@nox.session(reuse_venv=True)
def serve_docs(session: Session) -> None:
"""Create local copy of docs for testing"""
session.run("poetry", "install", external=True)
session.run("sphinx-autobuild", "docs", "build")
@nox.session(reuse_venv=True)
def build_docs(session: Session) -> None:
"""Create local copy of docs for testing"""
session.run("poetry", "install", external=True)
session.run("sphinx-build", "-b", "html", "docs", "build")
@nox.session(reuse_venv=True)
def install_release(session: Session) -> None:
session.run("npm", "install", "@semantic-release/changelog")
session.run("npm", "install", "@semantic-release/exec")
session.run("npm", "install", "@semantic-release/git")
session.run("npm", "install", "@semantic-release/github")
session.run("npm", "install", "conventional-changelog-conventionalcommits@7.0.2")
session.run("npm", "install", "semantic-release-pypi")
@nox.session(reuse_venv=True)
def release(session: Session) -> None:
"""Release a new version of the package"""
pypi_password = session.posargs[0]
session.run("poetry", "install", external=True)
session.notify("install_release")
session.run("npx", "semantic-release", "--debug")
session.run("poetry", "build", external=True)
session.run(
"poetry", "publish", "-u", "__token__", "-p", pypi_password, external=True
)