Skip to content

Commit 0e8f4e7

Browse files
committed
feat: alter sync demo process to use ephemeral github commits for generation so that everything is more accurate
1 parent 964ec8e commit 0e8f4e7

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

.github/workflows/sync-demos.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
with:
2727
repository: ${{ github.repository }}
2828
path: cookiecutter-robust-python
29-
ref: ${{ github.head_ref }}
3029

3130
- name: Checkout Demo
3231
uses: actions/checkout@v4
@@ -44,6 +43,6 @@ jobs:
4443
python-version: ${{ matrix.python-version }}
4544

4645
- name: Update Demo
47-
run: "uvx nox -s 'update-demo(${{ matrix.demo.session_modifier }})'"
46+
run: "uvx nox -s 'update-demo(${{ matrix.demo.session_modifier }})' -- --branch-override ${{ github.head_ref }}"
4847

4948

noxfile.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ def update_demo(session: Session, demo: RepoMetadata) -> None:
196196
if "maturin" in demo.app_name:
197197
args.append("--add-rust-extension")
198198

199+
if session.posargs:
200+
args.extend(session.posargs)
201+
199202
demo_env: dict[str, Any] = {f"ROBUST_DEMO__{key.upper()}": value for key, value in asdict(demo).items()}
200203
session.run("python", UPDATE_DEMO_SCRIPT, *args, env=demo_env)
201204

scripts/update-demo.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,20 @@ def update_demo(
3939
demos_cache_folder: Annotated[Path, FolderOption("--demos-cache-folder", "-c")],
4040
add_rust_extension: Annotated[bool, typer.Option("--add-rust-extension", "-r")] = False,
4141
min_python_version: Annotated[str, typer.Option("--min-python-version")] = "3.10",
42-
max_python_version: Annotated[str, typer.Option("--max-python-version")] = "3.14"
42+
max_python_version: Annotated[str, typer.Option("--max-python-version")] = "3.14",
43+
branch_override: Annotated[Optional[str], typer.Option("--branch-override")] = None
4344
) -> None:
4445
"""Runs precommit in a generated project and matches the template to the results."""
4546
demo_name: str = get_demo_name(add_rust_extension=add_rust_extension)
4647
demo_path: Path = demos_cache_folder / demo_name
4748

48-
current_branch: str = get_current_branch()
49+
if branch_override is not None:
50+
typer.secho(f"Overriding current branch name for demo reference. Using '{branch_override}' instead.")
51+
current_branch: str = branch_override
52+
else:
53+
current_branch: str = get_current_branch()
4954
template_commit: str = get_current_commit()
55+
5056
_validate_template_main_not_checked_out(branch=current_branch)
5157
require_clean_and_up_to_date_demo_repo(demo_path=demo_path)
5258
_checkout_demo_develop_or_existing_branch(demo_path=demo_path, branch=current_branch)

0 commit comments

Comments
 (0)