|
1 | 1 | """Noxfile for the cookiecutter-robust-python template.""" |
2 | 2 | import os |
3 | 3 | import shutil |
4 | | -import tempfile |
5 | 4 | from pathlib import Path |
6 | 5 |
|
7 | 6 | import nox |
|
36 | 35 |
|
37 | 36 | GENERATE_DEMO_SCRIPT: Path = SCRIPTS_FOLDER / "generate-demo.py" |
38 | 37 | GENERATE_DEMO_OPTIONS: tuple[str, ...] = ( |
39 | | - *("--repo-folder", REPO_ROOT), |
40 | 38 | *("--demos-cache-folder", PROJECT_DEMOS_FOLDER), |
41 | | - *("--demo-name", DEFAULT_DEMO_NAME), |
42 | 39 | ) |
43 | 40 |
|
44 | | - |
45 | 41 | LINT_FROM_DEMO_SCRIPT: Path = SCRIPTS_FOLDER / "lint-from-demo.py" |
46 | 42 | LINT_FROM_DEMO_OPTIONS: tuple[str, ...] = GENERATE_DEMO_OPTIONS |
47 | 43 |
|
| 44 | +UPDATE_DEMO_SCRIPT: Path = SCRIPTS_FOLDER / "update-demo.py" |
| 45 | +UPDATE_DEMO_OPTIONS: tuple[str, ...] = GENERATE_DEMO_OPTIONS |
| 46 | + |
48 | 47 |
|
49 | 48 | @nox.session(name="generate-demo", python=DEFAULT_TEMPLATE_PYTHON_VERSION) |
50 | 49 | def generate_demo(session: Session) -> None: |
@@ -123,6 +122,19 @@ def test(session: Session) -> None: |
123 | 122 | session.run("pytest", "tests") |
124 | 123 |
|
125 | 124 |
|
| 125 | +@nox.parametrize(arg_names="add_rust_extension", arg_values_list=[False], ids=["no-rust"]) |
| 126 | +@nox.session(name="update-demo", python=DEFAULT_TEMPLATE_PYTHON_VERSION) |
| 127 | +def update_demo(session: Session, add_rust_extension: bool) -> None: |
| 128 | + session.log("Installing script dependencies for updating generated project demos...") |
| 129 | + session.install("cookiecutter", "cruft", "platformdirs", "loguru", "typer") |
| 130 | + |
| 131 | + session.log("Updating generated project demos...") |
| 132 | + args: list[str] = [*UPDATE_DEMO_OPTIONS] |
| 133 | + if add_rust_extension: |
| 134 | + args.append("--add-rust-extension") |
| 135 | + session.run("python", UPDATE_DEMO_SCRIPT, *args) |
| 136 | + |
| 137 | + |
126 | 138 | @nox.session(venv_backend="none") |
127 | 139 | def release_template(session: Session): |
128 | 140 | """Run the release process for the TEMPLATE using Commitizen. |
@@ -158,3 +170,11 @@ def release_template(session: Session): |
158 | 170 |
|
159 | 171 | session.log("Template version bumped and tag created locally via Commitizen/uvx.") |
160 | 172 | session.log("IMPORTANT: Push commits and tags to remote (`git push --follow-tags`) to trigger CD for the TEMPLATE.") |
| 173 | + |
| 174 | + |
| 175 | +@nox.session(python=False) |
| 176 | +def remove_demo_release(session: Session) -> None: |
| 177 | + """Deletes the latest demo release.""" |
| 178 | + session.run("git", "branch", "-d", f"release/{session.posargs[0]}", external=True) |
| 179 | + session.run("git", "push", "--progress", "--porcelain", "origin", f"release/{session.posargs[0]}", external=True) |
| 180 | + |
0 commit comments