-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
317 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,99 @@ | ||
name: Full CI | ||
name: CI for Tests and Package Publishing | ||
|
||
on: | ||
push: | ||
branches: [main, dev] | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: | ||
- main | ||
release: | ||
types: [published] | ||
types: | ||
- published | ||
workflow_dispatch: | ||
inputs: | ||
job: | ||
description: 'Choose which job to run' | ||
required: true | ||
default: 'deploy' | ||
type: choice | ||
options: | ||
- publish-module | ||
- test-Django | ||
- coverage | ||
- all | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test-Django: | ||
if: github.event.inputs.job == 'test-Django' || github.event.inputs.job == 'all' || github.event_name == 'release' || github.event_name == 'push' | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- 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: | | ||
cd ./test/app/ | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install ../../ | ||
- name: Run Tests | ||
run: | | ||
cd ./test/app/ | ||
python manage.py test | ||
coverage: | ||
if: github.event.inputs.job == 'coverage' || github.event.inputs.job == 'all' || github.event_name == 'release' || github.event_name == 'push' | ||
runs-on: ubuntu-latest | ||
needs: test-Django | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
- name: Install Dependencies | ||
run: | | ||
cd ./test/app/ | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install coverage | ||
pip install ../../ | ||
- name: Run Coverage | ||
run: | | ||
cd ./test/app/ && coverage run manage.py test && coverage html && coverage xml | ||
- name: Upload Coverage to GitHub | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-report | ||
path: ./test/app/htmlcov | ||
- name: Report Coverage | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./test/app/htmlcov/coverage.xml | ||
|
||
publish-module: | ||
if: github.event_name == 'release' || github.event.inputs.job == 'publish-module' || github.event.inputs.job == 'all' | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install Poetry | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
export PATH="$HOME/.local/bin:$PATH" | ||
- name: Install dependencies | ||
run: | | ||
poetry install | ||
- name: Run pre-commit hooks | ||
run: | | ||
poetry run pre-commit run --all-files | ||
- name: Run tests with tox | ||
run: | | ||
poetry run tox | ||
- name: Stop on failure | ||
if: failure() | ||
run: exit 1 | ||
|
||
- name: Upload to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: coverage.xml | ||
flags: unittests | ||
fail_ci_if_error: true | ||
verbose: true | ||
|
||
- name: Upload test results to Codecov | ||
if: ${{ !cancelled() }} | ||
uses: codecov/test-results-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
- name: Upload HTML coverage report | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-report | ||
path: htmlcov/ | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
needs: [test-Django, coverage] | ||
needs: test | ||
|
||
if: github.event_name == 'release' # Exécuter uniquement lors d'une release | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build | ||
- name: Check current folder | ||
run: | | ||
ls | ||
- name: Build package | ||
run: | | ||
python -m build | ||
- name: Publish build | ||
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install Poetry | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
export PATH="$HOME/.local/bin:$PATH" | ||
- name: Install dependencies | ||
run: poetry install --no-dev | ||
|
||
- name: Build package | ||
run: poetry build | ||
|
||
- name: Publish package | ||
run: poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
[build-system] | ||
build-backend = "poetry.core.masonry.api" | ||
requires = [ "poetry-core" ] | ||
|
||
[tool.poetry] | ||
name = "djangorestframework-hybridrouter" | ||
version = "1.0.0" | ||
description = "Django app that provide an hybrid router for Django Rest Framework" | ||
authors = [ "enzo_frnt" ] | ||
license = "MIT" | ||
readme = "README.md" | ||
keywords = [ "django", "rest", "framework", "router", "hybrid", "views and viewsets" ] | ||
|
||
classifiers = [ | ||
"Development Status :: 5 - Production/Stable", | ||
"Environment :: Web Environment", | ||
"Framework :: Django", | ||
"Framework :: Django :: 4.2", | ||
"Framework :: Django :: 5.0", | ||
"Framework :: Django :: 5.1", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
] | ||
|
||
packages = [ | ||
{ include = "hybridrouter" }, | ||
] | ||
|
||
[tool.poetry.urls] | ||
"Documentation" = "https://github.com/enzofrnt/djangorestframework-hybridrouter/blob/main/README.md" | ||
"Source Code" = "https://github.com/enzofrnt/djangorestframework-hybridrouter" | ||
"Issues" = "https://github.com/enzofrnt/djangorestframework-hybridrouter/issues" | ||
|
||
[tool.poetry.dependencies] | ||
tox = "^4.16.0" | ||
python = ">=3.8,<4.0" | ||
django = [ | ||
{ version = ">=4.2,<5.0", python = ">=3.8,<3.10" }, | ||
{ version = ">=4.2,<5.3", python = ">=3.10" }, # Django 4.2 and 5.x for Python 3.10+ | ||
] | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "8.2.0" | ||
pytest-django = "^4.8.0" | ||
pytest-cov = "^5.0.0" | ||
pylint = "^3.2.6" | ||
pylint-pytest = "^1.1.8" | ||
mypy = "^1.11.1" | ||
isort = "^5.13.2" | ||
black = "^24.4.2" | ||
pre-commit = "^3.5.0" | ||
bandit = { extras = [ "toml" ], version = "^1.7.9" } | ||
tox = "^4.16.0" | ||
django-stubs = "^5.0.4" | ||
codecov = "^2.1.13" | ||
python-semantic-release = "^9.8.8" | ||
|
||
[tool.black] | ||
line-length = 88 | ||
exclude = ''' | ||
/( | ||
\.git | ||
| \.venv | ||
| \.tox | ||
| build | ||
| dist | ||
| migrations | ||
| venv | ||
| env | ||
| __pycache__ | ||
| node_modules | ||
| env | ||
| kernel | ||
| \.mypy_cache | ||
| \.pytest_cache | ||
| .*\.egg-info | ||
)/ | ||
''' | ||
|
||
[tool.isort] | ||
profile = "black" | ||
line_length = 88 | ||
skip = [ | ||
"venv", | ||
".venv", | ||
".tox", | ||
"build", | ||
"dist", | ||
".git", | ||
"__pycache__", | ||
"*.egg-info", | ||
".mypy_cache", | ||
".pytest_cache", | ||
"migrations", | ||
"node_modules", | ||
"env", | ||
"kernel", | ||
] | ||
|
||
[tool.pylint] | ||
disable = [ | ||
"C0103", # Invalid constant name | ||
"C0114", # Missing module docstring | ||
"C0115", # Missing class docstring | ||
"C0116", # Missing function or method docstring | ||
"E1101", # Instance of 'Foo' has no 'bar' member | ||
"W0212", # Access to a protected member | ||
"C0301", # Line too long | ||
"C0411", # Wrong import order | ||
"W0611", # Unused imports | ||
"W0613", # Unused arguments | ||
"W0622", # Redefining built-in names | ||
"R0903", # Too few public methods | ||
"R0801", # Duplicate code | ||
"W0621", | ||
"C0415", | ||
"R1719", # The if expression can be replaced with 'bool(test)' | ||
"R1705", # Unnecessary "elif" after "return" | ||
"R0401", | ||
] | ||
max-line-length = 88 | ||
ignore = [ | ||
"tests", | ||
"migrations/*", | ||
"venv/*", | ||
"build/*", | ||
"dist/*", | ||
".git/*", | ||
".tox/*", | ||
"__pycache__/*", | ||
"*.egg-info/*", | ||
".mypy_cache/*", | ||
".pytest_cache/*", | ||
] | ||
load-plugins = [ | ||
"pylint_pytest", | ||
] | ||
|
||
suggestion-mode = true | ||
const-rgx = "([A-Z_][A-Z0-9_]*)|(__.*__)" | ||
attr-rgx = "[a-z_][a-z0-9_]{2,30}$" | ||
variable-rgx = "[a-z_][a-z0-9_]{2,30}$" | ||
argument-rgx = "[a-z_][a-z0-9_]{2,30}$" | ||
method-rgx = "[a-z_][a-z0-9_]{2,30}$" | ||
function-rgx = "[a-z_][a-z0-9_]{2,30}$" | ||
class-rgx = "[A-Z_][a-zA-Z0-9]+$" | ||
module-rgx = "(([a-z_][a-z0-9_]*)|(__.*__))$" | ||
|
||
[tool.bandit] | ||
targets = [ "./wait_for_db" ] | ||
exclude_dirs = [ | ||
"tests", | ||
"migrations", | ||
] | ||
severity = "medium" | ||
confidence = "medium" | ||
max_lines = 500 | ||
progress = true | ||
reports = true | ||
output_format = "screen" | ||
output_file = "bandit_report.txt" | ||
include = [ "B101", "B102" ] | ||
exclude_tests = [ "B301", "B302" ] | ||
|
||
[tool.bandit.plugins] | ||
B104 = { check_typed_list = true } |
Oops, something went wrong.