260 lines
8.1 KiB
Markdown
260 lines
8.1 KiB
Markdown
# Contributing to newzy
|
|
|
|
First off, thank you for considering contributing to **newzy**! It's people like you that make this project great.
|
|
|
|
## Table of Contents
|
|
|
|
- [Code of Conduct](#code-of-conduct)
|
|
- [Getting Started](#getting-started)
|
|
- [How to Contribute](#how-to-contribute)
|
|
- [Branch Strategy](#branch-strategy)
|
|
- [Git Workflow](#git-workflow)
|
|
- [Commit Message Guidelines](#commit-message-guidelines)
|
|
- [Pull Request Process](#pull-request-process)
|
|
- [Reporting Bugs](#reporting-bugs)
|
|
- [Adding Features](#adding-features)
|
|
|
|
## Code of Conduct
|
|
|
|
Please be respectful and constructive. We aim to maintain a welcoming environment for all contributors.
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
Before contributing, ensure you have:
|
|
- Node.js v18+ installed
|
|
- npm or yarn installed
|
|
- Git configured with your email and name:
|
|
```bash
|
|
git config --global user.email "you@example.com"
|
|
git config --global user.name "Your Name"
|
|
```
|
|
|
|
### Setup Development Environment
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd newzy
|
|
npm install
|
|
cp .env.example .env
|
|
# Update .env with your configuration
|
|
npm run dev
|
|
```
|
|
|
|
## How to Contribute
|
|
|
|
### 1. Find or Create an Issue
|
|
|
|
- Check existing issues for similar problems/features
|
|
- If no issue exists, create one describing the problem/feature clearly
|
|
- Reference relevant documentation or examples if applicable
|
|
|
|
### 2. Fork and Clone the Repository
|
|
|
|
```bash
|
|
git clone https://github.com/<your-username>/newzy.git
|
|
cd newzy
|
|
git remote add upstream https://github.com/<owner>/newzy.git
|
|
```
|
|
|
|
### 3. Create a Branch
|
|
|
|
Follow our [branch strategy](#branch-strategy) below.
|
|
|
|
### 4. Make Your Changes
|
|
|
|
- Follow the existing code style
|
|
- Write tests for new features/bug fixes
|
|
- Update documentation as needed
|
|
|
|
### 5. Test Locally
|
|
|
|
Ensure your changes work correctly before submitting.
|
|
|
|
### 6. Commit Your Changes
|
|
|
|
Use [commit message guidelines](#commit-message-guidelines) below.
|
|
|
|
### 7. Create a Pull Request
|
|
|
|
Fill out the PR template, reference issues, and ensure all CI checks pass.
|
|
|
|
## Branch Strategy
|
|
|
|
Our repository uses a standard Git flow with the following branches:
|
|
|
|
### `main` (Production)
|
|
- **Purpose**: Production-ready, stable releases only
|
|
- **Branch protection**: Enabled
|
|
- **Access**: Requires approval for merges
|
|
- **Content**: Merged, tested, and approved code
|
|
|
|
### `develop` (Integration)
|
|
- **Purpose**: Integration branch for feature development
|
|
- **Branch protection**: Enabled with checks required
|
|
- **Access**: Open for contributors
|
|
- **Content**: Completed features ready for next release
|
|
|
|
### Feature Branches (`feature/*`)
|
|
- **Pattern**: `feature/<feature-name>` or `feature/issue-number/<short-description>`
|
|
- **Example**: `feature/42/article-search` or `feature/article-search`
|
|
- **Usage**: Create from `develop`, merge back to `develop` when complete
|
|
|
|
### Bugfix Branches (`bugfix/*`)
|
|
- **Pattern**: `bugfix/<bug-name>` or `bugfix/issue-number/<short-description>`
|
|
- **Example**: `bugfix/43/image-upload-crash`
|
|
- **Usage**: Create from `develop`, merge back to both `develop` and `main` if critical
|
|
|
|
### Hotfix Branches (`hotfix/*`)
|
|
- **Pattern**: `hotfix/<issue-number>-<description>`
|
|
- **Example**: `hotfix/50-critical-login-fix`
|
|
- **Usage**: Create from `main`, merge back to both `main` and `develop`
|
|
|
|
## Git Workflow
|
|
|
|
### Pre-push Hooks
|
|
|
|
We use pre-push hooks to enforce code quality. These automatically:
|
|
- Run linting checks
|
|
- Build the project (if applicable)
|
|
- Ensure no sensitive files are committed
|
|
|
|
To see hook output, run with verbose flags or check the `.github/hooks/pre-push.sh` script.
|
|
|
|
### Merge Conflict Resolution Strategy
|
|
|
|
1. **First responder owns**: The person who first modifies conflicting code takes responsibility
|
|
2. **Communicate early**: Notify team members immediately of conflicts
|
|
3. **Use git merge tools**: Visual diff tools help resolve conflicts cleanly
|
|
4. **Test thoroughly**: All merged code must pass tests
|
|
5. **Update documentation**: Document any workflow changes
|
|
|
|
Recommended merge tool: [VSCode Merge Conflict Resolution](https://marketplace.visualstudio.com/items?itemName=rogalmi.bash-merge-tool) or [KDiff3](https://kdiff3.org/)
|
|
|
|
## Commit Message Guidelines
|
|
|
|
We follow the [Conventional Commits](https://www.conventionalcommits.org/) format:
|
|
|
|
```
|
|
<type>(<scope>): <subject>
|
|
|
|
<body>
|
|
|
|
<footer>
|
|
```
|
|
|
|
### Types
|
|
|
|
| Type | Description | Example |
|
|
|-----------|------------------------------------------------------|----------------------------------|
|
|
| `feat` | New feature that changes functionality | `feat: add user login system` |
|
|
| `fix` | Bug fix | `fix: resolve login redirect bug` |
|
|
| `docs` | Documentation changes | `docs: update API docs` |
|
|
| `style` | Code style changes (formatting, etc.) | `style: format JavaScript files` |
|
|
| `refactor`| Code refactoring without behavior changes | `refactor: simplify auth module` |
|
|
| `test` | Adding or fixing tests | `test: add login unit tests` |
|
|
| `chore` | Maintenance tasks | `chore: update dependencies` |
|
|
|
|
### Scope (Optional)
|
|
|
|
Scope should be lowercase and match the feature/module name:
|
|
- `auth`, `database`, `api`, `frontend`, `ui`, etc.
|
|
|
|
### Subject Guidelines
|
|
|
|
- Use imperative, present tense ("add" not "added" or "adds")
|
|
- Don't capitalize first letter
|
|
- No period at end
|
|
- Keep it short and descriptive
|
|
|
|
### Example Commit Messages
|
|
|
|
```bash
|
|
# Correct:
|
|
feat(auth): add email validation to registration form
|
|
|
|
fix(database): resolve connection timeout issue
|
|
|
|
docs(api): update endpoint documentation with new auth requirements
|
|
|
|
refactor(ui): extract reusable header component
|
|
|
|
test: improve coverage for search functionality
|
|
|
|
chore(deps): bump lodash from 4.17.20 to 4.17.21
|
|
```
|
|
|
|
### Conventions
|
|
|
|
- **Add**: Add something that doesn't exist yet (new files)
|
|
- **Fix**: Something broken, missing, or not working as expected
|
|
- **Revert**: Revert previous commits
|
|
- **Style**: White-space, formatting, missing semi-colons, etc.
|
|
- **Refactor**: Completely changing the structure (not adding/removing features)
|
|
- **Test**: Adding tests for existing code
|
|
- **Build**: Changes that affect the build system or external dependencies
|
|
- **Chore**: Maintenance tasks
|
|
|
|
## Pull Request Process
|
|
|
|
1. **Fork** the repository
|
|
2. **Clone** your fork
|
|
3. **Create a feature branch** from `develop`
|
|
4. **Make your changes** and ensure tests pass
|
|
5. **Commit** with proper message format
|
|
6. **Push** to your fork
|
|
7. **Open a pull request** to `develop` (or `main` for hotfixes)
|
|
|
|
### Pull Request Template Requirements
|
|
|
|
Your PR must include:
|
|
- [ ] Description of changes
|
|
- [ ] Issue numbers referenced (if applicable)
|
|
- [ ] Screenshots/recordings (for UI changes)
|
|
- [ ] Before/after code comparison (for refactors)
|
|
- [ ] Test results or coverage reports
|
|
- [ ] Any breaking changes noted
|
|
|
|
### PR Checklist
|
|
|
|
- [x] All tests pass locally
|
|
- [x] Code follows project style guidelines
|
|
- [x] Commit messages follow Conventional Commits format
|
|
- [x] Documentation updated (if applicable)
|
|
- [x] No sensitive information committed
|
|
- [x] PR is against the correct branch (`develop` or `main`)
|
|
- [x] All CI checks pass
|
|
|
|
## Reporting Bugs
|
|
|
|
Please create an issue with:
|
|
1. **Clear title** describing the problem
|
|
2. **Steps to reproduce** (numbered list)
|
|
3. **Expected behavior** vs **actual behavior**
|
|
4. **Environment info**: browser, OS, node version, etc.
|
|
5. **Screenshots** if applicable
|
|
|
|
## Adding Features
|
|
|
|
When adding new features:
|
|
|
|
1. **Create an issue** first - discuss implementation approach
|
|
2. **Check dependencies** - minimize external libraries
|
|
3. **Write tests** before implementing (TDD approach encouraged)
|
|
4. **Update documentation** as needed
|
|
5. **Add changelog entry** via commit message
|
|
6. **Consider backwards compatibility**
|
|
|
|
## Code Review
|
|
|
|
- Be constructive and respectful
|
|
- Focus on code quality, not personal preferences
|
|
- Check for test coverage
|
|
- Verify PR checklist is complete
|
|
- Ensure commits follow guidelines
|
|
|
|
## Questions?
|
|
|
|
Open an issue or discuss in the project's issues section. We welcome all contributions!
|