Skip to content

Commit

Permalink
chore: change repo_host_type to repo_platform (#533)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuan (Sean) Hu <[email protected]>
Co-authored-by: msclock <[email protected]>
  • Loading branch information
huxuan and msclock authored May 10, 2024
1 parent 21db07d commit 443b415
Show file tree
Hide file tree
Showing 22 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 18 additions & 13 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:'
Expand Down
2 changes: 1 addition & 1 deletion includes/copier-answers-sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion includes/sample.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%]
Expand Down
22 changes: 11 additions & 11 deletions includes/variable.jinja
Original file line number Diff line number Diff line change
@@ -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 %]
Expand All @@ -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 }}/)
Expand Down
6 changes: 3 additions & 3 deletions template/.renovaterc.json.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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$"
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion template/Makefile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}"
Expand Down

0 comments on commit 443b415

Please sign in to comment.