|
| 1 | +import os |
| 2 | + |
| 3 | +import nox |
| 4 | + |
| 5 | +nox.options.sessions = ["lint", "test"] |
| 6 | + |
| 7 | +basedir = os.path.abspath(os.path.dirname(__file__)) |
| 8 | +about_path = os.path.join(basedir, os.path.join("flask_minify", "about.py")) |
| 9 | +about_content = "" |
| 10 | +test_req_path = os.path.join("requirements", "test.txt") |
| 11 | +dev_req_path = os.path.join("requirements", "dev.txt") |
| 12 | + |
| 13 | +with open(about_path) as f: |
| 14 | + about_content = f.read() |
| 15 | + exec(about_content) # nosec |
| 16 | + |
| 17 | + |
| 18 | +@nox.session(python=__supported_versions__) # type: ignore |
| 19 | +def test(session: nox.session): |
| 20 | + session.install("-r", test_req_path) |
| 21 | + session.run("python", "-m", "pytest") |
| 22 | + session.run("python", "-m", "bandit", "-c", "bandit.yml", "-r", ".") |
| 23 | + |
| 24 | + |
| 25 | +@nox.session |
| 26 | +def lint(session: nox.Session): |
| 27 | + session.install("-r", test_req_path) |
| 28 | + session.run( |
| 29 | + "python", "-m", "isort", "-sg", "**/.nox*", "--profile", "black", "--check", "." |
| 30 | + ) |
| 31 | + session.run("python", "-m", "black", "--check", ".") |
| 32 | + |
| 33 | + |
| 34 | +@nox.session |
| 35 | +def format(session: nox.Session): |
| 36 | + session.install("-r", test_req_path) |
| 37 | + session.run("python", "-m", "isort", "-sg", "**/.nox*", "--profile", "black", ".") |
| 38 | + session.run("python", "-m", "black", ".") |
| 39 | + |
| 40 | + |
| 41 | +@nox.session |
| 42 | +def release(session: nox.Session): |
| 43 | + session.install("-r", dev_req_path) |
| 44 | + session.run("python", "setup.py", "sdist", "bdist_wheel") |
| 45 | + session.run("python", "-m", "twine", "upload", "dist/*") |
| 46 | + session.run("rm", "-rf", "dist", "build", "Flask_Minify.egg-info", ".eggs") |
| 47 | + |
| 48 | + |
| 49 | +@nox.session |
| 50 | +def bump(session: nox.Session): |
| 51 | + old_version = __version__ # type: ignore |
| 52 | + new_version = old_version.split(".") |
| 53 | + new_version[-1] = str(int(new_version[-1]) + 1) |
| 54 | + new_version = ".".join(new_version) |
| 55 | + |
| 56 | + with open(about_path, "w") as f: |
| 57 | + f.write(about_content.replace(old_version, new_version)) |
| 58 | + |
| 59 | + session.run("git", "add", about_path, external=True) |
| 60 | + session.run( |
| 61 | + "git", "commit", "-m", f"chore: bump version to {new_version}", external=True |
| 62 | + ) |
0 commit comments