Skip to content

Commit 973bd8d

Browse files
committed
build: add setup-venv as a nox session and expand upon the setup-git session
1 parent 0dc51bf commit 973bd8d

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

{{cookiecutter.project_name}}/noxfile.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
REPO_ROOT: Path = Path(__file__).parent
2727
CRATES_FOLDER: Path = REPO_ROOT / "rust"
2828
PACKAGE_NAME: str = "{{cookiecutter.package_name}}"
29+
GITHUB_USER: str = "{{cookiecutter.github_user}}"
2930

3031

31-
@nox.session(python=DEFAULT_PYTHON_VERSION, name="setup-repo")
32+
@nox.session(python=None, name="setup-repo")
3233
def setup_repo(session: Session) -> None:
3334
"""Set up the repository for development.
3435
@@ -37,23 +38,36 @@ def setup_repo(session: Session) -> None:
3738
"""
3839
session.log("Installing development dependencies...")
3940
session.notify("setup-git")
40-
session.notify("setup-branches")
41-
session.install("-e", ".", "--group", "dev")
41+
session.notify("setup-venv")
4242

4343

44-
@nox.session(python=DEFAULT_PYTHON_VERSION, name="setup-git")
44+
@nox.session(python=None, name="setup-git")
4545
def setup_git(session: Session) -> None:
4646
"""Set up the git repo for the current project."""
4747
session.run("git", "init")
4848
session.run("git", "branch", "-M", "main")
49+
50+
session.run(
51+
"git", "remote", "add", "origin", f"https://github.com/{GITHUB_USER}/{PACKAGE_NAME}.git", "||", "true"
52+
)
53+
session.run("git", "remote", "set-url", "origin", f"https://github.com/{GITHUB_USER}/{PACKAGE_NAME}.git")
54+
session.run("git", "fetch", "origin")
55+
56+
session.run("git", "push", "-u", "origin", "main")
57+
session.run("git", "checkout", "-b", "develop", "main")
58+
session.run("git", "push", "-u", "origin", "develop")
59+
4960
session.run("git", "add", ".")
5061
session.run("git", "commit", "-m", "feat: initial commit")
62+
session.run("git", "push", "origin", "develop")
5163

5264

53-
@nox.session(python=DEFAULT_PYTHON_VERSION, name="setup-branches")
54-
def setup_branches(session: Session) -> None:
55-
"""Set up the git repo for the current project."""
56-
session.run("git", "checkout", "-b", "develop", "main")
65+
@nox.session(python=None, name="setup-venv")
66+
def setup_venv(session: Session) -> None:
67+
session.run("uv", "venv", ".venv", external=True)
68+
session.run("uv", "python", "install", PYTHON_VERSIONS[0], external=True)
69+
session.run("uv", "python", "pin", PYTHON_VERSIONS[0], external=True)
70+
session.run("uv", "sync", "--all-groups", external=True)
5771

5872

5973
@nox.session(python=DEFAULT_PYTHON_VERSION, name="pre-commit")

0 commit comments

Comments
 (0)