Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
- name: Install dependencies
run: uv sync
- name: Set git identity
run: |
git config --global user.email "ci-example-user@xomnia.com"
git config --global user.name "CI Example User"
- name: Run pytest
run: uv run pytest
# Single aggregate check to require in the branch ruleset. It depends on
Expand Down
21 changes: 20 additions & 1 deletion copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ _tasks:
- "git checkout -b main"
- "uv sync"
- "uv run pre-commit install"
- "git add --all -- :!branch_protection_rules.json"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this exclude branch_protection_rules.jsonfrom the commit? Should we add it to.gitignore` then?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that's possible as the file was checked in already, but generally that would also ignore the file in this template repository.

- "git commit -m \"chore: initial commit\""
- command: gh repo create {{ github_username }}/{{ project_github_name }} --source=. --push --private
when: "{{ push_to_github }}"
- command: "gh api --method PUT -H \"Accept: application/vnd.github+json\" repos/{{ github_username }}/{{ project_github_name }}/branches/main/protection --input branch_protection_rules.json"
when: "{{ push_to_github }}"
- rm branch_protection_rules.json

# Questions

Expand All @@ -29,7 +36,7 @@ author_email:
github_username:
type: str
help: GitHub username or organization
default: "{{ author_name | lower | replace(' ', '') }}"
default: "XomniaAi"

project_name:
type: str
Expand All @@ -53,6 +60,11 @@ project_slug:
and underscores only, and it may not start with a digit.
{% endif %}

project_github_name:
type: str
default: "{{ project_slug | lower | replace('_', '-') }}"
when: false

project_short_description:
type: str
help: A short description of the project
Expand Down Expand Up @@ -81,3 +93,10 @@ include_hexagonal:
adapters layers with an example slice, plus import-linter contracts that
enforce the layer boundaries.
default: true

push_to_github:
type: bool
help: >-
Push the repository to GitHub. Auto-applies standard branch protection rules
standard for trunk-based development. (e.g. one main branch)
default: true
4 changes: 2 additions & 2 deletions template/README.md.jinja
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# {{ project_name }}

[![Tests](https://github.com/{{ github_username }}/{{ project_slug }}/actions/workflows/ci.yaml/badge.svg)](https://github.com/{{ github_username }}/{{ project_slug }}/actions/workflows/ci.yaml)
[![Tests](https://github.com/{{ github_username }}/{{ project_github_name }}/actions/workflows/ci.yaml/badge.svg)](https://github.com/{{ github_username }}/{{ project_github_name }}/actions/workflows/ci.yaml)
[![PyPI version](https://badge.fury.io/py/{{ project_slug | replace('_', '-') }}.svg)](https://pypi.org/project/{{ project_slug | replace('_', '-') }}/)


{{ project_short_description }}

Original repository: [https://github.com/{{ github_username }}/{{ project_slug }}](https://github.com/{{ github_username }}/{{ project_slug }})
Original repository: [https://github.com/{{ github_username }}/{{ project_github_name }}](https://github.com/{{ github_username }}/{{ project_github_name }})

{% if include_hexagonal -%}

Expand Down
19 changes: 19 additions & 0 deletions template/branch_protection_rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"allow_deletions": false,
"allow_force_pushes": false,
"enforce_admins": true,
"required_linear_history": false,
"required_pull_request_reviews": {
"dismiss_stale_reviews": true,
"require_code_owner_reviews": false,
"require_last_push_approval": true,
"required_approving_review_count": 1
},
"required_status_checks": {
"contexts": [
"ci-gate"
],
"strict": true
},
"restrictions": null
}
4 changes: 2 additions & 2 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ dependencies = [
]

[project.urls]
Homepage = "https://github.com/{{ github_username }}/{{ project_slug }}"
Repository = "https://github.com/{{ github_username }}/{{ project_slug }}"
Homepage = "https://github.com/{{ github_username }}/{{ project_github_name }}"
Repository = "https://github.com/{{ github_username }}/{{ project_github_name }}"

[tool.hatch.build.targets.wheel]
packages = ["src/{{ project_slug }}"]
Expand Down
3 changes: 2 additions & 1 deletion tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def _triggers(workflow: dict) -> dict:
"project_short_description": "A test project.",
"version": "0.1.0",
"license": "MIT",
"push_to_github": False
}


Expand Down Expand Up @@ -327,7 +328,7 @@ def test_default_slug_is_valid_package_name(tmp_path):
copier.run_copy(
src_path=str(TEMPLATE_ROOT),
dst_path=str(dst),
data={"author_name": "Joe Doe", "author_email": "joe@example.com"},
data={"author_name": "Joe Doe", "author_email": "joe@example.com", "push_to_github": False},
defaults=True,
unsafe=True,
vcs_ref="HEAD",
Expand Down