Skip to content

Commit

Permalink
Fix repo metadata (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep authored Sep 2, 2024
1 parent 336b977 commit f0a10d4
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/assets/cookiecutter-scverse-instance.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author_full_name": "scverse community",
"author_email": "[email protected]",
"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",
Expand Down
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author_full_name": "Your Name",
"author_email": "[email protected]",
"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",
Expand Down
31 changes: 31 additions & 0 deletions scripts/tests/test_build.py
Original file line number Diff line number Diff line change
@@ -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())
5 changes: 2 additions & 3 deletions scripts/tests/test_cruft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions {{cookiecutter.project_name}}/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_name}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_name}}/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
}
Expand Down
5 changes: 3 additions & 2 deletions {{cookiecutter.project_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f0a10d4

Please sign in to comment.