-
Notifications
You must be signed in to change notification settings - Fork 2
/
noxfile.py
63 lines (49 loc) · 1.75 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
import os
from pathlib import Path
import nox
HERE = Path(__file__).resolve(strict=True).parent
PYTHON_VERSION = HERE.joinpath(".python-version").read_text().strip()
nox.options.pythons = [PYTHON_VERSION]
nox.options.sessions = ["run"]
nox.options.reuse_existing_virtualenvs = True
nox.options.error_on_missing_interpreters = True
@nox.session(python=PYTHON_VERSION)
def lint(session: nox.Session) -> None:
"""Run the linter."""
session.install("-U", "pre-commit")
session.run("pre-commit", "run", "--all-files", *session.posargs)
@nox.session(python=PYTHON_VERSION)
def update_requirements(session: nox.Session) -> None:
"""Update requirements.txt."""
session.install("-U", "pip-tools")
env = os.environ.copy()
# CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to
# regenerate the constraints files
env["CUSTOM_COMPILE_COMMAND"] = f"nox -s {session.name}"
session.run(
"pip-compile",
"--allow-unsafe",
"--upgrade",
"--generate-hashes",
"requirements.in",
env=env,
)
@nox.session(python=PYTHON_VERSION)
def run(session: nox.Session) -> None:
"""Run manylinux-timeline."""
session.install(
"--only-binary",
":all:",
"--require-hashes",
"-r",
"requirements.txt",
)
session.run("python", "update.py", *session.posargs)
@nox.session(python=PYTHON_VERSION)
def serve(session: nox.Session) -> None:
session.run("python", "-m", "http.server", "-d", "build")
@nox.session(python=PYTHON_VERSION, venv_backend="none")
def timestamp(session: nox.Session) -> None:
"""Get timestamp for PyPI package cache on GHA"""
from datetime import datetime, timezone
print(datetime.now(timezone.utc).isoformat())