First off, thank you for considering contributing to Pharox! We welcome any contributions, from fixing a typo to implementing a new feature.
This document provides a guide for making contributions to the project.
- Getting Started: Your Development Environment
- The Development Workflow
- Running Tests
- Submitting Your Contribution
- Versioning and Releases (For Maintainers)
To ensure a consistent development experience, we use Poetry to manage dependencies and virtual environments.
Prerequisites:
Setup Steps:
-
Fork the repository: Click the "Fork" button on the top right of the GitHub repository page.
-
Clone your fork:
git clone https://github.com/fzaca/pharox.git cd pharox -
Install dependencies and activate the environment: Poetry will create a virtual environment and install all required dependencies, including development tools like
pytestandruff.poetry install
-
Activate the virtual environment: To use the installed tools, you need to be inside the project's virtual environment.
poetry shell
-
Set up pre-commit hooks: We use
pre-committo automatically lint and format your code before you commit it. This helps maintain a consistent code style.pre-commit install
You are now ready to start developing!
-
Create a new branch: Work on a separate branch to keep your changes organized. Name it descriptively.
# Example: git checkout -b feature/add-new-proxy-strategy # Example: git checkout -b fix/resolve-caching-bug git checkout -b <type>/<short-description>
-
Write your code: All the library's source code is located in the
src/pharoxdirectory. -
Write or update tests: Tests are crucial! Make sure to add or update tests for any changes you make. Tests reside in the
tests/directory. -
Commit your changes: When you're ready, stage and commit your files.
git add . git commit -m "feat: Add new proxy rotation strategy"
When you run
git commit,pre-commitwill automatically runruffto format and lint your code. If it makes any changes, you'll need togit add .the modified files and run the commit command again.
To ensure your changes haven't broken anything, run the full test suite with pytest. We also check for test coverage.
# Make sure you are in the poetry shell
pytestThis command will run all tests in the tests/ directory and print a coverage report to the terminal. Aim for high test coverage for any new code you add.
You can also run specific tests:
pytest tests/test_my_feature.py-
Push your branch to your fork:
git push origin <your-branch-name>
-
Open a Pull Request (PR): Go to the original repository on GitHub. You should see a prompt to create a Pull Request from your recently pushed branch.
-
Fill out the PR template:
- Provide a clear title and a concise description of your changes.
- Link to any relevant issues (e.g., "Closes #42").
- Explain your changes and why they are needed.
-
Wait for review: A maintainer will review your PR. They may request changes. Once your PR is approved and all checks pass, it will be merged into the
mainbranch.
This project follows Semantic Versioning (MAJOR.MINOR.PATCH) and uses Commitizen to automate versioning and changelog generation.
Release Process:
-
Ensure
mainis stable: All tests must be passing on themainbranch. -
Create a new release: The
cz bumpcommand automates the entire release process based on the commit history since the last tag. It will:- Determine the correct version bump (
PATCH,MINOR, orMAJOR). - Update the version in
pyproject.toml. - Generate or update the
CHANGELOG.mdfile. - Create a new git tag for the release.
# This single command handles everything cz bump - Determine the correct version bump (
-
Generate release notes: Use the helper script to extract the latest changelog entry (it defaults to the current Poetry version). Pipe it to a file that you can upload to GitHub releases or automate further.
poetry run python scripts/generate_release_notes.py \ --output dist/release-notes/v$(poetry version -s).mdThe command prints the destination file path. Use its contents as the body of the GitHub release or feed it into
gh release create. -
Push the changes and tags: After the command completes, push the commit and the new tag to the remote repository. The GitHub Actions workflow will then publish the package to PyPI.
git push --tags