Skip to content

Commit

Permalink
Merge pull request #19 from MohmdFo/main
Browse files Browse the repository at this point in the history
refactor(sage_mailbox): restructure project and update pre-commit con…
  • Loading branch information
sepehr-akbarzadeh authored Sep 16, 2024
2 parents 2a4fe15 + ae9f951 commit a6252d7
Show file tree
Hide file tree
Showing 43 changed files with 1,549 additions and 733 deletions.
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ sage.py
*/sage.py

*/attachments/*
attachments/

# ruff
.ruff_cache/
Expand All @@ -176,4 +177,7 @@ manage.py

# Ignore all migrations files except __init__.py
**/migrations/*
!**/migrations/__init__.py
!**/migrations/__init__.py

venv_3_8
bandit_report.txt
122 changes: 112 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,130 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-toml
- id: check-yaml
files: \.yaml$
- 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/psf/black
rev: 23.3.0
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.2.1
hooks:
- id: black
exclude: docs/
- id: pyproject-fmt

- repo: https://github.com/tox-dev/tox-ini-fmt
rev: 1.3.1
hooks:
- id: tox-ini-fmt

- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.5.5
hooks:
- id: ruff
args: ["--config=pyproject.toml"]
exclude: (migrations/|tests/|docs/|static/|media/|apps.py).*

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

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: ["--config=pyproject.toml"]
exclude: (migrations/|tests/|docs/|static/|media/).*

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.28.0
hooks:
- id: mypy
args: ["--config-file=mypy.ini"]
exclude: ^(docs/|stubs/|tests/)
- id: commitizen

- repo: https://github.com/PyCQA/bandit
rev: 1.7.4
hooks:
- id: bandit
args: ["-c", "pyproject.toml", "-r", "."]
additional_dependencies: ["bandit[toml]"]
exclude: (migrations/|tests/|docs/|static/|media/).*

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.18.0
hooks:
- id: blacken-docs
additional_dependencies:
- black==24.4.2
files: '\.rst$'

- repo: https://github.com/rstcheck/rstcheck
rev: "v6.2.4"
hooks:
- id: rstcheck
args: ["--report-level=warning"]
files: ^docs/(.*/)*.*\.rst$
additional_dependencies: ["Sphinx==6.2.1"]

- repo: https://github.com/regebro/pyroma
rev: "4.2"
hooks:
- id: pyroma
always_run: false
files: |
(?x)^(
README.md|
pyproject.toml|
)$
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: v0.7.3
hooks:
- id: pydocstringformatter
args: ["--max-summary-lines=2", "--linewrap-full-docstring"]
files: "sage_mailbox"

- repo: local
hooks:
- id: pytest
name: Pytest
entry: poetry run pytest -v
language: system
types: [python]
stages: [commit]
pass_filenames: false
always_run: true

- id: pylint
name: Pylint
entry: pylint
language: system
types: [python]
require_serial: true
args:
- "-rn"
- "-sn"
- "--rcfile=pyproject.toml"
- "--fail-under=9.0"
files: ^sage_mailbox/

ci:
skip: [
pylint,
pytest
]
13 changes: 0 additions & 13 deletions .pylintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ sphinx:
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: requirements.txt
- requirements: requirements/dev.txt
186 changes: 186 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
## 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/<your-username>/django-sage-mailbox.git
cd django-sage-invoice
```


2. **Initialize Git Flow**: Set up Git Flow to manage your branches efficiently.
```bash
git flow init
```
Follow the prompts to configure Git Flow. The default options usually suffice.

3. **Create a Branch**: Create a new branch for your feature or bugfix using Git Flow.

- **Creating a Feature Branch**:
```bash
git flow feature start your-feature-name
```
This will create and check out a new branch from the `develop` branch.

- **Creating a Bugfix Branch**:
```bash
git flow bugfix start your-bugfix-name
```
This will create and check out a new branch specifically for the bugfix.

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

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

6. **Run Code Quality Checks**: Ensure code quality with pre-commit, Ruff, and Pylint.
```bash
poetry run pre-commit run --all-files
poetry run ruff check sage_mailbox/ --fix
poetry run black sage_mailbox/
poetry run isort sage_mailbox/
poetry run pylint sage_mailbox/
poetry run bandit -r sage_mailbox/ -c pyproject.toml
```

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

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

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

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

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

12. **Export Dependencies**: Export dependencies for development and production.
```bash
poetry export -f requirements.txt --output requirements/prod.txt --without-hashes
poetry export -f requirements.txt --dev --output 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
```
build(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)
```
build(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
```
build(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.
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

Loading

0 comments on commit a6252d7

Please sign in to comment.