From 81248ff021474e285cc0ce43bf57221d8de5b66c Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Fri, 13 Sep 2024 09:50:46 +0000 Subject: [PATCH] Only generate catalog info when in DiamondLightSource Doesn't make sense in per-user repos as they aren't scanned. Also doesn't make sense for bluesky --- copier.yml | 17 ++++++++++------- ...urce\" %}catalog-info.yaml{% endif %}.jinja" | 0 tests/test_example.py | 8 ++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) rename template/catalog-info.yaml.jinja => "template/{% if github_org == \"DiamondLightSource\" %}catalog-info.yaml{% endif %}.jinja" (100%) diff --git a/copier.yml b/copier.yml index 84dec3b4..046b88b2 100644 --- a/copier.yml +++ b/copier.yml @@ -2,7 +2,7 @@ package_name: type: str help: | - Name of the python import package. + Name of the python import package. Must be a valid python identifier, i.e. my_package validator: >- {% if not (package_name | regex_search('^[a-zA-Z][a-zA-Z_0-9]+$')) %} @@ -58,20 +58,22 @@ author_email: help: Your email address placeholder: email@diamond.ac.uk +# Catalog info component_owner: type: str + when: "{{ github_org == 'DiamondLightSource' }}" help: | - The unique name of the person or group who owns this component in + The unique name of the person or group who owns this component in the Developer Portal Software Catalogue. - This will normally be group:default/. For a full list of groups visit + This will normally be group:default/. For a full list of groups visit https://dev-portal.diamond.ac.uk/catalog?filters%5Bkind%5D=group&filters%5Buser%5D=all and hover over each group link to see its group ID, e.g. https://dev-portal.diamond.ac.uk/catalog/default/group/accelerator-controls would go here as group:default/accelerator-controls. - component_type: type: str + when: "{{ github_org == 'DiamondLightSource' }}" help: | Type of the component in the Developer Portal Software Catalogue. Most likely service, library or application (without quotes). @@ -84,8 +86,9 @@ component_type: component_lifecycle: type: str + when: "{{ github_org == 'DiamondLightSource' }}" help: | - Project's current lifecycle stage, to be displayed in the Developer + Project's current lifecycle stage, to be displayed in the Developer Portal Software Catalogue. choices: - experimental @@ -147,6 +150,6 @@ _tasks: _migrations: - version: 2.0.0 before: - - echo This update will require you to login to pypi.org and make changes before you can make a new release to PyPI. If you do not have time to do this now, press CTRL+C to abort this update. + - echo This update will require you to login to pypi.org and make changes before you can make a new release to PyPI. If you do not have time to do this now, press CTRL+C to abort this update. after: - - echo Visit https://diamondlightsource.github.io/python-copier-template/main/how-to/pypi.html to find out how to set up PyPI trusted publishing + - echo Visit https://diamondlightsource.github.io/python-copier-template/main/how-to/pypi.html to find out how to set up PyPI trusted publishing diff --git a/template/catalog-info.yaml.jinja "b/template/{% if github_org == \"DiamondLightSource\" %}catalog-info.yaml{% endif %}.jinja" similarity index 100% rename from template/catalog-info.yaml.jinja rename to "template/{% if github_org == \"DiamondLightSource\" %}catalog-info.yaml{% endif %}.jinja" diff --git a/tests/test_example.py b/tests/test_example.py index dfefaaf8..cae1e6fc 100644 --- a/tests/test_example.py +++ b/tests/test_example.py @@ -49,6 +49,8 @@ def test_template_defaults(tmp_path: Path): run = make_venv(tmp_path) container_doc = tmp_path / "docs" / "how-to" / "run-container.md" assert container_doc.exists() + catalog_info = tmp_path / "catalog-info.yaml" + assert catalog_info.exists() run("./venv/bin/tox -p") run("./venv/bin/pip install build twine") run("./venv/bin/python -m build") @@ -114,6 +116,12 @@ def test_template_no_docs(tmp_path: Path): run("./venv/bin/tox -p") +def test_template_in_different_org_has_no_catalog(tmp_path: Path): + copy_project(tmp_path, github_org="bluesky") + catalog_info = tmp_path / "catalog-info.yaml" + assert not catalog_info.exists() + + def test_template_no_docker_has_no_docs_and_works(tmp_path: Path): copy_project(tmp_path, docker=False) container_doc = tmp_path / "docs" / "how-to" / "run-container.md"