Contributing
We’re excited that you’re interested in contributing to dj-announcement-api! Whether you’re fixing a bug, adding a feature, or improving the project, your help is appreciated.
Overview
Setting Up Your Environment
Testing Your Changes
Code Style Guidelines
Utilizing Pre-commit Hooks
Creating a Pull Request
Reporting Issues
Resources
Setting Up Your Environment
Fork the Repository:
Begin by forking the dj-announcement-api repository on GitHub. This creates your own copy where you can make changes.
Clone Your Fork:
Use the following command to clone your fork locally:
git clone https://github.com/your-username/dj-announcement-api.git cd dj-announcement-api
Install Dependencies:
Install the necessary dependencies using
Poetry. If Poetry isn’t installed on your machine, you can find installation instructions on the Poetry website.poetry installCreate a Feature Branch:
It’s a good practice to create a new branch for your work:
git checkout -b feature/your-feature-name
Testing Your Changes
We use pytest for running tests. Before submitting your changes, ensure that all tests pass:
poetry run pytest
If you’re adding a new feature or fixing a bug, don’t forget to write tests to cover your changes.
Code Style Guidelines
Maintaining a consistent code style is crucial. We use black for code formatting and isort for import sorting. Make sure your code adheres to these styles:
poetry run black .
poetry run isort .
For linting, pylint is used to enforce style and catch potential errors:
poetry run pylint django_announcement
Utilizing Pre-commit Hooks
Pre-commit hooks are used to automatically check and format code before you make a commit. This ensures consistency and quality in the codebase.
Install Pre-commit:
poetry add --group dev pre-commit
Set Up the Hooks:
Install the pre-commit hooks by running:
poetry run pre-commit install
Set Up django_migration_linter:
To ensure that
django_migration_linterfunctions properly, add it to the INSTALLED_APPS section in yoursettings.pyfile:INSTALLED_APPS = [ # ... "django_migration_linter" # ... ]
This step integrates the migration linter into your Django project, allowing it to monitor migrations effectively.
Manual Hook Execution (Optional):
To run all hooks manually on your codebase:
poetry run pre-commit run --all-files
Creating a Pull Request
Once your changes are ready, follow these steps to submit them:
Commit Your Changes:
Write clear and concise commit messages. Following the Conventional Commits format is recommended:
git commit -am 'refactor: update api announcement permission class'
Push Your Branch:
Push your branch to your fork on GitHub:
git push origin feature/your-feature-name
Open a Pull Request:
Go to the original dj-announcement-api repository and open a pull request. Include a detailed description of your changes and link any related issues.
Respond to Feedback:
After submitting, a maintainer will review your pull request. Be prepared to make revisions based on their feedback.
Reporting Issues
Found a bug or have a feature request? We’d love to hear from you!
Open an Issue:
Head over to the Issues section of the dj-announcement-api repository and click “New Issue”.
Describe the Problem:
Fill out the issue template with as much detail as possible. This helps us understand and address the issue more effectively.
Resources
Here are some additional resources that might be helpful:
Thank you for your interest in contributing to dj-announcement-api! We look forward to your contributions.