From 90ba659a705d62a0e706271ac0b7b784469ddaf3 Mon Sep 17 00:00:00 2001 From: ARYAN-NIKNEZHAD Date: Tue, 20 Aug 2024 06:11:38 +0430 Subject: [PATCH 1/8] :wrench: chore: Add-pre-commit-config - Hook for checks - Hook for Isort - Hook for black --- .pre-commit-config.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..bb4606f --- /dev/null +++ b/.pre-commit-config.yaml @@ -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/).* \ No newline at end of file From 65071bd33d099f573dc740f20f1a10855622ac14 Mon Sep 17 00:00:00 2001 From: ARYAN-NIKNEZHAD Date: Tue, 20 Aug 2024 07:26:52 +0430 Subject: [PATCH 2/8] :wrench: chore: Add Tox Config Closes(#34) --- tox.ini | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tox.ini diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..5a48fa9 --- /dev/null +++ b/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = + py38-django40, py39-django40, py310-django40, py311-django40, py312-django40, + py310-django50, py311-django50, py312-django50 + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 + 3.12: py312 + +[testenv] +description = Run Pytest tests with multiple django versions +usedevelop = True +deps = + django40: django>=4.2,<5.0 + django50: django>=5.0,<5.3 + pytest + pytest-django + pytest-cov + django-stubs +commands = + pytest --cov + +setenv = + DJANGO_SETTINGS_MODULE = kernel.settings + +[testenv:pre-commit] +description = Run pre-commit hooks +deps = + pre-commit +commands = + pre-commit run --all-files \ No newline at end of file From dfcc8630fe9ec7f4f6fa1c68540c59c6df3dbc4b Mon Sep 17 00:00:00 2001 From: ARYAN-NIKNEZHAD Date: Tue, 20 Aug 2024 10:32:04 +0430 Subject: [PATCH 3/8] :green_heart: chore: Add CI workflow for automated testing and code quality checks - Set up GitHub Actions workflow to run on push and pull request events. - Include steps to check out the repository, set up Python, and install dependencies. - Run tests with pytest and generate a coverage report using coverage. - Add Tox to test across multiple Python environments and configurations. - Implement pre-commit hooks to enforce code quality and style. - Upload coverage reports to Codecov for coverage tracking. This CI setup ensures continuous integration with automated testing and code quality checks, improving the overall reliability of the codebase. Closes(#36) --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2ba412b --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 }} \ No newline at end of file From 0b132d51216ca7fb6219ea6a104f0f9ffdf67551 Mon Sep 17 00:00:00 2001 From: Sepehr Akbarzadeh Date: Fri, 23 Aug 2024 15:09:42 +0330 Subject: [PATCH 4/8] build(version): upgrade version enhance configurations --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 27d84d0..2decbd9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django-sage-tools" -version = "0.2.0" +version = "0.2.1" description = "Reusable, generic mixins for Django" authors = ["Sepehr Akbarzadeh "] license = "MIT" From 71ee560cd7441cb44d125444fe6510abb81a2b09 Mon Sep 17 00:00:00 2001 From: ARYAN-NIKNEZHAD Date: Sun, 25 Aug 2024 10:08:28 +0430 Subject: [PATCH 5/8] :books: docs: Add code-of-conduct file --- CODE_OF_CONDUCT.md | 166 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..e655be2 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -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: + +``` +[optional scope]: + +[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. From dcc2bb9df48b2f4a80c2f9888bccc4386dd1ac1a Mon Sep 17 00:00:00 2001 From: ARYAN-NIKNEZHAD Date: Sun, 25 Aug 2024 10:20:19 +0430 Subject: [PATCH 6/8] :books: docs: Add-contributing file Closes(#40) --- CONTRIBUTING.md | 139 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6b6d11c --- /dev/null +++ b/CONTRIBUTING.md @@ -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! From 8a9a4938138281411db50d2c61d7f9e8d2b38e30 Mon Sep 17 00:00:00 2001 From: ARYAN-NIKNEZHAD Date: Sun, 25 Aug 2024 10:37:37 +0430 Subject: [PATCH 7/8] :wrench: chore: Update-pytest-config --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a11c942..827cfe6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ pytest = "^8.3.2" pytest-cov = "^5.0.0" [tool.pytest.ini_options] -addopts = "--cov=. --cov-report=term-missing --cov-report=html" +addopts = "--cov=. --cov-report=term-missing --cov-report=html --cov-fail-under=90" DJANGO_SETTINGS_MODULE = "kernel.settings" python_files = ["tests.py", "test_*.py"] testpaths = ["tests"] From ef59f777ff3045e1d26582c737e703742f1dea19 Mon Sep 17 00:00:00 2001 From: Sepehr Akbarzadeh Date: Sun, 25 Aug 2024 09:56:37 +0330 Subject: [PATCH 8/8] build(pypi): update version because of versioning problem --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f2ac3b6..41b0003 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django-sage-tools" -version = "0.2.1" +version = "0.2.2" description = "Reusable, generic mixins for Django" authors = ["Sepehr Akbarzadeh "] license = "MIT"