diff --git a/.github/assets/cookiecutter-scverse-instance.json b/.github/assets/cookiecutter-scverse-instance.json index a2a83089..41f7a2a6 100644 --- a/.github/assets/cookiecutter-scverse-instance.json +++ b/.github/assets/cookiecutter-scverse-instance.json @@ -6,7 +6,7 @@ "author_full_name": "scverse community", "author_email": "core-team@scverse.org", "github_user": "scverse", - "project_repo": "https://github.com/scverse/cookiecutter-scverse-instance", + "github_repo": "cookiecutter-scverse-instance", "license": "BSD 3-Clause License", "_copy_without_render": [ ".github/workflows/**.yaml", diff --git a/.gitignore b/.gitignore index 342a7a52..a295123a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,16 +2,14 @@ .DS_Store *~ +# Caches +__pycache__/ +.*cache/ + # Distribution / packaging -/build/ /dist/ -/*.egg-info/ # Tests and coverage -__pycache__/ -.ruff_cache/ -/.pytest_cache/ -/.cache/ /data/ /node_modules/ diff --git a/cookiecutter.json b/cookiecutter.json index ea87fe6d..cf40b568 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -5,7 +5,7 @@ "author_full_name": "Your Name", "author_email": "yourname@example.com", "github_user": "your_github_username", - "project_repo": "https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.project_name }}", + "github_repo": "{{ cookiecutter.project_name }}", "license": [ "MIT License", "BSD 2-Clause License", diff --git a/scripts/tests/test_build.py b/scripts/tests/test_build.py new file mode 100644 index 00000000..e8d00fb4 --- /dev/null +++ b/scripts/tests/test_build.py @@ -0,0 +1,31 @@ +from __future__ import annotations + +import re +from pathlib import Path +from typing import TYPE_CHECKING + +import pytest +from cookiecutter.main import cookiecutter + +if TYPE_CHECKING: + from collections.abc import Mapping + from typing import Any + + +HERE = Path(__file__).parent + + +@pytest.mark.parametrize( + ("params", "path", "pattern"), + [ + ({}, "docs/conf.py", r'"github_repo": project_name,'), + ({"github_repo": "floob"}, "docs/conf.py", r'"github_repo": "floob",'), + ], +) +def test_build(tmp_path: Path, params: Mapping[str, Any], path: Path | str, pattern: re.Pattern | str): + cookiecutter(str(HERE.parent.parent), output_dir=tmp_path, no_input=True, extra_context=params) + proj_dir = tmp_path / "project-name" + assert proj_dir.is_dir() + path = proj_dir / path + pattern = re.compile(pattern, re.MULTILINE) + assert pattern.search(path.read_text()) diff --git a/scripts/tests/test_cruft.py b/scripts/tests/test_cruft.py index 1e34ab38..e4b25229 100644 --- a/scripts/tests/test_cruft.py +++ b/scripts/tests/test_cruft.py @@ -36,9 +36,8 @@ class MockRelease: @pytest.fixture def con(response_mock) -> GitHubConnection: resp = json.dumps({"login": "scverse-bot"}) - with catch_warnings(): - with response_mock(f"GET https://api.github.com:443/users/scverse-bot -> 200 :{resp}"): - return GitHubConnection("scverse-bot") + with catch_warnings(), response_mock(f"GET https://api.github.com:443/users/scverse-bot -> 200 :{resp}"): + return GitHubConnection("scverse-bot") @pytest.fixture diff --git a/{{cookiecutter.project_name}}/.gitignore b/{{cookiecutter.project_name}}/.gitignore index eeec7e29..d01a5d5d 100644 --- a/{{cookiecutter.project_name}}/.gitignore +++ b/{{cookiecutter.project_name}}/.gitignore @@ -6,17 +6,12 @@ buck-out/ # Compiled files .venv/ __pycache__/ -.mypy_cache/ -.ruff_cache/ +.*cache/ # Distribution / packaging -/build/ /dist/ -/*.egg-info/ # Tests and coverage -/.pytest_cache/ -/.cache/ /data/ /node_modules/ diff --git a/{{cookiecutter.project_name}}/README.md b/{{cookiecutter.project_name}}/README.md index 06123708..d907f1fa 100644 --- a/{{cookiecutter.project_name}}/README.md +++ b/{{cookiecutter.project_name}}/README.md @@ -4,7 +4,7 @@ [![Documentation][badge-docs]][link-docs] [badge-tests]: https://img.shields.io/github/actions/workflow/status/{{ cookiecutter.github_user }}/{{ cookiecutter.project_name }}/test.yaml?branch=main -[link-tests]: {{ cookiecutter.project_repo }}/actions/workflows/test.yml +[link-tests]: https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.github_repo }}/actions/workflows/test.yml [badge-docs]: https://img.shields.io/readthedocs/{{ cookiecutter.project_name }} {{ cookiecutter.project_description }} @@ -33,7 +33,7 @@ pip install {{ cookiecutter.project_name }} 1. Install the latest development version: ```bash -pip install git+{{ cookiecutter.project_repo }}.git@main +pip install git+https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.github_repo }}.git@main ``` ## Release notes diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.project_name}}/docs/conf.py index 312f8699..4197a427 100644 --- a/{{cookiecutter.project_name}}/docs/conf.py +++ b/{{cookiecutter.project_name}}/docs/conf.py @@ -37,7 +37,7 @@ html_context = { "display_github": True, # Integrate GitHub "github_user": "{{cookiecutter.github_user}}", - "github_repo": "{{cookiecutter.project_repo}}", + "github_repo": {% if cookiecutter.project_name == cookiecutter.github_repo %}project_name{% else %}"{{cookiecutter.github_repo}}"{% endif %}, "github_version": "main", "conf_py_path": "/docs/", } diff --git a/{{cookiecutter.project_name}}/pyproject.toml b/{{cookiecutter.project_name}}/pyproject.toml index 7a7a36e3..5f91b7dd 100644 --- a/{{cookiecutter.project_name}}/pyproject.toml +++ b/{{cookiecutter.project_name}}/pyproject.toml @@ -15,9 +15,10 @@ authors = [ maintainers = [ {name = "{{ cookiecutter.author_full_name }}", email = "{{ cookiecutter.author_email }}"}, ] +# https://docs.pypi.org/project_metadata/#project-urls urls.Documentation = "https://{{ cookiecutter.project_name }}.readthedocs.io/" -urls.Source = "{{ cookiecutter.project_repo }}" -urls.Home-page = "{{ cookiecutter.project_repo }}" +urls.Source = "https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.github_repo }}" +urls.Homepage = "https://github.com/{{ cookiecutter.github_user }}/{{ cookiecutter.github_repo }}" dependencies = [ "anndata", # for debug logging (referenced from the issue template)