From 443b4150bfb5c930c859b64d53ddac2b2c229a91 Mon Sep 17 00:00:00 2001 From: "Xuan (Sean) Hu" Date: Fri, 10 May 2024 11:45:09 +0800 Subject: [PATCH] chore: change repo_host_type to repo_platform (#533) Signed-off-by: Xuan (Sean) Hu Co-authored-by: msclock --- Makefile | 2 +- copier.yaml | 31 +++++++++++-------- includes/copier-answers-sample.yml | 2 +- includes/sample.jinja | 2 +- includes/variable.jinja | 22 ++++++------- template/.renovaterc.json.jinja | 6 ++-- template/Makefile.jinja | 2 +- .../FUNDING.yml.jinja | 0 .../workflows/ci.yml.jinja | 0 .../workflows/commitlint.yml | 0 .../delete-untagged-packages.yml.jinja | 0 .../workflows/devcontainer.yml.jinja | 0 .../workflows/readthedocs-preview.yml.jinja | 0 .../workflows/release.yml.jinja | 0 .../workflows/renovate.yml.jinja | 0 ...anaged' %].gitlab-ci.yml[% endif %].jinja} | 0 .../workflows/ci.yml.jinja | 0 .../workflows/commitlint.yml | 0 .../workflows/devcontainer.yml.jinja | 0 .../workflows/release.yml.jinja | 0 .../workflows/renovate.yml | 0 template/pyproject.toml.jinja | 4 +-- 22 files changed, 38 insertions(+), 33 deletions(-) rename template/{[% if repo_host_type == 'github.com' %].github[% endif %] => [% if repo_platform == 'github' %].github[% endif %]}/FUNDING.yml.jinja (100%) rename template/{[% if repo_host_type == 'github.com' %].github[% endif %] => [% if repo_platform == 'github' %].github[% endif %]}/workflows/ci.yml.jinja (100%) rename template/{[% if repo_host_type == 'github.com' %].github[% endif %] => [% if repo_platform == 'github' %].github[% endif %]}/workflows/commitlint.yml (100%) rename template/{[% if repo_host_type == 'github.com' %].github[% endif %] => [% if repo_platform == 'github' %].github[% endif %]}/workflows/delete-untagged-packages.yml.jinja (100%) rename template/{[% if repo_host_type == 'github.com' %].github[% endif %] => [% if repo_platform == 'github' %].github[% endif %]}/workflows/devcontainer.yml.jinja (100%) rename template/{[% if repo_host_type == 'github.com' %].github[% endif %] => [% if repo_platform == 'github' %].github[% endif %]}/workflows/readthedocs-preview.yml.jinja (100%) rename template/{[% if repo_host_type == 'github.com' %].github[% endif %] => [% if repo_platform == 'github' %].github[% endif %]}/workflows/release.yml.jinja (100%) rename template/{[% if repo_host_type == 'github.com' %].github[% endif %] => [% if repo_platform == 'github' %].github[% endif %]}/workflows/renovate.yml.jinja (100%) rename template/{[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja => [% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja} (100%) rename template/{[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %] => [% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]}/workflows/ci.yml.jinja (100%) rename template/{[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %] => [% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]}/workflows/commitlint.yml (100%) rename template/{[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %] => [% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]}/workflows/devcontainer.yml.jinja (100%) rename template/{[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %] => [% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]}/workflows/release.yml.jinja (100%) rename template/{[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %] => [% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]}/workflows/renovate.yml (100%) diff --git a/Makefile b/Makefile index e0f774f5..896028f2 100644 --- a/Makefile +++ b/Makefile @@ -154,7 +154,7 @@ doc: changelog doc-gen doc-mypy doc-coverage consistency: find . -maxdepth 1 | grep -vE '(\.|\.git|template|includes|copier\.yaml|pdm\.lock)$$' | xargs -I {} rm -r {} - copier copy -r HEAD --data-file includes/copier-answers-sample.yml --data repo_host_type=gitlab.com -f . . + copier copy -r HEAD --data-file includes/copier-answers-sample.yml --data repo_platform=gitlab -f . . rm -rf .copier-answers.yml copier copy -r HEAD --data-file includes/copier-answers-sample.yml -f . . rm -rf .copier-answers.yml diff --git a/copier.yaml b/copier.yaml index 2cd7ad4c..cd0fb22c 100644 --- a/copier.yaml +++ b/copier.yaml @@ -67,39 +67,44 @@ author_email: default: '{{ author_name|lower|replace(" ", ".") }}@{{ organization_name|lower|replace(" ", "-") }}.com' help: 'Specify the email address of the author:' type: str -repo_host_type: - default: github.com +repo_platform: + default: github choices: - GitHub: github.com - GitLab: gitlab.com + GitHub: github + GitLab: gitlab GitLab (self-managed): gitlab-self-managed - help: 'Choose the host for the repository:' + help: 'Choose the platform for the repository:' type: str repo_host: - default: '{{ repo_host_type }}' + default: |- + [% if repo_platform == 'github' -%] + github.com + [%- elif repo_platform == 'gitlab' -%] + gitlab.com + [%- endif %] help: 'Specify the host of the self-managed GitLab:' type: str - when: '{{ repo_host_type == "gitlab-self-managed" }}' + when: '{{ repo_platform == "gitlab-self-managed" }}' page_host: default: |- - [% if repo_host_type == 'github.com' -%] + [% if repo_platform == 'github' -%] github.io - [%- elif repo_host_type == 'gitlab.com' -%] + [%- elif repo_platform == 'gitlab' -%] gitlab.io [%- endif %] help: 'Specify the host of the self-managed GitLab Pages:' type: str - when: '{{ repo_host_type == "gitlab-self-managed" }}' + when: '{{ repo_platform == "gitlab-self-managed" }}' container_registry_host: default: |- - [% if repo_host_type == 'github.com' -%] + [% if repo_platform == 'github' -%] ghcr.io - [%- elif repo_host_type == 'gitlab.com' -%] + [%- elif repo_platform == 'gitlab' -%] registry.gitlab.com [%- endif %] help: 'Specify the host of the self-managed GitLab Container Registry:' type: str - when: '{{ repo_host_type == "gitlab-self-managed" }}' + when: '{{ repo_platform == "gitlab-self-managed" }}' repo_namespace: default: '{{ organization_name|lower|replace(" ", "-") }}' help: 'Indicate the GitHub Repository Owner or GitLab Namespace. This is typically the account name of the author or the organization:' diff --git a/includes/copier-answers-sample.yml b/includes/copier-answers-sample.yml index d6043bb7..89fac73f 100644 --- a/includes/copier-answers-sample.yml +++ b/includes/copier-answers-sample.yml @@ -19,6 +19,6 @@ project_description: An evolving Python project template that covers the full development lifecycle. project_name: Serious Scaffold Python -repo_host_type: github.com repo_name: ss-python repo_namespace: serious-scaffold +repo_platform: github diff --git a/includes/sample.jinja b/includes/sample.jinja index 4e7646ba..cc6dead4 100644 --- a/includes/sample.jinja +++ b/includes/sample.jinja @@ -7,7 +7,7 @@ Setting up a project often involves more than just establishing a basic project structure. It involves tasks like integrating GitHub Actions or GitLab CI/CD, configuring lint, test and documentation, as well as implementing settings, logging and other frequently used modules. [Serious Scaffold Python](https://github.com/serious-scaffold/ss-python) streamlines this process. Powered by [`copier`](https://copier.readthedocs.io/), bootstrapping a new Python project can be done with a single command. By answering a few questions, the project will be fully configured and ready for development. Furthermore, the project can be updated alongside the advancement of the template. -[% if repo_host_type == 'github.com' -%] +[% if repo_platform == 'github' -%] If you find this helpful, please consider [sponsorship](https://github.com/sponsors/{{ author_name }}). [% endif -%] diff --git a/includes/variable.jinja b/includes/variable.jinja index c61ae8db..41bec460 100644 --- a/includes/variable.jinja +++ b/includes/variable.jinja @@ -1,23 +1,23 @@ [% macro coverage_badge() -%] - [% if repo_host_type == 'github.com' -%] + [% if repo_platform == 'github' -%] [![Coverage](https://img.shields.io/endpoint?url=https://{{ page_url() }}/_static/badges/coverage.json)](https://{{ page_url() }}/reports/coverage) - [%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] + [%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%] [![coverage report](https://{{ repo_url() }}/badges/main/coverage.svg)](https://{{ repo_url() }}/-/commits/main) [%- endif %] [%- endmacro %] [% macro license_badge() -%] - [% if repo_host_type == 'github.com' -%] + [% if repo_platform == 'github' -%] [![GitHub](https://img.shields.io/github/license/{{ repo_namespace }}/{{ repo_name }})]({{ license_url() }}) - [%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] + [%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%] [![GitLab](https://img.shields.io/gitlab/license/{{ repo_namespace }}/{{ repo_name }}?gitlab_url=https%3A%2F%2F{{ repo_host }})]({{ license_url() }}) [%- endif -%] [%- endmacro %] [% macro license_url() -%] - [% if repo_host_type == 'github.com' -%] + [% if repo_platform == 'github' -%] https://{{ repo_url() }}/blob/main/LICENSE - [%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] + [%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%] https://{{ repo_url() }}/-/blob/main/LICENSE [%- endif -%] [%- endmacro %] @@ -31,28 +31,28 @@ [%- endmacro %] [% macro page_url() -%] - [% if repo_host_type == 'github.com' -%] + [% if repo_platform == 'github' -%] {{ repo_namespace }}.github.io/{{ repo_name }} - [%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] + [%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%] [%- set repo_namespace_root = repo_namespace.split("/")[0] -%] {{ repo_namespace_root }}.{{ page_host }}{{ repo_namespace | replace(repo_namespace_root, "", 1) }}/{{ repo_name }} [%- endif %] [%- endmacro %] [% macro pipeline_badge() -%] - [% if repo_host_type == 'github.com' -%] + [% if repo_platform == 'github' -%] [![CI](https://{{ repo_url() }}/actions/workflows/ci.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/ci.yml) [![CommitLint](https://{{ repo_url() }}/actions/workflows/commitlint.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/commitlint.yml) [![DevContainer](https://{{ repo_url() }}/actions/workflows/devcontainer.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/devcontainer.yml) [![Release](https://{{ repo_url() }}/actions/workflows/release.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/release.yml) [![Renovate](https://{{ repo_url() }}/actions/workflows/renovate.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/renovate.yml) - [%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] + [%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%] [![pipeline status](https://{{ repo_url() }}/badges/main/pipeline.svg)](https://{{ repo_url() }}/-/commits/main) [%- endif %] [%- endmacro %] [% macro release_badge() -%] - [%- if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] + [%- if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%] [![Latest Release](https://{{ repo_url() }}/-/badges/release.svg)](https://{{ repo_url() }}/-/releases) [%- endif -%] [![PyPI](https://img.shields.io/pypi/v/{{ package_name }})](https://pypi.org/project/{{ package_name }}/) diff --git a/template/.renovaterc.json.jinja b/template/.renovaterc.json.jinja index 4beb7b94..b1d37fb8 100644 --- a/template/.renovaterc.json.jinja +++ b/template/.renovaterc.json.jinja @@ -97,7 +97,7 @@ ":enablePreCommit", ":maintainLockFilesWeekly" ], -[%- if repo_host_type == "gitlab.com" or reop_host_type == "gitlab-self-managed" or project_name == "Serious Scaffold Python" %] +[%- if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' or project_name == 'Serious Scaffold Python' %] "gitlabci": { "fileMatch": [ "^.gitlab/workflows/.*\\.yml$" @@ -203,10 +203,10 @@ "github-tags" ], "matchDepNames": [ -[%- if repo_host_type == "github.com" %] +[%- if repo_platform == "github" %] "ghcr.io/renovatebot/renovate", [%- endif %] -[%- if repo_host_type == "gitlab.com" or reop_host_type == "gitlab-self-managed" or project_name == "Serious Scaffold Python" %] +[%- if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' or project_name == 'Serious Scaffold Python' %] "renovate/renovate", [%- endif %] "renovatebot/pre-commit-hooks" diff --git a/template/Makefile.jinja b/template/Makefile.jinja index 6cc4ac70..08415099 100644 --- a/template/Makefile.jinja +++ b/template/Makefile.jinja @@ -157,7 +157,7 @@ doc: changelog doc-gen doc-mypy doc-coverage consistency: find . -maxdepth 1 | grep -vE '(\.|\.git|template|includes|copier\.yaml|pdm\.lock)$$' | xargs -I {} rm -r {} - copier copy -r HEAD --data-file includes/copier-answers-sample.yml --data repo_host_type=gitlab.com -f . . + copier copy -r HEAD --data-file includes/copier-answers-sample.yml --data repo_platform=gitlab -f . . rm -rf .copier-answers.yml copier copy -r HEAD --data-file includes/copier-answers-sample.yml -f . . rm -rf .copier-answers.yml diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/FUNDING.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/FUNDING.yml.jinja similarity index 100% rename from template/[% if repo_host_type == 'github.com' %].github[% endif %]/FUNDING.yml.jinja rename to template/[% if repo_platform == 'github' %].github[% endif %]/FUNDING.yml.jinja diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja similarity index 100% rename from template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja rename to template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/commitlint.yml b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/commitlint.yml similarity index 100% rename from template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/commitlint.yml rename to template/[% if repo_platform == 'github' %].github[% endif %]/workflows/commitlint.yml diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/delete-untagged-packages.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/delete-untagged-packages.yml.jinja similarity index 100% rename from template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/delete-untagged-packages.yml.jinja rename to template/[% if repo_platform == 'github' %].github[% endif %]/workflows/delete-untagged-packages.yml.jinja diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja similarity index 100% rename from template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/devcontainer.yml.jinja rename to template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/readthedocs-preview.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/readthedocs-preview.yml.jinja similarity index 100% rename from template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/readthedocs-preview.yml.jinja rename to template/[% if repo_platform == 'github' %].github[% endif %]/workflows/readthedocs-preview.yml.jinja diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja similarity index 100% rename from template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja rename to template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/renovate.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/renovate.yml.jinja similarity index 100% rename from template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/renovate.yml.jinja rename to template/[% if repo_platform == 'github' %].github[% endif %]/workflows/renovate.yml.jinja diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja similarity index 100% rename from template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja rename to template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja similarity index 100% rename from template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja rename to template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/commitlint.yml b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/commitlint.yml similarity index 100% rename from template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/commitlint.yml rename to template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/commitlint.yml diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja similarity index 100% rename from template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja rename to template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja similarity index 100% rename from template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja rename to template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/renovate.yml b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/renovate.yml similarity index 100% rename from template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/renovate.yml rename to template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/renovate.yml diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index 92e1d1b6..7338d29d 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -77,9 +77,9 @@ requires-python = ">={{ min_py }}" [project.urls] documentation = "https://{{ page_url() }}" -[% if repo_host_type == 'github.com' -%] +[% if repo_platform == 'github' -%] issue = "https://{{ repo_url() }}/issues" -[%- elif repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' -%] +[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%] issue = "https://{{ repo_url() }}/-/issues" [%- endif %] repository = "https://{{ repo_url() }}"