Thank you for your interest in contributing to NyaProxy! This document outlines the process for contributing to the project and helps ensure a smooth collaboration experience.
- Code of Conduct
- Development Workflow
- Branch Strategy
- Setting Up Development Environment
- Code Style and Standards
- Pull Request Process
- Testing
- Reporting Bugs
- Requesting Features
- Release Process
We expect all contributors to treat each other with respect and maintain a positive, constructive environment. Please be considerate of differing viewpoints and experiences, and focus on what is best for the community and the project.
NyaProxy follows a structured development workflow with three main branches:
Feature Branch → dev → staging → main (production)
- dev: Active development branch. All new features and fixes are integrated here first.
- staging: Pre-production testing branch. Changes from dev are promoted here for integration testing.
- main: Production branch. Only thoroughly tested code from staging reaches this branch.
This graduated deployment approach ensures stability in production while allowing active development to continue.
- Always create feature branches from
dev - Use descriptive branch names with the following convention:
feature/short-descriptionfor new featuresfix/issue-descriptionfor bug fixesdocs/update-descriptionfor documentation changesrefactor/component-namefor code refactoring
- Keep branches focused on a single feature or fix
- Fork the repository
- Clone your fork:
git clone https://github.com/your-username/nyaproxy.git
cd nyaproxy- Add the upstream repository as a remote:
git remote add upstream https://github.com/Nya-Foundation/nyaproxy.git- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activateNyaProxy uses automated tools to maintain consistent code style and type safety:
- Ruff: Python linting, import sorting, and code formatting
- mypy: Static type checking (see the ratchet note below)
mypy does not yet pass on the whole codebase. pyproject.toml
([tool.mypy]) lists the modules that are currently type-clean, and only
those are checked in CI. When you clean up a legacy module, add it to that
files list so it can never regress.
Our CI pipeline also checks formatting on every PR, but it's best to format
your code with make format before pushing. Run make check to reproduce
the complete CI quality checks locally.
- Create a branch from
devfor your changes - Make your changes following our code style guidelines
- Add tests for new features or bug fixes
- Ensure all tests pass locally
- Push your branch to your fork
- Open a pull request to the
devbranch of the main repository - Ensure the PR description clearly describes the changes and their purpose
- Ensure the PR passes all CI checks
- Address any feedback from reviewers
All pull requests require at least one approval from a maintainer before merging.
All new code should include tests at the right level:
- Unit tests for isolated functions, classes, and edge cases
- End-to-end tests for proxy behavior that depends on real HTTP routing, config loading, queueing, retries, or upstream responses
The test suite is organized as:
tests/
unit/ # focused tests for internal logic
e2e/ # true local proxy + mock upstream tests
Install development dependencies:
pip install -e ".[dev]"Or, if you use uv:
uv run --extra dev python -m pytest --versionRun the full test suite:
pytestWith uv:
uv run --extra dev python -m pytestRun unit tests only:
pytest tests/unitRun E2E tests only:
pytest tests/e2e -m e2eWith uv:
uv run --extra dev python -m pytest tests/e2e -m e2eE2E tests start real local services:
- a mock upstream API on a random
127.0.0.1port - a NyaProxy process on a random
127.0.0.1port - a temporary YAML config file that points NyaProxy to the mock upstream
The mock upstream records each received request, including path, method, body, and injected upstream key. Tests then send real HTTP requests through NyaProxy and assert externally visible behavior.
Current E2E coverage includes:
- credential injection and round-robin key rotation
- retry behavior that rotates to the next key after retryable status codes such as
429 - path policy rejection before requests reach the upstream
- key rate-limit queueing
- streaming response forwarding
- request body substitution
Keep E2E tests focused. Prefer one test per user-visible proxy behavior. Do not duplicate unit-level assertions in E2E unless the behavior only appears when the proxy, config file, queue, and upstream server run together.
For coverage information:
pytest --cov=nya tests/ --cov-report=termWhen running E2E tests, coverage from the NyaProxy subprocess is not included in the parent pytest coverage report unless subprocess coverage is explicitly configured. Treat E2E tests primarily as behavioral checks, not coverage boosters.
Our CI pipeline automatically runs tests across supported Python versions.
When reporting bugs, please use the GitHub issue tracker and include:
- A clear, descriptive title
- Steps to reproduce the issue
- Expected behavior
- Actual behavior
- Environment details (OS, Python version, etc.)
- Screenshots or logs if applicable
Feature requests are welcome! Please include:
- A clear description of the problem you're trying to solve
- The solution you'd like to see
- Alternatives you've considered
- Any additional context or screenshots
Our release process is fully automated using semantic-release:
- Changes integrated into
devare tested by our CI pipeline - When ready, changes are promoted to
stagingfor further testing - Finally, changes are merged to
mainfor production release - When code reaches
main, our CI/CD pipeline:- Runs tests and security scans
- Calculates the next version based on commit messages
- Creates a GitHub release with changelog
- Publishes the package to PyPI
- Builds and pushes Docker images
We follow Semantic Versioning for version numbers.
We use the Conventional Commits specification for commit messages, which helps with automated versioning:
feat: add new feature(triggers a minor version bump)fix: resolve bug(triggers a patch version bump)docs: update documentation(no version bump)refactor: improve code structure(no version bump)test: add tests(no version bump)chore: update dependencies(no version bump)
Breaking changes should be noted with BREAKING CHANGE: in the commit message, which will trigger a major version bump.
Thank you for contributing to NyaProxy! Your time and expertise help make this project better for everyone.