-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnoxfile.py
More file actions
53 lines (35 loc) · 1.11 KB
/
noxfile.py
File metadata and controls
53 lines (35 loc) · 1.11 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
import os
import shutil
import stat
from pathlib import Path
from typing import Any
import nox
CTT_DIR = Path(".ctt")
nox.options.default_venv_backend = "uv|virtualenv"
nox.options.reuse_existing_virtualenvs = True
nox.options.stop_on_first_error = True
nox.options.sessions = [
"ctt",
]
@nox.session()
def ctt(session: nox.Session):
session.install("copier-template-tester")
for git_dir in CTT_DIR.glob("*/.git"):
try_rmtree(session, git_dir)
session.run("python", "ctt_strict.py", silent=not is_ci())
@nox.session(python=False)
def clean(session: nox.Session):
try_rmtree(session, CTT_DIR)
# helper functions
def try_rmtree(session: nox.Session, path: Path):
if not path.is_dir():
return
session.log(f"Removing directory: {path}")
shutil.rmtree(path, onerror=on_rm_error)
def on_rm_error(func: Any, path: str, exc_info: Any):
# from: https://stackoverflow.com/questions/4829043/how-to-remove-read-only-attrib-directory-with-python-in-windows
path_ = Path(path)
path_.chmod(stat.S_IWRITE)
path_.unlink()
def is_ci():
return os.getenv("CI") == "true"