-
Notifications
You must be signed in to change notification settings - Fork 6
/
noxfile.py
78 lines (57 loc) · 1.73 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
import os
import nox
source_files = (
"hstspreload/",
"test_hstspreload.py",
"build-hstspreload.py",
"setup.py",
"noxfile.py",
)
@nox.session(reuse_venv=True)
def format(session):
session.install("-rrequirements/lint.txt")
session.run("autoflake", "--in-place", "--recursive", *source_files)
session.run(
"isort",
"--profile=black",
*source_files,
)
session.run("black", "--target-version=py36", *source_files)
lint(session)
@nox.session(reuse_venv=True)
def lint(session):
session.install("-rrequirements/lint.txt")
session.run("black", "--check", "--target-version=py36", *source_files)
session.run("flake8", "--max-line-length=88", "--ignore=W503,E203", *source_files)
@nox.session(reuse_venv=True)
def build(session):
session.install("-rrequirements/test.txt")
session.run("python", "build-hstspreload.py")
@nox.session(reuse_venv=True)
def test(session):
session.install("-rrequirements/test.txt")
session.install(".")
session.run("python", "-m", "pytest", "-q", "test_hstspreload.py")
@nox.session(reuse_venv=True)
def deploy(session):
session.install("-rrequirements/deploy.txt")
if os.path.isdir("dist"):
session.run("rm", "-rf", "dist/*")
session.run("python", "-m", "build")
if os.getenv("PYPI_TOKEN"):
username = "__token__"
password = os.getenv("PYPI_TOKEN")
else:
username = os.environ["PYPI_USERNAME"]
password = os.environ["PYPI_PASSWORD"]
session.run(
"python",
"-m",
"twine",
"upload",
"--skip-existing",
"dist/*",
f"--username={username}",
f"--password={password}",
success_codes=[0, 1],
)