Skip to content

Commit 59d4b04

Browse files
authored
Merge pull request #18
Test Improvements and Refactoring
2 parents 1954742 + e728720 commit 59d4b04

File tree

8 files changed

+217
-52
lines changed

8 files changed

+217
-52
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ repos:
1111
rev: v2.6.0
1212
hooks:
1313
- id: prettier
14+
- repo: https://github.com/python-jsonschema/check-jsonschema
15+
rev: 0.33.1
16+
hooks:
17+
- id: check-github-workflows
18+
args: [ "--verbose" ]

tests/conftest.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def robust_file__path__relative(request: FixtureRequest) -> str:
5151

5252
@pytest.fixture(scope="session")
5353
def robust_demo(
54-
request: FixtureRequest,
5554
demos_folder: Path,
5655
robust_demo__path: Path,
5756
robust_demo__extra_context: dict[str, Any],
@@ -67,29 +66,29 @@ def robust_demo(
6766
if robust_demo__is_setup:
6867
subprocess.run(["nox", "-s", "setup-git"], cwd=robust_demo__path, capture_output=True)
6968
subprocess.run(["nox", "-s", "setup-venv"], cwd=robust_demo__path, capture_output=True)
70-
return getattr(request, "param", robust_demo__path)
69+
return robust_demo__path
7170

7271

7372
@pytest.fixture(scope="session")
74-
def robust_demo__path(request: FixtureRequest, demos_folder: Path, robust_demo__name: str) -> Path:
75-
return getattr(request, "param", demos_folder / robust_demo__name)
73+
def robust_demo__path(demos_folder: Path, robust_demo__name: str) -> Path:
74+
return demos_folder / robust_demo__name
7675

7776

7877
@pytest.fixture(scope="session")
79-
def robust_demo__name(request: FixtureRequest) -> str:
80-
return getattr(request, "param", "robust-python-demo-with-setup")
78+
def robust_demo__name(robust_demo__add_rust_extension: str, robust_demo__is_setup: bool) -> str:
79+
build: str = "maturin" if robust_demo__add_rust_extension else "python"
80+
name_parts: list[str] = ["robust", "python", "demo", build]
81+
if robust_demo__is_setup:
82+
name_parts.append("setup")
83+
return "-".join(name_parts)
8184

8285

8386
@pytest.fixture(scope="session")
84-
def robust_demo__extra_context(
85-
request: FixtureRequest,
86-
robust_demo__name: str,
87-
robust_demo__add_rust_extension: bool
88-
) -> dict[str, Any]:
89-
return getattr(request, "param", {
87+
def robust_demo__extra_context(robust_demo__name: str, robust_demo__add_rust_extension: bool) -> dict[str, Any]:
88+
return {
9089
"project_name": robust_demo__name,
9190
"add_rust_extension": robust_demo__add_rust_extension
92-
})
91+
}
9392

9493

9594
@pytest.fixture(scope="session")

tests/integration_tests/test_robust_python_demo.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
from pathlib import Path
55

66
import pytest
7+
from pbr.options import TRUE_VALUES
78

89
from tests.constants import GLOBAL_NOX_SESSIONS
910

1011

11-
def test_demo_project_generation(robust_python_demo_with_setup: Path) -> None:
12-
assert robust_python_demo_with_setup.exists()
13-
14-
1512
@pytest.mark.parametrize("session", GLOBAL_NOX_SESSIONS)
1613
def test_demo_project_nox_session(robust_demo: Path, session: str) -> None:
1714
command: list[str] = ["nox", "-s", session]
@@ -44,6 +41,8 @@ def test_demo_project_nox_pre_commit(robust_demo: Path) -> None:
4441
assert result.returncode == 0
4542

4643

44+
@pytest.mark.parametrize(argnames="robust_demo__add_rust_extension", argvalues=[True, False], indirect=True)
45+
@pytest.mark.parametrize(argnames="robust_demo__is_setup", argvalues=[False], indirect=True)
4746
def test_demo_project_nox_pre_commit_with_install(robust_demo: Path) -> None:
4847
command: list[str] = ["nox", "-s", "pre-commit", "--", "install"]
4948
pre_commit_hook_path: Path = robust_demo / ".git" / "hooks" / "pre-commit"

{{cookiecutter.project_name}}/.github/workflows/release-python.yml

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,18 @@ name: Release Python Package
66
on:
77
push:
88
tags:
9-
# Trigger on SemVer tags. Commitizen configured in pyproject.toml (Area 12)
10-
# uses PEP 440 which is SemVer compatible.
119
- "v[0-9]+.[0-9]+.[0-9]+"
1210
- "v[0-9]+.[0-9]+.[0-9]+-*" # Include pre-release tags
1311

14-
# Allow workflow to be run manually from the Actions tab for a specific tag
1512
workflow_dispatch:
1613
inputs:
1714
tag:
1815
description: 'Git tag to build and release (e.g., v1.2.3). Must already exist.'
19-
required: true # User must provide a tag when manually dispatching
16+
required: true
2017

2118
jobs:
22-
# Job 1: Build the package and publish to TestPyPI
2319
build_and_testpypi:
2420
name: Build & Publish to TestPyPI
25-
# Run on a consistent, standard build environment
2621
runs-on: ubuntu-latest
2722

2823
steps:
@@ -40,42 +35,31 @@ jobs:
4035
python-version-file: .python-version
4136

4237
- name: Upload built package artifacts
43-
# Upload packages so the publish job can access them.
4438
uses: actions/upload-artifact@v4
4539
with:
46-
name: distribution-packages # Name the artifact
47-
path: dist/ # Path to the built sdist/wheel files
48-
retention-days: 7 # Keep built artifacts for 7 days
40+
name: distribution-packages
41+
path: dist/
42+
retention-days: 7
4943

5044
- name: Download built package artifacts
5145
uses: actions/download-artifact@v4
5246
with:
53-
name: distribution-packages-{{"{{ github.event.inputs.tag }}"}}
47+
name: distribution-packages-{{"${{ github.event.inputs.tag }}"}}
5448
path: dist/
5549

56-
# --- Publish to TestPyPI Step ---
57-
# This step runs within the same job after build.
5850
- name: Publish to TestPyPI
59-
# Execute the Task Automation publish session for TestPyPI.
60-
# This calls uv publish dist/* with TestPyPI credentials/config (Topic 10).
6151
env:
62-
# TestPyPI credentials stored as secrets in GitHub Settings -> Secrets
63-
TWINE_USERNAME: __token__ # Standard username when using API tokens
64-
TWINE_PASSWORD: {{"${{ secrets.TESTPYPI_API_TOKEN }}"}} # Use GitHub Encrypted Secret
65-
# Optional: If uv publish requires different config for repository URL, pass TWINE_REPOSITORY or similar
66-
run: uvx nox -s publish-package -- --repository testpypi # Call the publish-package session, passing repository arg
67-
68-
# --- Get Changelog Content for Release Notes ---
69-
# Use a standard action to extract changelog content.
70-
# This action requires a standard CHANGELOG.md format.
52+
TWINE_USERNAME: __token__
53+
TWINE_PASSWORD: {{"${{ secrets.TESTPYPI_API_TOKEN }}"}}
54+
run: uvx nox -s publish-package -- --repository testpypi
55+
7156
- name: Get Release Notes from Changelog
7257
id: changelog
73-
uses: simple-changelog/action@v3 # Action to parse CHANGELOG.md
58+
uses: simple-changelog/action@v3
7459
with:
75-
path: CHANGELOG.md # Path to your CHANGELOG.md
76-
tag: {{"${{ github.event_name == 'push' && github.ref_name || github.event.inputs.tag }}"}} # Pass the tag name
60+
path: CHANGELOG.md
61+
tag: {{"${{ github.event_name == 'push' && github.ref_name || github.event.inputs.tag }}"}}
7762

78-
# Define outputs from this job that other jobs (like create_github_release) can use.
7963
outputs:
8064
changelog_body:
8165
description: "Release notes body extracted from CHANGELOG.md"

{{cookiecutter.project_name}}/.github/workflows/security-python.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ on:
1818
- main
1919
- master
2020
paths:
21-
- 'src/**/*.py'
22-
- 'tests/**/*.py'
23-
- 'noxfile.py'
24-
- 'pyproject.toml'
25-
- '.bandit'
26-
- '.ruff.toml'
27-
- '.github/workflows/security-python.yml'
21+
- "src/**/*.py"
22+
- "tests/**/*.py"
23+
- "noxfile.py"
24+
- "pyproject.toml"
25+
- ".bandit"
26+
- ".ruff.toml"
27+
- ".github/workflows/security-python.yml"
2828

2929
workflow_dispatch:
3030

{{cookiecutter.project_name}}/.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ repos:
6060
- id: prettier
6161
name: Prettier
6262

63+
- repo: https://github.com/python-jsonschema/check-jsonschema
64+
rev: 0.33.1
65+
hooks:
66+
- id: check-github-workflows
67+
args: [ "--verbose" ]
68+
6369
- repo: https://github.com/commitizen-tools/commitizen
6470
rev: v4.8.2
6571
hooks:
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, caste, color, religion, or sexual
10+
identity and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
- Demonstrating empathy and kindness toward other people
21+
- Being respectful of differing opinions, viewpoints, and experiences
22+
- Giving and gracefully accepting constructive feedback
23+
- Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
- Focusing on what is best not just for us as individuals, but for the overall
26+
community
27+
28+
Examples of unacceptable behavior include:
29+
30+
- The use of sexualized language or imagery, and sexual attention or advances of
31+
any kind
32+
- Trolling, insulting or derogatory comments, and personal or political attacks
33+
- Public or private harassment
34+
- Publishing others' private information, such as a physical or email address,
35+
without their explicit permission
36+
- Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
[56kyleoliver@gmail.com](mailto:56kyleoliver@gmail.com).
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series of
86+
actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or permanent
93+
ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within the
113+
community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.1, available at
119+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120+
121+
Community Impact Guidelines were inspired by
122+
[Mozilla's code of conduct enforcement ladder][mozilla coc].
123+
124+
For answers to common questions about this code of conduct, see the FAQ at
125+
[https://www.contributor-covenant.org/faq][faq]. Translations are available at
126+
[https://www.contributor-covenant.org/translations][translations].
127+
128+
[homepage]: https://www.contributor-covenant.org
129+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130+
[mozilla coc]: https://github.com/mozilla/diversity
131+
[faq]: https://www.contributor-covenant.org/faq
132+
[translations]: https://www.contributor-covenant.org/translations
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Contributing to cookiecutter-robust-python
2+
3+
Thank you for considering contributing to the `cookiecutter-robust-python` template! We welcome contributions that help improve the template, keep its tooling current, and enhance its documentation.
4+
5+
By participating in this project, you are expected to uphold our [Code of Conduct](CODE_OF_CONDUCT.md).
6+
7+
## How to Contribute
8+
9+
There are several ways to contribute:
10+
11+
1. **Reporting Bugs:** If you find an issue with the template itself (e.g., it doesn't generate correctly, the generated project's workflow doesn't work on a specific OS, a tool is misconfigured), please open an issue on the [issue tracker](https://github.com/56kyle/cookiecutter-robust-python/issues). Provide clear steps to reproduce the bug.
12+
2. **Suggesting Enhancements:** Have an idea for a new feature, a different tool choice you think is better, or an improvement to the template structure or documentation? Open an issue on the [issue tracker](https://github.com/56kyle/cookiecutter-robust-python/issues) to discuss your suggestion. Clearly articulate the proposed change and the rationale behind it, ideally referencing the template's philosophy and criteria ([Template Philosophy](https://56kyle.github.io/cookiecutter-robust-python/philosophy.html), [Criteria for Tool Selection](https://56kyle.github.io/cookiecutter-robust-python/criteria.html)).
13+
3. **Submitting Code Contributions:** Ready to contribute code (e.g., fix a bug, implement a suggested enhancement, update a tool version)? Please fork the repository and submit a Pull Request.
14+
15+
## Setting Up Your Development Environment
16+
17+
Refer to the **[Getting Started: Contributing to the Template](https://56kyle.github.io/cookiecutter-robust-python/getting-started-template-contributing.html)** section in the template documentation for instructions on cloning the repository, installing template development dependencies (using uv), setting up the template's pre-commit hooks, and running template checks/tests.
18+
19+
## Contribution Workflow
20+
21+
1. **Fork** the repository and **clone** your fork.
22+
2. Create a **new branch** for your contribution based on the main branch. Use a descriptive name (e.g., `fix/ci-workflow-on-windows`, `feat/update-uv-version`).
23+
3. Set up your development environment following the [Getting Started](https://56kyle.github.io/cookiecutter-robust-python/getting-started-template-contributing.html) guide (clone, `uv sync`, `uvx nox -s pre-commit -- install`).
24+
4. Make your **code or documentation changes**.
25+
5. Ensure your changes adhere to the template's **code quality standards** (configured in the template's `.pre-commit-config.yaml`, `.ruff.toml`, etc.). The pre-commit hooks will help with this. Run `uvx nox -s lint`, `uvx nox -s check` in the template repository for more comprehensive checks.
26+
6. Ensure your changes **do not break existing functionality**. Run the template's test suite: `uvx nox -s test`. Ideally, add tests for new functionality or bug fixes.
27+
7. Ensure the **template documentation builds correctly** with your changes: `uvx nox -s docs`.
28+
8. Write clear, concise **commit messages** following the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification where possible, especially for significant changes (fixes, features, chore updates, etc.).
29+
9. **Push** your branch to your fork.
30+
10. **Open a Pull Request** from your branch to the main branch of the main template repository. Provide a clear description of your changes. Link to any relevant issues.
31+
32+
## Updating Tool Evaluations
33+
34+
If your contribution involves updating a major tool version or suggesting a different tool entirely, you **must** update the relevant sections in the template's documentation (`docs/topics/` files) to reflect the changes in configuration, behavior, or re-justify the choice based on the current state of the tools and criteria. This is crucial for keeping the documentation accurate and useful over time.
35+
36+
## Communication
37+
38+
For questions or discussion about contributions, open an issue or a discussion on the [GitHub repository](https://github.com/56kyle/cookiecutter-robust-python).
39+
40+
---

0 commit comments

Comments
 (0)