Skip to content

Commit 1fc18ce

Browse files
committed
chore: standardize contributing guide across org
1 parent 715c8bf commit 1fc18ce

1 file changed

Lines changed: 85 additions & 89 deletions

File tree

CONTRIBUTING.md

Lines changed: 85 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,118 @@
1-
# Contributing to `each`
1+
# Contributing
22

3-
Thanks for your interest in contributing. This guide covers the operational process. For the **why** — the design principles every contribution is tested against — see **[bold-minds/oss/PRINCIPLES.md](https://github.com/bold-minds/oss/blob/main/PRINCIPLES.md)**.
3+
Thank you for your interest in contributing! We welcome contributions that improve the library while maintaining its focus on simplicity, performance, and Go idioms.
44

5-
## 🎯 Before You Start
5+
## Getting Started
66

7-
Every contribution is measured against the four Bold Minds principles: **outcome naming**, **one way to do each thing**, **get out of the way**, and **non-goals explicit**. If your proposed change doesn't honor these, it will not be merged.
7+
### Prerequisites
88

9-
**Read [PRINCIPLES.md](https://github.com/bold-minds/oss/blob/main/PRINCIPLES.md) first.**
9+
- **Go 1.22+**
10+
- **Git**
11+
- **golangci-lint** (optional, for comprehensive linting)
1012

11-
## 🔧 Development Setup
13+
### Development Setup
1214

13-
**Requirements:** Go 1.21 or later, Git, Bash.
15+
1. **Fork and clone the repository**:
16+
```bash
17+
git clone https://github.com/YOUR_USERNAME/each.git
18+
cd each
19+
```
1420

15-
```bash
16-
git clone https://github.com/bold-minds/each.git
17-
cd each
18-
go test ./... # unit tests
19-
go test -race ./... # race detection
20-
go test -bench=. ./... # benchmarks
21-
./scripts/validate.sh # full validation pipeline
22-
./scripts/validate.sh ci # strict CI mode
23-
```
21+
2. **Run tests**:
22+
```bash
23+
go test -race ./...
24+
```
2425

25-
Your contribution must pass `./scripts/validate.sh ci` before submitting.
26+
## What We're Looking For
2627

27-
## 📁 Project Structure
28+
### Encouraged
2829

29-
```
30-
each/
31-
├── each.go # Implementation (single file)
32-
├── each_test.go # Unit tests with adversarial coverage
33-
├── bench_test.go # Benchmarks
34-
├── examples/ # Runnable examples
35-
├── scripts/
36-
│ └── validate.sh # Validation pipeline
37-
├── README.md
38-
├── CONTRIBUTING.md # This file
39-
├── CHANGELOG.md
40-
├── CODE_OF_CONDUCT.md
41-
├── SECURITY.md
42-
├── LICENSE
43-
└── go.mod
44-
```
30+
- **Bug fixes** — fix issues or edge cases
31+
- **Performance improvements** — optimize without breaking compatibility
32+
- **Test enhancements** — add test cases, improve coverage
33+
- **Documentation improvements** — clarify usage, add examples
4534

46-
Flat layout. No `internal/` directory.
35+
### Requires Discussion First
4736

48-
## 🎨 Code Style
37+
- **API changes** — modifications to public interfaces
38+
- **New dependencies** — adding external packages
39+
- **Breaking changes** — changes that affect backward compatibility
4940

50-
### Naming
51-
- Outcome naming per PRINCIPLES.md. Function names describe the predicate-based operation performed.
41+
### Not Accepted
5242

53-
### Error Handling
54-
- Functions **must not panic** on valid input.
55-
- No error returns — operations either succeed or return sensible defaults (zero values, non-nil empty slices/maps).
56-
- Every function is nil-safe.
43+
- **Feature creep** — complex features that don't align with Go idioms
44+
- **Non-idiomatic Go** — code that doesn't follow Go conventions
45+
- **Performance regressions** — changes that significantly slow down the library
5746

58-
### Documentation
59-
- Every exported function has a doc comment describing behavior, edge cases (nil/empty input), and ordering guarantees.
60-
- Panic risks from caller-side misuse (non-comparable key types from `GroupBy`/`KeyBy`) are documented in the package doc.
47+
## Contribution Process
6148

62-
### Dependencies
63-
- **Zero external dependencies.** `each` is pure stdlib.
49+
### 1. Create an Issue First
6450

65-
## 🧪 Testing
51+
For significant changes, please create an issue to discuss:
52+
- What problem you're solving
53+
- Your proposed approach
54+
- Any potential breaking changes
6655

67-
**Coverage target: 100% of exported functions.**
56+
### 2. Development Workflow
6857

69-
**Every PR must include adversarial tests.** The lesson from the wider Bold Minds library family: passing validation is necessary but insufficient. Tests must explicitly verify:
58+
1. **Create a feature branch**:
59+
```bash
60+
git checkout -b feature/your-feature-name
61+
```
7062

71-
1. **Non-nil return guarantees** — no function returns `nil` for empty results when the docs promise "non-nil empty"
72-
2. **Immutability** — input slices are byte-identical before and after the call
73-
3. **Result non-aliasing** — mutating the returned slice does not affect the input
74-
4. **Custom comparable key types**`GroupBy`/`KeyBy` must work with named types, structs, and any other comparable Go type
75-
5. **Short-circuit evaluation**`Every` must stop on the first false; write a counter-based test that would catch a regression
76-
6. **Stateful predicates** — closures with captured state must work (common real-world pattern)
63+
2. **Make your changes** — follow the code style guidelines below, add tests, update documentation as needed.
7764

78-
```bash
79-
go test -v ./...
80-
go test -race ./...
81-
go test -cover ./...
82-
go test -bench=. -benchmem ./...
83-
```
65+
3. **Validate your changes**:
66+
```bash
67+
go fmt ./...
68+
go vet ./...
69+
go test -race ./...
70+
```
8471

85-
## 📝 Pull Request Process
72+
4. **Commit your changes**:
73+
```bash
74+
git commit -m "feat: add your feature description"
75+
```
8676

87-
### PR Checklist
77+
5. **Push and create a pull request**:
78+
```bash
79+
git push origin feature/your-feature-name
80+
```
8881

89-
- [ ] **Outcome naming** — does the function name describe what the caller gets?
90-
- [ ] **One way** — does any existing function (this library or stdlib) already do this?
91-
- [ ] **Get out of the way** — can a Go dev use this from the signature alone?
92-
- [ ] **Non-goals** — does this violate any of the library's stated non-goals?
93-
- [ ] Tests cover 100% of new code
94-
- [ ] Adversarial tests included (nil returns, immutability, aliasing)
95-
- [ ] Benchmarks added for new exported functions
96-
- [ ] README updated (if adding or changing exported functions)
97-
- [ ] CHANGELOG.md updated
98-
- [ ] `./scripts/validate.sh ci` passes locally
82+
### 3. Pull Request Guidelines
9983

100-
## 🆕 Adding a New Function
84+
Your PR should:
85+
- Have a clear title describing the change
86+
- Reference any related issues using `Fixes #123` or `Closes #123`
87+
- Include tests for new functionality
88+
- Pass all CI checks
89+
- Maintain backward compatibility unless discussed otherwise
10190

102-
`each` is deliberately scoped to seven functions. New additions must clear a high bar:
91+
## Code Style
10392

104-
1. Read the library's non-goals in [README.md](README.md#-whats-deliberately-not-here) and [PRINCIPLES.md](https://github.com/bold-minds/oss/blob/main/PRINCIPLES.md)
105-
2. Prove the stdlib gap. Current Go's `slices` package is more capable than many realize.
106-
3. Confirm the function operates on a single slice with a predicate or key function (operations on multiple slices belong in [`bold-minds/list`](https://github.com/bold-minds/list)).
107-
4. Show real-world evidence of the pain.
108-
5. Reject anything that is a thin wrapper around `slices.IndexFunc`, `slices.ContainsFunc`, or other stdlib helpers.
93+
- Follow standard Go formatting (`go fmt`)
94+
- Use meaningful variable and function names
95+
- Write clear, concise comments for public APIs
96+
- Follow Go's error handling patterns
97+
- Write table-driven tests where appropriate
98+
- Test both success and error cases
99+
- Include edge cases (nil values, empty strings, etc.)
100+
- Run tests with `-race` to ensure thread safety
109101

110-
## 🏷️ Versioning and Releases
102+
## Commit Messages
103+
104+
We follow conventional commits:
105+
106+
```
107+
type(scope): description
108+
```
111109

112-
- Semantic versioning
113-
- v0.x: API may change between minor versions
114-
- v1.0+: breaking changes require major version bump
110+
Types: `feat`, `fix`, `docs`, `test`, `refactor`, `perf`, `chore`
115111

116-
## 🙏 Code of Conduct
112+
## Code Review
117113

118-
See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
114+
We look for: correctness, performance, style, tests, documentation, and backward compatibility. Initial review within 2-3 business days.
119115

120-
## 📄 License
116+
## License
121117

122-
By contributing, you agree your contributions are licensed under the MIT License.
118+
By contributing, you agree that your contributions will be licensed under the same license that covers the project.

0 commit comments

Comments
 (0)