Skip to content

Commit f2170db

Browse files
authored
docs: Update contributing guidelines and development workflow (#24)
* chore: add GitHub issue templates and config * docs: update contributing guidelines, move tests guidance to a new doc, linked Move Code Style, Testing, and Documentation sections up. Add links to ensure new contributors can understand code documentation styles Explain Taskfile and reference commands in Taskfile when possible * test: bump up coverage threshold to 80, to match original Testing target "Maintain test coverage above 80%"
1 parent 765cc83 commit f2170db

File tree

7 files changed

+207
-43
lines changed

7 files changed

+207
-43
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: "F41B Bug Report"
3+
about: "Create a report to help us improve"
4+
title: "[Bug] "
5+
labels: bug
6+
assignees: ""
7+
---
8+
9+
### Describe the bug
10+
11+
A clear and concise description of what the bug is.
12+
13+
### Reproduction steps
14+
15+
1. Go to '...'
16+
2. Run '...'
17+
3. Observe '...'
18+
19+
### Expected behavior
20+
21+
What you expected to happen.
22+
23+
### Screenshots / Logs
24+
25+
If applicable, add screenshots or paste the relevant console/terminal output.
26+
27+
### Environment
28+
29+
- OS (e.g. Ubuntu 22.04):
30+
- Python/Terraform/`<other>` versions:
31+
- Commit SHA:
32+
33+
### Additional context
34+
35+
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Report a security vulnerability
4+
url: https://github.com/rafaelherik/tfsumpy/security/advisories/new
5+
about: Report a security vulnerability in tfsumpy.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: "F31F Feature Request"
3+
about: "Suggest an idea or enhancement"
4+
title: "[Feature]"
5+
labels: enhancement
6+
assignees: ""
7+
---
8+
9+
### Problem to solve
10+
11+
What limitation or pain point are you facing?
12+
13+
### Proposal
14+
15+
Describe the feature or behaviour you'd like to see.
16+
17+
### Alternatives considered
18+
19+
Have you considered any alternative solutions? If so, list them here.
20+
21+
### Additional context
22+
23+
Add any other context or references (links, diagrams, etc.) about the feature request here.

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ jobs:
3636
- name: Run tests with coverage
3737
run: |
3838
poetry run pytest --cov=tfsumpy --cov-report=term
39-
poetry run coverage report --fail-under=75
39+
poetry run coverage report --fail-under=80
4040
4141
- name: Coverage reminder
4242
if: success()
43-
run: echo "::notice ::Current threshold is 75%. PRs that raise coverage are welcome!"
43+
run: echo "::notice ::Current threshold is 80%. PRs that raise coverage are welcome!"
4444

4545
- name: Build package
4646
run: poetry build

Taskfile.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ tasks:
1515
- .venv
1616

1717
test:
18-
desc: Run all tests with pytest
18+
desc: Run tests with coverage
1919
cmds:
20-
- . .venv/bin/activate && poetry run pytest --cov=tfsumpy --cov-report=term && poetry run coverage report --fail-under=75
20+
- . .venv/bin/activate && poetry run pytest --cov=tfsumpy --cov-report=term && poetry run coverage report --fail-under=80
2121
deps: [install]
2222

2323
lint:
@@ -37,4 +37,4 @@ tasks:
3737
desc: Run all checks (install, lint, test)
3838
cmds:
3939
- poetry run ruff check .
40-
deps: [install]
40+
deps: [install]

docs/contributing.md

Lines changed: 79 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,49 @@
1-
# Contributing to tfsumpy
1+
# Contributing Guidelines
2+
3+
## Code Style
4+
5+
- Follow [PEP 8 guidelines](https://peps.python.org/pep-0008/)
6+
- Use [type hints](https://docs.python.org/3/library/typing.html) for better code clarity and IDE support
7+
- Write docstrings for all public methods following [PEP 257](https://peps.python.org/pep-0257/) conventions
8+
- Keep functions focused and small
9+
10+
## Documentation
11+
12+
- Update documentation for new features
13+
- Include [docstrings](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) in code (Google style preferred)
14+
- Update example usage in README.md
15+
- Add type hints to function signatures
16+
17+
## Making Changes
18+
19+
1. Review [open issues](https://github.com/rafaelherik/tfsumpy/issues) and [pull requests](https://github.com/rafaelherik/tfsumpy/pulls) to see if there is any related work that's already in progress
20+
2. Get or update your own copy of the project to work with
21+
3. Write new and/or update existing tests for your changes
22+
4. Develop and implement your changes
23+
5. Commit your changes in small, useful chunks
24+
6. Ensure all tests pass
25+
7. Update documentation as needed
26+
8. Push your changes to your fork
27+
9. Create a Pull Request
228

329
## Getting Started
430

531
1. Fork the repository
632
2. Clone your fork:
7-
```bash
8-
git clone https://github.com/your-username/tfsumpy.git
9-
```
33+
34+
```bash
35+
git clone https://github.com/your-username/tfsumpy.git
36+
```
1037

1138
3. Set up development environment:
12-
```bash
13-
cd tfsumpy
14-
pip install -e ".[dev]"
15-
```
39+
40+
This project uses [Task](https://taskfile.dev/) to run set up, and run linting, and testing tasks consistently with how they are run in CI. Start by making sure you have [Task](https://taskfile.dev/) installed.
41+
42+
Running the `task install` command will create a local virtual environment, install dev requirements and then execute the individual tools. Running these commands in the [Taskfile](Taskfile.yml) guarantees that everyone, including CI workflows, uses the same versions and settings.
43+
44+
```bash
45+
task install
46+
```
1647

1748
## Development Process
1849

@@ -22,25 +53,55 @@ pip install -e ".[dev]"
2253
git checkout -b feature/your-feature-name
2354
```
2455

25-
### Running Tests
56+
### Testing
57+
58+
- **Unit Tests**: Required for all new features and bug fixes
59+
- Follow our [Testing Guide](tests.md) for best practices
60+
- Use [pytest](https://docs.pytest.org/)-style tests with `assert` statements
61+
- Maintain test coverage above 80%
62+
- Run tests with `task test` (executes `pytest` with coverage)
63+
64+
- **Test-Driven Development (TDD)**:
65+
- Write tests first, then implementation
66+
- Follow the [TDD workflow](https://realpython.com/test-driven-development-python/)
67+
- Keep tests focused and fast
68+
69+
- **Test Types**:
70+
- Unit tests for individual functions/classes
71+
- Integration tests for component interactions
72+
- See [Testing Guide](tests.md) for detailed patterns
73+
74+
### Linting
75+
76+
Linting and static analysis are automated in GitHub Actions. To help you get an approval for your pull request, you'll need to have all Actions workflow checks pass. To run the same tools locally you can use the [Taskfile](Taskfile.yml) to achieve the same results. First make sure you have the [Task](https://taskfile.dev/) runner [installed](https://taskfile.dev/#/installation).
2677
2778
```bash
28-
pytest
79+
cd tfsumpy
80+
# Run ruff, mypy and bandit (fails on any issues)
81+
task lint
82+
83+
# Optionally, auto-fix style issues detected by ruff
84+
task lint-fix
2985
```
3086
31-
### Running Linting
87+
The Taskfile will create a local virtual environment if needed, install all dev requirements and then execute the individual tools. Running the tasks guarantees that everyone uses the same versions and settings.
88+
89+
### Running Tests
90+
91+
Automated tests run in GitHub Actions. To help you get an approval for your pull request, you'll need to have all Actions workflow checks pass. To run the same tests locally you can use the [Taskfile](Taskfile.yml) to achieve the same results. First make sure you have the [Task](https://taskfile.dev/) runner [installed](https://taskfile.dev/#/installation).
3292

3393
```bash
34-
pylint tfsumpy
35-
mypy tfsumpy
94+
# Run pytest with coverage threshold enforcement (mirrors CI)
95+
task test
3696
```
3797

38-
### Making Changes
98+
This task sets up the virtual-env if necessary, installs all dev dependencies, then executes
3999

40-
1. Write tests for your changes
41-
2. Implement your changes
42-
3. Ensure all tests pass
43-
4. Update documentation if needed
100+
```bash
101+
pytest --cov=tfsumpy --cov-report=term && coverage report --fail-under=80
102+
```
103+
104+
so you get quick feedback on both test failures and coverage.
44105

45106
### Committing Changes
46107

@@ -56,23 +117,3 @@ git push origin feature/your-feature-name
56117
2. Update the documentation if needed
57118
3. Ensure all tests pass
58119
4. Create a Pull Request with a clear description of changes
59-
60-
## Code Style
61-
62-
- Follow PEP 8 guidelines
63-
- Use type hints
64-
- Write docstrings for all public methods
65-
- Keep functions focused and small
66-
67-
## Testing
68-
69-
- Write unit tests for new functionality
70-
- Maintain test coverage above 80%
71-
- Include integration tests where appropriate
72-
73-
## Documentation
74-
75-
- Update documentation for new features
76-
- Include docstrings in code
77-
- Update example usage in README.md
78-
- Add type hints to function signatures

docs/tests.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Adding and Updating Tests
2+
3+
New to pytest? Start here:
4+
5+
- [Official Quick Start (5-min read)](https://docs.pytest.org/en/stable/getting-started.html) – concise intro, test discovery rules, and basic assertions
6+
- [Real Python “Getting Started With pytest”](https://realpython.com/pytest-python-testing/) – longer, example-driven walkthrough
7+
8+
## Project guidelines
9+
10+
1. Location & naming
11+
12+
- Put tests in the tests/ directory, mirroring the package layout.
13+
- Filenames should start with test*, and test functions/classes with test*…, so pytest will auto-discover them.
14+
15+
2. Keep them simple
16+
17+
- Prefer plain assert statements—pytest rewrites them to show expressive failure messages.
18+
- One logical assertion per test is ideal; use multiple tests rather than many asserts in one function.
19+
20+
3. Re-use set-up code with fixtures
21+
22+
- Place shared fixtures in conftest.py at the project root or the relevant sub-directory.
23+
- Example:
24+
25+
```python
26+
import pytest
27+
from tfsumpy import SomeClass
28+
29+
@pytest.fixture
30+
def sample_instance():
31+
return SomeClass(param="value")
32+
```
33+
34+
4. Parametrize when inputs vary
35+
36+
```python
37+
@pytest.mark.parametrize("raw,expected", [(1, "1"), (None, "")])
38+
def test_coerce_to_str(raw, expected):
39+
assert utils.coerce_to_str(raw) == expected
40+
```
41+
42+
5. Measure coverage locally
43+
44+
`task test` runs `pytest --cov=tfsumpy …`. Aim to increase the coverage number or at least keep it above 80 %.
45+
46+
6. Writing new tests
47+
48+
- Start by reproducing the current behaviour (red).
49+
- Implement or fix code (green).
50+
- Refactor while tests stay green (TDD cycle).
51+
52+
7. Run only what you need while developing:
53+
54+
```bash
55+
# Single test file
56+
pytest tests/test_utils.py
57+
58+
# Filter by keyword
59+
pytest -k "coerce and str"
60+
```

0 commit comments

Comments
 (0)