-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathnoxfile.py
More file actions
88 lines (74 loc) · 2.15 KB
/
Copy pathnoxfile.py
File metadata and controls
88 lines (74 loc) · 2.15 KB
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
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
import glob
from typing import Dict
import nox
SRC_DIRS = [
"gcm",
]
INTERNAL_TESTS_GLOB = "**/tests/*_internal.py"
@nox.session
def tests(session: nox.Session) -> None:
session.install("-r", "dev-requirements.txt")
session.install("--no-deps", "-e", ".")
env_fname = ".env"
try:
env = _env_from_file(env_fname)
except FileNotFoundError:
session.debug(
f"File '{env_fname}' does not exist. Not running with modified environment."
)
env = None
session.run(
"pytest",
"--ignore-glob",
INTERNAL_TESTS_GLOB,
"-n",
"auto",
*session.posargs,
env=env,
)
@nox.session
def internal_tests(session: nox.Session) -> None:
session.install("-r", "dev-requirements.txt")
session.install("--no-deps", "-e", ".")
env_fname = ".env"
try:
env = _env_from_file(env_fname)
except FileNotFoundError:
session.debug(
f"File '{env_fname}' does not exist. Not running with modified environment."
)
env = None
internal_test_files = glob.glob(INTERNAL_TESTS_GLOB)
session.run("pytest", *internal_test_files, "-n", "auto", *session.posargs, env=env)
def _env_from_file(fname: str) -> Dict[str, str]:
with open(fname) as f:
env = {}
for line in f:
k, v = line.rstrip().split("=", maxsplit=1)
env[k] = v
return env
@nox.session
def lint(session: nox.Session) -> None:
session.install("-r", "dev-requirements.txt")
session.install("--no-deps", "-e", ".")
session.run(
"flake8",
"--per-file-ignores=gcm/_version.py:F401",
*SRC_DIRS,
)
@nox.session
def format(session: nox.Session) -> None:
session.install("-r", "dev-requirements.txt")
session.install("--no-deps", "-e", ".")
session.run(
"ufmt",
"check",
*SRC_DIRS,
)
@nox.session
def typecheck(session: nox.Session) -> None:
session.install("-r", "dev-requirements.txt")
session.install("--no-deps", "-e", ".")
session.run("mypy", *SRC_DIRS)