Skip to content

Commit

Permalink
Merge pull request #16 from MohmdFo/main
Browse files Browse the repository at this point in the history
build(chore): project configuration and apply pre-commit rules across codebase
  • Loading branch information
sepehr-akbarzadeh authored Oct 26, 2024
2 parents 4b2e60d + fce831a commit 8f2be6a
Show file tree
Hide file tree
Showing 62 changed files with 1,503 additions and 938 deletions.
58 changes: 39 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,45 @@ on: [push, pull_request]

jobs:
test:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest

env:
PYTHONPATH: ${{ github.workspace }}

strategy:
matrix:
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'

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: Upload coverage to Codecov
run: codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coverage codecov pytest poetry
pip install -r packages/requirements-dev.txt
- name: Run tests with coverage
run: pytest --cov=iranian_cities --cov-report=xml

- name: Run Tox tests
run: tox

- name: Run pre-commit hooks
run: pre-commit run --all-files --config=.pre-commit-config-ci.yaml

- name: Upload coverage to Codecov
run: codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@ manage.py

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

bar_codes/
qr_codes/
85 changes: 67 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
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
Expand All @@ -15,46 +18,88 @@ repos:
- id: check-docstring-first
exclude: (migrations/|tests/|docs/|static/|media/).*

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

- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: 1.3.1
hooks:
- id: black
args: ["--config=pyproject.toml"]
exclude: (migrations/|tests/|docs/|static/|media/).*
- 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: (migrations/|tests/|docs/|static/|media/).*

- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: docformatter
args: ["--in-place", "--recursive", "--blank"]
- id: black
args: ["--config=pyproject.toml"]
exclude: (migrations/|tests/|docs/|static/|media/).*

- repo: https://github.com/commitizen-tools/commitizen
rev: v3.28.0
hooks:
- id: commitizen
exclude: (migrations/|tests/|docs/|static/|media/).*

- repo: https://github.com/PyCQA/bandit
rev: 1.7.4
hooks:
- id: bandit
args: ["-c", "pyproject.toml", "-r", "."]
additional_dependencies: [ "bandit[toml]" ]
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_qrcode"

- repo: local
hooks:
- id: pytest
Expand All @@ -67,7 +112,7 @@ repos:
always_run: true

- id: pylint
name: pylint
name: Pylint
entry: pylint
language: system
types: [python]
Expand All @@ -76,7 +121,11 @@ repos:
- "-rn"
- "-sn"
- "--rcfile=pyproject.toml"
- "--fail-under=9.0"
files: ^sage_qrcode/

ci:
skip: [pylint]
skip: [
pylint,
pytest
]
54 changes: 35 additions & 19 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,69 @@ Thank you for your interest in contributing to our package! This document outlin
cd django-sage-qrcode
```

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

2. **Initialize Git Flow**: Set up Git Flow to manage your branches efficiently.
```bash
git checkout -b feature/your-feature-name
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.

3. **Install Dependencies**: Use Poetry to install dependencies.
4. **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. **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.
6. **Run Code Quality Checks**: Ensure code quality with pre-commit, Ruff, and Pylint.
```bash
pre-commit run --all-files
ruff check django_sage_qrcode --fix
black django_sage_qrcode/
isort django_sage_qrcode/
pylint django_sage_qrcode
poetry run pre-commit run --all-files
poetry run ruff check sage_qrcode/ --fix
poetry run black sage_qrcode/
poetry run isort sage_qrcode/
poetry run pylint sage_qrcode/
```

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

7. **Commit Changes**: Use Commitizen to commit your changes.
8. **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.
9. **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.
10. **Bump Version**: Use Commitizen to bump the version.
```bash
cz bump
```

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

11. **Export Dependencies**: Export dependencies for development and production.
12. **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
Expand Down Expand Up @@ -87,7 +103,7 @@ feat(core): initialize the core module
### 2. Release with build and tag version
```
chore(release): build and tag version 1.0.0
build(release): build and tag version 1.0.0

- Built the project for production
- Created a new tag for version 1.0.0
Expand Down Expand Up @@ -123,7 +139,7 @@ docs(sphinx): update API documentation
### 6. Update dependencies (packages)
```
chore(deps): update project dependencies
build(deps): update project dependencies

- Updated all outdated npm packages
- Resolved compatibility issues with new package versions
Expand All @@ -132,7 +148,7 @@ chore(deps): update project dependencies
### 7. Update version for build and publish
```
chore(version): update version to 2.1.0 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
Expand Down
Loading

0 comments on commit 8f2be6a

Please sign in to comment.