Skip to content

Commit fe289b0

Browse files
committed
✨ cookiecutter testing
1 parent 8b9bf3f commit fe289b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+14198
-170
lines changed

.github/workflows/release.yaml

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
name: Release
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
push:
5+
branches:
6+
- main
77

88
jobs:
9-
10-
release:
11-
name: github-release
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Check out the repository
15-
uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 2
18-
ref: main
19-
- name: Setup Node.js
20-
uses: actions/setup-node@v3
21-
- name: Release
22-
run: |
23-
npm install --prefix .github/semantic_release/
24-
npx --prefix .github/semantic_release/ semantic-release
25-
env:
26-
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
27-
GIT_AUTHOR_NAME: github-actions[bot]
28-
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
29-
GIT_COMMITTER_NAME: github-actions[bot]
30-
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
9+
release:
10+
name: github-release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out the repository
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 2
17+
ref: main
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v3
20+
- name: Release
21+
run: |
22+
npm install --prefix .github/semantic_release/
23+
npx --prefix .github/semantic_release/ semantic-release
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
26+
GIT_AUTHOR_NAME: github-actions[bot]
27+
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
28+
GIT_COMMITTER_NAME: github-actions[bot]
29+
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com

.github/workflows/tests.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches: ["**"]
9+
jobs:
10+
test-suite:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
include:
16+
- { name: Python 3.12, python: "3.12" }
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ matrix.python }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
steps:
21+
- name: Set up Github Workspace
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
- name: Set up Python Environment ${{ matrix.python }}
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: ${{ matrix.python }}
29+
- name: Install Hatch
30+
run: |
31+
python -m pip install --upgrade pip
32+
python -m pip install -q hatch pre-commit
33+
hatch env create
34+
hatch --version
35+
- name: Test Suite
36+
run: |
37+
hatch run test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,4 @@ dmypy.json
140140

141141
# Cookiecutter Examples
142142
example-project/
143+
!tests/example-project/

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
default_stages: [commit]
2+
fail_fast: false
3+
exclude: "{{cookiecutter.repo_name}}"
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.4.0
7+
hooks:
8+
- id: trailing-whitespace
9+
- id: end-of-file-fixer
10+
- id: check-yaml
11+
exclude: mkdocs.yaml
12+
- id: check-ast
13+
- id: check-docstring-first
14+
- id: check-merge-conflict
15+
- id: mixed-line-ending
16+
17+
- repo: https://github.com/pre-commit/mirrors-prettier
18+
rev: v3.0.0
19+
hooks:
20+
- id: prettier
21+
args: [--print-width=88, --tab-width=4]
22+
exclude: |
23+
(?x)(
24+
.github/semantic_release/release_notes.hbs
25+
)

.releaserc.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ module.exports = {
3030
},
3131
},
3232
],
33-
[
34-
"@semantic-release/github",
35-
{},
36-
],
33+
["@semantic-release/github", {}],
3734
],
3835
};

README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@
99

1010
[juftin]'s personal [cookiecutter] template for Python projects.
1111

12+
```shell
13+
cookiecutter gh:juftin/cookiecutter-python
14+
```
15+
1216
## Features
1317

14-
- [hatch] for managing the project's virtual environment and development tools
15-
- [black] for code formatting
16-
- [ruff] for code linting
17-
- [mypy] for type checking
18-
- [pip-tools] for dependency management + lockfile
19-
- [pre-commit] for managing git hooks
20-
- [GitHub Actions] for CI/CD
21-
- [MkDocs] and [mkdocs-material] for documentation
22-
- [GitHub Pages] for hosting documentation
23-
- [semantic-release] and [gitmoji] for automated releases
24-
- Publishes to [PyPI] and [Docker Hub]
18+
- [hatch] for managing the project's virtual environment and development tools
19+
- [ruff] for code formatting and linting
20+
- [mypy] for type checking
21+
- [pip-tools] for dependency management + lockfile
22+
- [pre-commit] for managing git hooks
23+
- [GitHub Actions] for CI/CD
24+
- [MkDocs] and [mkdocs-material] for documentation
25+
- [GitHub Pages] for hosting documentation
26+
- [semantic-release] and [gitmoji] for automated releases
27+
- Publishes to [PyPI] and [Docker Hub]
2528

2629
## Quickstart Guide
2730

@@ -65,13 +68,10 @@ This project uses GitHub Actions to deploy releases, documentation, and
6568
to publish artifacts to PyPI / Docker Hub. You will need to create
6669
secrets in your GitHub repository to enable these features.
6770

68-
These secrets can be found in the `.env` file at the root of the project.
69-
Once you have created the secrets on the `.env` file, you can run the
70-
[GitHub CLI] to create the secrets in your repository:
71-
72-
```shell
73-
gh secret set --env-file .env
74-
```
71+
- `PERSONAL_ACCESS_TOKEN`: A GitHub Personal Access Token with `repo` permissions
72+
- `PYPI_TOKEN`: Your PyPI token (optional)
73+
- `DOCKER_USERNAME`: Your Docker Hub username (optional)
74+
- `DOCKER_TOKEN`: Your Docker Hub token (optional)
7575

7676
#### Developing
7777

@@ -103,4 +103,3 @@ Once the server is running, you can view the documentation at
103103
[localhost:8080/contributing]: http://localhost:8080/contributing
104104
[ruff]: httpe://ruff.io/
105105
[mypy]: https://mypy.readthedocs.io/
106-
[black]: https://black.readthedocs.io/en/stable/

cookiecutter.json

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,29 @@
11
{
2-
"project_name": "example-project",
3-
"friendly_name": "{{ cookiecutter.project_name.lower().replace(' ', '-').replace('-', '-') }}",
4-
"repo_name": "{{ cookiecutter.friendly_name.lower().replace(' ', '-').replace('-', '-') }}",
5-
"project_slug": "{{ cookiecutter.friendly_name.lower().replace(' ', '_').replace('-', '_') }}",
6-
"project_short_description": "Brief description of the project",
7-
"version": "0.0.0",
8-
"full_name": "Justin Flannery",
9-
"email": "[email protected]",
10-
"github_username": "juftin",
11-
"default_python_version": [
12-
"3.12",
13-
"3.11",
14-
"3.10",
15-
"3.9",
16-
"3.8"
17-
],
18-
"default_branch": ["main", "master"],
19-
"license": ["MIT", "Apache-2.0", "GPL-3.0", "UNLICENSED"],
20-
"development_status": [
21-
"Development Status :: 1 - Planning",
22-
"Development Status :: 2 - Pre-Alpha",
23-
"Development Status :: 3 - Alpha",
24-
"Development Status :: 4 - Beta",
25-
"Development Status :: 5 - Production/Stable",
26-
"Development Status :: 6 - Mature",
27-
"Development Status :: 7 - Inactive"
28-
],
29-
"build_docker_image": [false, true],
30-
"publish_to_pypi": [false, true],
31-
"publish_to_docker_hub": [false, true],
32-
"logo_url": "https://raw.githubusercontent.com/juftin/juftin/main/static/juftin.png",
33-
"favicon": "https://juftin.com/favicon.ico",
34-
"_copy_without_render": [
35-
"*.hbs"
36-
]
2+
"project_name": "example-project",
3+
"friendly_name": "{{ cookiecutter.project_name.lower().replace(' ', '-').replace('-', '-') }}",
4+
"repo_name": "{{ cookiecutter.friendly_name.lower().replace(' ', '-').replace('-', '-') }}",
5+
"project_slug": "{{ cookiecutter.friendly_name.lower().replace(' ', '_').replace('-', '_') }}",
6+
"project_short_description": "Brief description of the project",
7+
"version": "0.0.0",
8+
"full_name": "Justin Flannery",
9+
"email": "[email protected]",
10+
"github_username": "juftin",
11+
"default_python_version": ["3.12", "3.11", "3.10", "3.9", "3.8"],
12+
"default_branch": ["main", "master"],
13+
"license": ["MIT", "Apache-2.0", "GPL-3.0", "UNLICENSED"],
14+
"development_status": [
15+
"Development Status :: 1 - Planning",
16+
"Development Status :: 2 - Pre-Alpha",
17+
"Development Status :: 3 - Alpha",
18+
"Development Status :: 4 - Beta",
19+
"Development Status :: 5 - Production/Stable",
20+
"Development Status :: 6 - Mature",
21+
"Development Status :: 7 - Inactive"
22+
],
23+
"build_docker_image": [false, true],
24+
"publish_to_pypi": [false, true],
25+
"publish_to_docker_hub": [false, true],
26+
"logo_url": "https://raw.githubusercontent.com/juftin/juftin/main/static/juftin.png",
27+
"favicon": "https://juftin.com/favicon.ico",
28+
"_copy_without_render": ["*.hbs"]
3729
}

pyproject.toml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
[build-system]
2+
build-backend = "hatchling.build"
3+
requires = ["hatchling"]
4+
5+
[project]
6+
authors = [
7+
{name = "Justin Flannery", email = "[email protected]"}
8+
]
9+
description = "Brief description of the project"
10+
license = "MIT"
11+
name = "example-project"
12+
readme = "README.md"
13+
requires-python = ">=3.8"
14+
version = "0.0.0"
15+
dependencies = [
16+
"cookiecutter~=2.4.0",
17+
]
18+
19+
[tool.hatch.envs.default]
20+
dependencies = [
21+
"coverage[toml]>=6.5",
22+
"pytest"
23+
]
24+
path = ".venv"
25+
post-install-commands = [
26+
"pre-commit install"
27+
]
28+
python = "3.11"
29+
type = "virtual"
30+
31+
[tool.hatch.envs.default.scripts]
32+
test = "pytest {args:tests}"
33+
34+
[tool.hatch.envs.docs]
35+
dependencies = [
36+
"mkdocs~=1.5.2",
37+
"mkdocs-material~=9.2.3",
38+
"mkdocstrings~=0.22.0",
39+
"markdown-exec[ansi]~=1.6.0"
40+
]
41+
detached = true
42+
43+
[tool.hatch.envs.docs.scripts]
44+
build = ["mkdocs build --clean --strict"]
45+
deploy = ["mkdocs gh-deploy {args:}"]
46+
serve = ["mkdocs serve --dev-addr localhost:8080 --livereload"]
47+
48+
[tool.ruff]
49+
ignore = [
50+
# Allow non-abstract empty methods in abstract base classes
51+
"B027",
52+
# Allow boolean positional values in function calls, like `dict.get(... True)`
53+
"FBT003",
54+
# Ignore checks for possible passwords
55+
"S105",
56+
"S106",
57+
"S107",
58+
# Ignore complexity
59+
"C901",
60+
"PLR0911",
61+
"PLR0912",
62+
"PLR0913",
63+
"PLR0915"
64+
]
65+
line-length = 100
66+
select = [
67+
"A",
68+
"ARG",
69+
"B",
70+
"C",
71+
"DTZ",
72+
"E",
73+
"EM",
74+
"F",
75+
"FBT",
76+
"I",
77+
"ICN",
78+
"ISC",
79+
"N",
80+
"PLC",
81+
"PLE",
82+
"PLR",
83+
"PLW",
84+
"Q",
85+
"RUF",
86+
"S",
87+
"T",
88+
"TID",
89+
"UP",
90+
"W",
91+
"YTT"
92+
]
93+
target-version = "py38"
94+
unfixable = [
95+
# Don't touch unused imports
96+
"F401"
97+
]
98+
99+
[tool.ruff.flake8-tidy-imports]
100+
ban-relative-imports = "all"
101+
102+
[tool.ruff.isort]
103+
known-first-party = ["example_project"]
104+
105+
[tool.ruff.pydocstyle]
106+
convention = "numpy"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: monthly
7+
- package-ecosystem: pip
8+
directory: /.github/workflows
9+
schedule:
10+
interval: monthly
11+
- package-ecosystem: pip
12+
directory: /docs
13+
schedule:
14+
interval: monthly
15+
- package-ecosystem: pip
16+
directory: /
17+
schedule:
18+
interval: monthly
19+
versioning-strategy: lockfile-only
20+
allow:
21+
- dependency-type: all

0 commit comments

Comments
 (0)