forked from astronomer/astro-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
64 lines (47 loc) · 1.71 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
"""Nox automation definitions."""
import pathlib
import nox
nox.options.sessions = ["dev"]
@nox.session(python="3.9")
def dev(session: nox.Session) -> None:
"""Create a dev environment with everything installed.
This is useful for setting up IDE for autocompletion etc. Point the
development environment to ``.nox/dev``.
"""
session.install("nox")
session.install("-e", ".[tests]")
@nox.session(python=["3.7", "3.8", "3.9"])
def test(session: nox.Session) -> None:
"""Run unit tests."""
session.install("-e", ".[tests]")
session.run("airflow", "db", "init")
session.run("pytest", *session.posargs)
@nox.session()
def lint(session: nox.Session) -> None:
"""Run linters."""
session.install("pre-commit")
if session.posargs:
args = [*session.posargs, "--all-files"]
else:
args = ["--all-files", "--show-diff-on-failure"]
session.run("pre-commit", "run", *args)
@nox.session()
def build(session: nox.Session) -> None:
"""Build release artifacts."""
session.install("build")
# TODO: Automate version bumping, Git tagging, and more?
dist = pathlib.Path("dist")
if dist.exists() and next(dist.iterdir(), None) is not None:
session.error(
"There are files in dist/. Remove them and try again. "
"You can use `git clean -fxdi -- dist` command to do this."
)
dist.mkdir(exist_ok=True)
session.run("python", "-m", "build", *session.posargs)
@nox.session()
def release(session: nox.Session) -> None:
"""Publish a release."""
session.install("twine")
# TODO: Better artifact checking.
session.run("twine", "check", *session.posargs)
session.run("twine", "upload", *session.posargs)