Skip to content

Commit 99106e3

Browse files
authored
Merge pull request #2 from XomniaAI/feat/put-on-github
2 parents a8633e3 + 09dc767 commit 99106e3

6 files changed

Lines changed: 49 additions & 6 deletions

File tree

‎.github/workflows/ci.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
2525
- name: Install dependencies
2626
run: uv sync
27+
- name: Set git identity
28+
run: |
29+
git config --global user.email "ci-example-user@xomnia.com"
30+
git config --global user.name "CI Example User"
2731
- name: Run pytest
2832
run: uv run pytest
2933
# Single aggregate check to require in the branch ruleset. It depends on

‎copier.yml‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ _tasks:
1313
- "git checkout -b main"
1414
- "uv sync"
1515
- "uv run pre-commit install"
16+
- "git add --all -- :!branch_protection_rules.json"
17+
- "git commit -m \"chore: initial commit\""
18+
- command: gh repo create {{ github_username }}/{{ project_github_name }} --source=. --push --private
19+
when: "{{ push_to_github }}"
20+
- 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"
21+
when: "{{ push_to_github }}"
22+
- rm branch_protection_rules.json
1623

1724
# Questions
1825

@@ -29,7 +36,7 @@ author_email:
2936
github_username:
3037
type: str
3138
help: GitHub username or organization
32-
default: "{{ author_name | lower | replace(' ', '') }}"
39+
default: "XomniaAi"
3340

3441
project_name:
3542
type: str
@@ -53,6 +60,11 @@ project_slug:
5360
and underscores only, and it may not start with a digit.
5461
{% endif %}
5562
63+
project_github_name:
64+
type: str
65+
default: "{{ project_slug | lower | replace('_', '-') }}"
66+
when: false
67+
5668
project_short_description:
5769
type: str
5870
help: A short description of the project
@@ -81,3 +93,10 @@ include_hexagonal:
8193
adapters layers with an example slice, plus import-linter contracts that
8294
enforce the layer boundaries.
8395
default: true
96+
97+
push_to_github:
98+
type: bool
99+
help: >-
100+
Push the repository to GitHub. Auto-applies standard branch protection rules
101+
standard for trunk-based development. (e.g. one main branch)
102+
default: true

‎template/README.md.jinja‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# {{ project_name }}
22

3-
[![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)
3+
[![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)
44
[![PyPI version](https://badge.fury.io/py/{{ project_slug | replace('_', '-') }}.svg)](https://pypi.org/project/{{ project_slug | replace('_', '-') }}/)
55

66

77
{{ project_short_description }}
88

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

1111
{% if include_hexagonal -%}
1212

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"allow_deletions": false,
3+
"allow_force_pushes": false,
4+
"enforce_admins": true,
5+
"required_linear_history": false,
6+
"required_pull_request_reviews": {
7+
"dismiss_stale_reviews": true,
8+
"require_code_owner_reviews": false,
9+
"require_last_push_approval": true,
10+
"required_approving_review_count": 1
11+
},
12+
"required_status_checks": {
13+
"contexts": [
14+
"ci-gate"
15+
],
16+
"strict": true
17+
},
18+
"restrictions": null
19+
}

‎template/pyproject.toml.jinja‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ dependencies = [
2525
]
2626

2727
[project.urls]
28-
Homepage = "https://github.com/{{ github_username }}/{{ project_slug }}"
29-
Repository = "https://github.com/{{ github_username }}/{{ project_slug }}"
28+
Homepage = "https://github.com/{{ github_username }}/{{ project_github_name }}"
29+
Repository = "https://github.com/{{ github_username }}/{{ project_github_name }}"
3030

3131
[tool.hatch.build.targets.wheel]
3232
packages = ["src/{{ project_slug }}"]

‎tests/test_template.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def _triggers(workflow: dict) -> dict:
4747
"project_short_description": "A test project.",
4848
"version": "0.1.0",
4949
"license": "MIT",
50+
"push_to_github": False
5051
}
5152

5253

@@ -327,7 +328,7 @@ def test_default_slug_is_valid_package_name(tmp_path):
327328
copier.run_copy(
328329
src_path=str(TEMPLATE_ROOT),
329330
dst_path=str(dst),
330-
data={"author_name": "Joe Doe", "author_email": "joe@example.com"},
331+
data={"author_name": "Joe Doe", "author_email": "joe@example.com", "push_to_github": False},
331332
defaults=True,
332333
unsafe=True,
333334
vcs_ref="HEAD",

0 commit comments

Comments
 (0)