Skip to content

Commit 0fecf02

Browse files
committed
Add template testing prompt
1 parent 54c920a commit 0fecf02

File tree

2 files changed

+213
-6
lines changed

2 files changed

+213
-6
lines changed
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
---
2+
description: "Comprehensive testing of the cookiecutter template across all configurations."
3+
---
4+
5+
# Template Testing Prompt
6+
7+
Please perform comprehensive testing of the cookiecutter template to ensure all configurations generate working projects with passing tests, type checking, and linting.
8+
9+
## Task Requirements:
10+
11+
### 1. Standard Test Configurations
12+
13+
Test ALL three standard configurations located in the `tests/` directory:
14+
15+
- **Full configuration** (`tests/full.yaml`): All features enabled (FastAPI, Celery, QuasiQueue, Database, Caching, Docker)
16+
- **Library configuration** (`tests/library.yaml`): Minimal setup for Python library development
17+
- **Bare configuration** (`tests/bare.yaml`): Basic project with no optional features
18+
19+
### 2. Testing Workflow
20+
21+
For EACH configuration, perform these steps:
22+
23+
#### Step 1: Generate Project
24+
25+
```bash
26+
cd /Users/tedivm/Repositories/tedivm/robs_awesome_python_template
27+
rm -rf workspaces/<config_name>
28+
cookiecutter --config-file tests/<config_name>.yaml --no-input --output-dir workspaces .
29+
cd workspaces/<config_name>
30+
```
31+
32+
#### Step 2: Run Test Suite
33+
34+
Run the key validation checks:
35+
36+
```bash
37+
make pytest # Run all tests with coverage
38+
make mypy_check # Type checking
39+
make ruff_check # Linting
40+
```
41+
42+
Note: Formatting issues (dapperdata, tomlsort, paracelsus) can be auto-fixed with `make chores` and are not critical for validation.
43+
44+
#### Step 3: Verify Results
45+
46+
Check that:
47+
48+
- ✅ All tests pass (exit code 0)
49+
- ✅ Test coverage meets expectations (typically 90%+ for full/library, 100% for bare)
50+
- ✅ No mypy type errors
51+
- ✅ No ruff linting errors
52+
- ✅ Code formatting is correct
53+
54+
### 3. Context-Specific Testing
55+
56+
**IMPORTANT:** In addition to the three standard configurations, create and test additional custom configurations relevant to your current work session.
57+
58+
For example:
59+
60+
- If you modified caching functionality, test a config with caching enabled and one with it disabled
61+
- If you updated Docker configurations, test with and without Docker components
62+
- If you modified CLI functionality, test with and without optional CLI features
63+
- If you modify a component with hooks into a lot of other systems, create multiple configurations to validate those changes
64+
65+
#### Creating Custom Test Configurations
66+
67+
Create temporary YAML config files in the `workspaces/` directory (these won't be committed):
68+
69+
```yaml
70+
# Example: workspaces/custom_test.yaml
71+
default_context:
72+
project_name: "Custom Test"
73+
project_slug: "custom_test"
74+
package_name: "custom_test"
75+
include_fastapi: "y"
76+
include_celery: "n"
77+
include_database: "y"
78+
include_caching: "y"
79+
# ... other settings as needed
80+
```
81+
82+
Then test with:
83+
84+
```bash
85+
cookiecutter --config-file workspaces/custom_test.yaml --no-input --output-dir workspaces .
86+
```
87+
88+
### 4. Expected Test Results
89+
90+
Standard configurations should produce these results:
91+
92+
#### Bare Configuration
93+
94+
- **Tests**: ~11 tests
95+
- **Coverage**: 100%
96+
- **Files tested**: Core settings and configuration
97+
98+
#### Library Configuration
99+
100+
- **Tests**: ~26 tests
101+
- **Coverage**: ~93%
102+
- **Files tested**: CLI, settings, basic project structure
103+
- **Note**: CLI should have version and hello commands
104+
105+
#### Full Configuration
106+
107+
- **Tests**: ~147 tests
108+
- **Coverage**: ~94%
109+
- **Files tested**: All services (cache, db, jinja), celery, CLI, QuasiQueue, FastAPI, settings
110+
- **Note**: Most comprehensive test suite with all features
111+
112+
### 5. Common Issues and Troubleshooting
113+
114+
#### Issue: Jinja2 Template Errors
115+
116+
- **Cause**: Raw Jinja2 code in documentation or examples
117+
- **Solution**: Ensure all Jinja2 examples in markdown files are wrapped in `{% raw %}...{% endraw %}`
118+
119+
#### Issue: Mypy Type Errors
120+
121+
- **Cause**: Missing type annotations or untyped library imports
122+
- **Solution**: Check pyproject.toml has strict mypy settings enabled; use `# type: ignore` for untyped third-party libraries as a last resort only
123+
124+
#### Issue: CLI Tests Failing
125+
126+
- **Cause**: Typer single-command behavior or missing commands
127+
- **Solution**: Ensure CLI always has at least 2 commands (version + hello minimum)
128+
129+
#### Issue: Import Errors
130+
131+
- **Cause**: Optional dependencies not properly handled
132+
- **Solution**: Check that conditional imports use try/except blocks or are properly guarded
133+
134+
### 6. Reporting Results
135+
136+
After testing, provide a summary that includes:
137+
138+
1. **Configuration Results**: For each tested configuration
139+
140+
- Configuration name
141+
- Number of tests run
142+
- Number of tests passed/failed
143+
- Code coverage percentage
144+
- Any errors or warnings
145+
146+
2. **Test Output Analysis**: Key findings from test execution
147+
148+
- Any deprecation warnings
149+
- Performance issues
150+
- Coverage gaps in important modules
151+
152+
3. **Validation Status**: Overall health check
153+
- ✅ All standard configurations passing
154+
- ✅ Context-specific configurations passing
155+
- ✅ Type checking clean (mypy)
156+
- ✅ Linting clean (ruff)
157+
- ✅ Formatting correct (black)
158+
159+
### 7. Performance Considerations
160+
161+
- Run tests in sequence, not parallel (to avoid resource conflicts)
162+
- Clean up workspace directories between runs to ensure fresh state
163+
- Virtual environments can be reused within a configuration but should be recreated between different configurations
164+
165+
### 8. Template Context Awareness
166+
167+
Remember that this is a **cookiecutter template project**, which means:
168+
169+
- The actual template files are in `{{cookiecutter.__package_slug}}/`
170+
- Test configurations are in `tests/*.yaml`
171+
- Generated projects appear in `workspaces/`
172+
- Many files contain Jinja2 templating syntax that looks like broken Python/YAML
173+
- The `hooks/post_gen_project.py` script removes unnecessary files based on configuration
174+
175+
### 9. Success Criteria
176+
177+
Testing is considered successful when:
178+
179+
- ✅ All three standard configurations generate working projects
180+
- ✅ All test suites pass with high coverage (90%+)
181+
- ✅ No type checking errors (mypy clean)
182+
- ✅ No linting errors (ruff clean)
183+
- ✅ All formatting is correct (black clean)
184+
- ✅ Any context-specific configurations relevant to recent changes also pass
185+
- ✅ Exit codes are 0 for all test runs
186+
- ✅ No warnings or errors in test output
187+
188+
## Implementation Approach:
189+
190+
1. **Prepare**: Understand what changes were made in the current session
191+
2. **Plan**: Identify which configurations are most relevant to test
192+
3. **Execute**: Run standard configurations (bare, library, full) sequentially
193+
4. **Validate**: Create and test custom configurations for specific scenarios
194+
5. **Report**: Provide clear summary of all test results
195+
6. **Iterate**: If any tests fail, investigate and fix before proceeding
196+
197+
Remember: Testing is not just about running commands—it's about validating that the template produces high-quality, production-ready Python projects across all supported configurations.

.github/prompts/upgrade-actions.prompt.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
mode: 'agent'
3-
description: 'Upgrade action versions in workflows of the template.'
2+
description: "Upgrade action versions in workflows of the template."
43
---
54

65
# GitHub Actions Version Upgrade Prompt
@@ -10,33 +9,39 @@ Please update all GitHub workflow files in the template directory (`{{cookiecutt
109
## Task Requirements:
1110

1211
### 1. File Location
12+
1313
- Target directory: `{{cookiecutter.__package_slug}}/.github/workflows/`
1414
- Update ALL `.yaml` workflow files in this directory
1515
- These are Jinja template files, so YAML formatting may appear broken due to template syntax - this is expected and should be preserved
1616

1717
### 2. Actions to Update
18+
1819
- **First, discover all GitHub Actions used** by reading through all workflow files in the target directory
1920
- **Research each action's latest version** by checking their respective GitHub releases pages
2021
- **Categorize actions appropriately**:
21-
- Core GitHub actions (actions/*)
22-
- Docker actions (docker/*)
23-
- PyPI/Python actions (pypa/*)
22+
- Core GitHub actions (actions/\*)
23+
- Docker actions (docker/\*)
24+
- PyPI/Python actions (pypa/\*)
2425
- Third-party actions (other organizations)
2526
- **Apply appropriate update strategies** based on action type and current version patterns
2627

2728
### 3. Version Format Rules
29+
2830
- **Use MAJOR versions only** (e.g., `v5`, `v6`, not `v5.2.1` or `v6.18.0`)
2931
- Major version tags automatically receive compatible updates
3032
- Exception: `pypa/gh-action-pypi-publish@release/v1` should stay as-is
3133

3234
### 4. Research Method
35+
3336
- Look up latest versions by fetching GitHub releases pages
3437
- Infer GitHub URLs from action names (e.g., `actions/checkout``https://github.com/actions/checkout/releases`)
3538
- Use the web to find the most recent stable major version
3639
- Don't update to pre-release or beta versions
3740

3841
### 5. Template Preservation
42+
3943
**CRITICAL:** Preserve ALL existing Jinja template syntax:
44+
4045
- `{% raw %}${{ github.actor }}{% endraw %}`
4146
- `{% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}`
4247
- `{% raw %}${{ matrix.version }}{% endraw %}`
@@ -45,20 +50,24 @@ Please update all GitHub workflow files in the template directory (`{{cookiecutt
4550
- Template comments and whitespace
4651

4752
### 6. File Discovery
53+
4854
- **Discover all workflow files** by listing all `.yaml` files in the target directory
4955
- **Don't assume file names** - read the directory contents to find all workflow files that need updating
5056

5157
### 7. Verification Steps
58+
5259
After updating:
60+
5361
1. Confirm all action versions are updated to latest major versions
5462
2. Verify Jinja templating is intact
5563
3. Check that YAML structure is preserved (even if it looks broken due to templates)
5664

5765
### 8. Example Updates
66+
5867
```yaml
5968
# Before:
6069
- uses: actions/checkout@v4
61-
- uses: actions/setup-python@v5
70+
- uses: actions/setup-python@v5
6271
- uses: docker/[email protected]
6372

6473
# After:
@@ -68,6 +77,7 @@ After updating:
6877
```
6978
7079
## Implementation Approach:
80+
7181
1. **Discover**: List all workflow files and identify all GitHub Actions used
7282
2. **Research**: Look up current latest versions for each discovered action
7383
3. **Plan**: Create a mapping of old version → new version

0 commit comments

Comments
 (0)