Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit c13aaea

Browse files
authored
Merge pull request #6 from ilbumi/dev
Release 0.1.0
2 parents 2d0d6e6 + 3616cb3 commit c13aaea

8 files changed

Lines changed: 176 additions & 8 deletions

File tree

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,29 @@ The template is heavily inspired by [Pawamoy's Copier PDM](https://github.com/pa
1212
### Existing features
1313

1414
- Python 3.9 or above
15+
- [PDM](https://github.com/pdm-project/pdm) setup, with pre-defined `pyproject.toml`
1516
- Pre-configured tools for code formatting, quality analysis and testing:
1617
- [black](https://github.com/psf/black),
1718
- [ruff](https://github.com/charliermarsh/ruff),
1819
- [mypy](https://github.com/python/mypy),
20+
- [safety](https://github.com/pyupio/safety)
21+
- [ssort](https://github.com/bwhmather/ssort),
22+
- [coverage](https://github.com/nedbat/coveragepy)
1923
- Tests run with [pytest](https://github.com/pytest-dev/pytest) and plugins
2024
- [Nox](https://github.com/wntrblm/nox) as task runner
2125
- All licenses from [choosealicense.com](https://choosealicense.com/appendix/)
26+
- Support for GitHub workflows
2227

2328
### Planned Features
2429

2530
- VSCode Dev Containers as development environments
26-
- [PDM](https://github.com/pdm-project/pdm) setup, with pre-defined `pyproject.toml`
2731
- Documentation built with [MkDocs](https://github.com/mkdocs/mkdocs)
2832
([Material theme](https://github.com/squidfunk/mkdocs-material)
2933
and "autodoc" [mkdocstrings plugin](https://github.com/mkdocstrings/mkdocstrings))
3034
- Pre-configured tools for code formatting, quality analysis and testing:
31-
- [blacken-docs](https://github.com/adamchainz/blacken-docs),
32-
- [ssort](https://github.com/bwhmather/ssort),
33-
- [safety](https://github.com/pyupio/safety)
34-
- [coverage](https://github.com/nedbat/coveragepy) support for tests
35+
- [blacken-docs](https://github.com/adamchainz/blacken-docs), support for tests
3536
- Auto-generated `CHANGELOG.md` from git commits
36-
- Support for GitHub workflows and GitLab CI/CD
37+
- Support for GitLab CI/CD
3738

3839
## Quick setup and usage
3940

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches:
7+
- main
8+
- dev
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
env:
15+
LANG: en_US.utf-8
16+
LC_ALL: en_US.utf-8
17+
PYTHONIOENCODING: UTF-8
18+
19+
jobs:
20+
quality:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
27+
- name: Fetch all tags
28+
run: git fetch --depth=1 --tags
29+
30+
- name: Set up PDM
31+
uses: pdm-project/setup-pdm@v3
32+
with:
33+
python-version: "3.9"
34+
35+
- name: Resolve dependencies
36+
run: pdm lock -v --no-cross-platform -G ci-quality
37+
38+
- name: Install dependencies
39+
run: pdm install -G ci-quality
40+
41+
- name: Check the code safety
42+
run: pdm run nox check_safety
43+
44+
- name: Check if the code is correctly typed
45+
run: pdm run nox check_types
46+
47+
- name: Check the code quality
48+
run: pdm run nox lint
49+
50+
tests:
51+
strategy:
52+
max-parallel: 4
53+
matrix:
54+
os:
55+
- ubuntu-latest
56+
- macos-latest
57+
python-version:
58+
- "3.9"
59+
- "3.10"
60+
- "3.11"
61+
- "3.12"
62+
runs-on: {% raw %}${{ matrix.os }}{% endraw %}
63+
continue-on-error: {% raw %}${{ matrix.python-version == '3.12' }}{% endraw %}
64+
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v3
68+
69+
- name: Set up PDM
70+
uses: pdm-project/setup-pdm@v3
71+
with:
72+
python-version: {% raw %}${{ matrix.python-version }}{% endraw %}
73+
allow-python-prereleases: true
74+
75+
- name: Resolve dependencies
76+
run: pdm lock -v --no-cross-platform -G ci-tests
77+
78+
- name: Install dependencies
79+
run: pdm install --no-editable -G ci-tests
80+
81+
- name: Run the test suite
82+
run: pdm run nox test
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: release
2+
3+
on: push
4+
permissions:
5+
contents: write
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
if: startsWith(github.ref, 'refs/tags/')
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
- name: Fetch all tags
15+
run: git fetch --depth=1 --tags
16+
- name: Setup Python
17+
uses: actions/setup-python@v4
18+
- name: Install git-changelog
19+
run: pip install git-changelog
20+
- name: Prepare release notes
21+
run: git-changelog --release-notes > release-notes.md
22+
- name: Create release
23+
uses: softprops/action-gh-release@v1
24+
with:
25+
body_path: release-notes.md

project/.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.3.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: local
9+
hooks:
10+
- id: format
11+
name: format
12+
entry: pdm run nox -e format
13+
language: system
14+
types: [python]
15+
- repo: local
16+
hooks:
17+
- id: lint
18+
name: lint
19+
entry: pdm run nox -e lint
20+
language: system
21+
types: [python]
22+
- repo: local
23+
hooks:
24+
- id: safety
25+
name: safety
26+
entry: pdm run nox -e check_safety
27+
language: system
28+
types: [python]
29+
- repo: local
30+
hooks:
31+
- id: check_types
32+
name: check_types
33+
entry: pdm run nox -e check_types
34+
language: system
35+
types: [python]

project/noxfile.py.jinja

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def format(session: Session) -> None:
2929
session (Session): nox session object
3030
"""
3131
session.run_always("pdm", "install", "-G", "ci-quality", external=True)
32+
session.run("ssort", *PYSRC)
33+
session.run("isort", *PYSRC)
3234
session.run("ruff", "check", "--config", "config/ruff.toml", "--fix", *PYSRC)
3335
session.run("black", "--config", "config/black.toml", *PYSRC)
3436

@@ -63,7 +65,7 @@ def check_safety(session: Session) -> None:
6365
session (Session): nox session object
6466
"""
6567
session.run_always("pdm", "install", "-G", "ci-quality", external=True)
66-
session.run("bandit", "--configfile", "config/bandit.toml", *PYSRC)
68+
session.run("bandit", "-r", "--configfile", "config/bandit.toml", *PYSRC)
6769
with tempfile.NamedTemporaryFile() as requirements:
6870
session.run(
6971
"pdm", "export", "-f", "requirements", "-o", requirements.name, "--without-hashes", external=True

project/pyproject.toml.jinja

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ editable-backend = "editables"
122122

123123
[tool.pdm.dev-dependencies]
124124
nox = ["nox"]
125+
full-dev = ["{{ python_package_distribution_name }}[nox,docs,quality,typing,security,tests,precommit]"]
125126
ci-quality = ["{{ python_package_distribution_name }}[nox,docs,quality,typing,security]"]
126127
ci-tests = ["{{ python_package_distribution_name }}[nox,tests]"]
127128
docs = [
@@ -146,6 +147,8 @@ maintain = [
146147
]
147148
quality = [
148149
"ruff>=0.0.246",
150+
"ssort",
151+
"isort",
149152
]
150153
tests = [
151154
"pytest>=6.2",
@@ -159,6 +162,9 @@ typing = [
159162
"types-pyyaml>=6.0",
160163
"types-toml>=0.10",
161164
]
165+
precommit = [
166+
"pre-commit"
167+
]
162168
security = [
163169
"safety>=2",
164170
"bandit"

tests/setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ copier copy --trust --defaults -r HEAD "${template}" "${DEST}" \
3636
pushd $DEST
3737
git init .
3838
git add -A .
39-
git commit -m "test"
39+
git commit -m "feat: init a repo"

tests/test_generate.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,22 @@ pdm run nox -e check_types
2323
pdm run nox -e lint
2424
pdm run nox -e check_safety
2525

26+
echo
27+
echo "///////////////////////////////////////////"
28+
echo " COMMIT CHECKS"
29+
echo "///////////////////////////////////////////"
30+
echo
31+
32+
echo '"""Module that contains the command line application."""' > some_code.py
33+
echo 'print("Fine")' >> some_code.py
34+
35+
git add -A .
36+
git commit -m "fix: fix a bug"
37+
38+
pdm run nox -e format
39+
pdm run nox -e check_types
40+
pdm run nox -e lint
41+
pdm run nox -e check_safety
42+
2643
popd
2744
rm -rf $DEST

0 commit comments

Comments
 (0)