Skip to content

Commit

Permalink
Merge branch 'chore/pyproject.toml-confg' of github.com:ARYAN-NIKNEZH…
Browse files Browse the repository at this point in the history
…AD/django-sage-tools into chore/pyproject.toml-confg
  • Loading branch information
ARYAN-NIKNEZHAD committed Oct 27, 2024
2 parents 1f77463 + 06ac5da commit 35a5d91
Show file tree
Hide file tree
Showing 6 changed files with 402 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coverage codecov pytest
pip install -r packages/requirements-dev.txt
- name: Run tests
run: |
coverage run -m pytest
- name: Generate coverage report
run: coverage xml
- name: Run Tox tests
run: tox
- name: Run pre-commmit hooks
run: tox -e pre-commit
- name: Upload coverage to Codecov
run: codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
exclude: (migrations/|tests/|docs/|static/|media/).*
- id: end-of-file-fixer
exclude: (migrations/|tests/|docs/|static/|media/).*
- id: check-added-large-files
exclude: (migrations/|tests/|docs/|static/|media/).*
- id: check-case-conflict
exclude: (migrations/|tests/|docs/|static/|media/).*
- id: check-merge-conflict
exclude: (migrations/|tests/|docs/|static/|media/).*
- id: check-docstring-first
exclude: (migrations/|tests/|docs/|static/|media/).*


- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
exclude: (migrations/|tests/|docs/|static/|media/).*

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
exclude: (migrations/|tests/|docs/|static/|media/).*
166 changes: 166 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
## Contribution Guidelines

Thank you for your interest in contributing to our package! This document outlines the tools and steps to follow to ensure a smooth and consistent workflow.

## Contribution Workflow

1. **Fork and Clone**: Fork the repository and clone it to your local machine.
```bash
git clone https://github.com/sageteamorg/django-sage-tools.git
cd django-sage-tools
```

2. **Create a Branch**: Create a new branch for your feature or bugfix.
```bash
git checkout -b feature/your-feature-name
```

3. **Install Dependencies**: Use Poetry to install dependencies.
```bash
poetry install
```

4. **Write Code and Tests**: Make your changes and write tests for your new code.

5. **Run Code Quality Checks**: Ensure code quality with pre-commit, Ruff, and Pylint.
```bash
ruff check .
ruff check --fix
```

6. **Run Tests**: Ensure all tests pass using Poetry.
```bash
poetry run pytest
```

7. **Commit Changes**: Use Commitizen to commit your changes.
```bash
cz commit
```

8. **Push and Create a PR**: Push your changes and create a pull request.
```bash
git push origin feature/your-feature-name
```

9. **Bump Version**: Use Commitizen to bump the version.
```bash
cz bump
```

10. **Generate Changelog**: Use Commitizen to generate the changelog.
```bash
cz changelog
```

11. **Export Dependencies**: Export dependencies for development and production.
```bash
poetry export -f requirements.txt --output packages/requirements.txt --without-hashes
poetry export -f requirements.txt --dev --output packages/requirements-dev.txt --without-hashes
```

## Commitizen Message Rule

Commitizen follows the Conventional Commits specification. The commit message should be structured as follows:

```
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]
```
Here are 10 examples of commit messages following the Commitizen Conventional Commits specification:
### 1. Initialization of core
```
feat(core): initialize the core module

- Set up the core structure
- Added initial configurations and settings
- Created basic utility functions
```
### 2. Release with build and tag version
```
chore(release): build and tag version 1.0.0

- Built the project for production
- Created a new tag for version 1.0.0
- Updated changelog with release notes
```
### 3. Adding a new feature
```
feat(auth): add user authentication

- Implemented user login and registration
- Added JWT token generation and validation
- Created middleware for protected routes
```
### 4. Fixing a bug
```
fix(api): resolve issue with data fetching

- Fixed bug causing incorrect data responses
- Improved error handling in API calls
- Added tests for the fixed bug
```
### 5. Update a doc (Sphinx)
```
docs(sphinx): update API documentation

- Updated the Sphinx documentation for API changes
- Added examples for new endpoints
- Fixed typos and formatting issues
```
### 6. Update dependencies (packages)
```
chore(deps): update project dependencies

- Updated all outdated npm packages
- Resolved compatibility issues with new package versions
- Ran tests to ensure no breaking changes
```
### 7. Update version for build and publish
```
chore(version): update version to 2.1.0 for build and publish

- Incremented version number to 2.1.0
- Updated package.json with the new version
- Prepared for publishing the new build
```
### 8. Adding unit tests
```
test(auth): add unit tests for authentication module

- Created tests for login functionality
- Added tests for registration validation
- Ensured 100% coverage for auth module
```
### 9. Refactoring codebase
```
refactor(core): improve code structure and readability

- Refactored core module to enhance readability
- Extracted utility functions into separate files
- Updated documentation to reflect code changes
```
### 10. Improving performance
```
perf(parser): enhance parsing speed

- Optimized parsing algorithm for better performance
- Reduced the time complexity of the parsing function
- Added benchmarks to track performance improvements
```
These examples cover various types of commits such as feature additions, bug fixes, documentation updates, dependency updates, versioning, testing, refactoring, and performance improvements.
139 changes: 139 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Contributing to django-iranian-cities

Thank you for considering contributing to `django-sage-tools`! We welcome contributions from the community to help make this project better.

## Table of Contents

- [Contributing to django-sage-tools](#contributing-to-django-sage-tools)
- [Table of Contents](#table-of-contents)
- [Getting Started](#getting-started)
- [Running Tests](#running-tests)
- [Code Style](#code-style)
- [Pre-commit Hooks](#pre-commit-hooks)
- [Setting Up Pre-commit Hooks](#setting-up-pre-commit-hooks)
- [Submitting a Pull Request](#submitting-a-pull-request)
- [Reporting Issues](#reporting-issues)
- [Additional Resources](#additional-resources)

## Getting Started

1. **Fork the repository on GitHub**:

Go to the [django-sage-tools](https://github.com/your-username/django-sage-tools) repository and click on the "Fork" button in the top-right corner.

2. **Clone your fork locally**:

```bash
git clone https://github.com/your-username/django-sage-tools.git
cd django-sage-tools
```

3. **Install dependencies using Poetry**:

If you don't have Poetry installed, you can install it by following the instructions on the [Poetry website](https://python-poetry.org/docs/#installation).

```bash
poetry install
```

4. **Create a new branch for your feature or bugfix**:

```bash
git checkout -b feature/your-feature
```

## Running Tests

We use `pytest` for testing. To run the tests, execute:

```bash
poetry run pytest
```

Ensure that all tests pass before submitting a pull request.

## Code Style

We use `black` and `isort` to format our code. Please ensure your code is formatted correctly before submitting a pull request:

```bash
poetry run black .
poetry run isort .
```

Additionally, we use `flake8` and `pylint` for linting. You can run these tools to check for code style issues:

```bash
poetry run flake8
poetry run pylint sage_tools
```

## Pre-commit Hooks

We use `pre-commit` to ensure code quality and consistency. Pre-commit hooks will run automatically before each commit to check and format the code.

### Setting Up Pre-commit Hooks

1. **Install pre-commit**:

```bash
poetry add --dev pre-commit
```

2. **Install the pre-commit hooks**:

```bash
poetry run pre-commit install
```

3. **Run pre-commit hooks manually (optional but recommended before committing)**:

```bash
poetry run pre-commit run --all-files
```

The pre-commit configuration is defined in the `.pre-commit-config.yaml` file. Make sure to review and understand the hooks configured.

## Submitting a Pull Request

1. **Commit your changes**:

Write clear and descriptive commit messages. Follow the guidelines in the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification if possible.

```bash
git commit -am 'feat: add new email feature'
```

2. **Push to the branch**:

```bash
git push origin feature/your-feature
```

3. **Open a pull request on GitHub**:

Go to the original repository on GitHub and open a pull request. Provide a clear and descriptive title and description for your pull request. Link to any relevant issues or discussions.

4. **Wait for review**:

One of the project maintainers will review your pull request. Be responsive to feedback and be prepared to make changes if necessary.

## Reporting Issues

If you find a bug or have a feature request, please open an issue on GitHub. Provide as much detail as possible to help us understand and address the issue:

1. **Go to the [Issues](https://github.com/your-username/django-sage-tools/issues) section of the repository.**
2. **Click on "New issue".**
3. **Fill out the issue template with relevant details.**

## Additional Resources

- [Poetry Documentation](https://python-poetry.org/docs/)
- [Black Documentation](https://black.readthedocs.io/en/stable/)
- [isort Documentation](https://pycqa.github.io/isort/)
- [pytest Documentation](https://docs.pytest.org/en/stable/)
- [flake8 Documentation](https://flake8.pycqa.org/en/latest/)
- [pylint Documentation](https://pylint.pycqa.org/en/latest/)
- [Pre-commit Documentation](https://pre-commit.com/)

Thank you for contributing!
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-sage-tools"
version = "0.2.0"
version = "0.2.2"
description = "Reusable, generic mixins for Django"
authors = ["Sepehr Akbarzadeh <[email protected]>"]
license = "MIT"
Expand Down
Loading

0 comments on commit 35a5d91

Please sign in to comment.