diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..aae3c3b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: Python CI + +on: + push: + branches: [main] + pull_request: + branches: + - '**' + + +jobs: + run_tests: + name: tests + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python-version: ['3.12'] + toxenv: [quality] + + steps: + - uses: actions/checkout@v3 + - name: setup python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Dependencies + run: pip install -r requirements/dev.txt + + - name: Run Tox + env: + TOXENV: ${{ matrix.toxenv }} + run: tox diff --git a/Dockerfile b/Dockerfile index 159cbb6..3c1b87f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ ENV PYTHONUNBUFFERED 1 WORKDIR /app COPY . /app/ -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements/base.txt COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh diff --git a/README.md b/README.md index 36eb0a5..897bfd2 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ $ pyenv activate venv-3.12.6 ### Install dependencies: At project root run the following command to install dependencies: ```bash -$ pip install -r requirements.txt +$ pip install -r requirements/base.txt ``` ### Database setup Create a new database using command diff --git a/pylintrc b/pylintrc new file mode 100644 index 0000000..97606a3 --- /dev/null +++ b/pylintrc @@ -0,0 +1,54 @@ +[MASTER] +ignore = migrations, management +load-plugins = pylint_django + +[MESSAGES CONTROL] +disable= + invalid-name, + django-not-configured, + consider-using-with, + bad-option-value, + too-many-positional-arguments, + logging-format-interpolation, + missing-module-docstring, + abstract-method, + +[MISCELLANEOUS] +notes = FIXME,XXX,TODO + +[SIMILARITIES] +min-similarity-lines = 4 +ignore-comments = yes +ignore-docstrings = yes +ignore-imports = no + +[VARIABLES] +init-import = no +dummy-variables-rgx = _|dummy|unused|.*_unused +additional-builtins = + +[CLASSES] +defining-attr-methods = __init__,__new__,setUp +valid-classmethod-first-arg = cls +valid-metaclass-classmethod-first-arg = mcs + +[DESIGN] +max-args = 5 +ignored-argument-names = _.* +max-locals = 15 +max-returns = 6 +max-branches = 12 +max-statements = 50 +max-parents = 7 +max-attributes = 7 +min-public-methods = 2 +max-public-methods = 20 + +[IMPORTS] +deprecated-modules = regsub,TERMIOS,Bastion,rexec +import-graph = +ext-import-graph = +int-import-graph = + +[EXCEPTIONS] +overgeneral-exceptions = builtins.Exception diff --git a/requirements.txt b/requirements/base.txt similarity index 100% rename from requirements.txt rename to requirements/base.txt diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 0000000..e754cc2 --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1,5 @@ +tox==4.24.1 +pylint==3.3.3 +pycodestyle==2.12.1 +isort==5.13.2 +pylint_django==2.6.1 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..8d29eb3 --- /dev/null +++ b/tox.ini @@ -0,0 +1,47 @@ +[tox] +envlist = py312-django{42} + +[isort] +line_length = 120 +known_django = django +known_first_party = events,users +include_trailing_comma = true +multi_line_output = 3 + +[pycodestyle] +exclude = .git,.tox,migrations +max-line-length = 120 + +[testenv] +setenv = + TOXENV={envname} +deps = + django42: Django>=4.2,<5.0 + -r{toxinidir}/requirements/base.txt +commands = + python manage.py check + +[testenv:isort] +deps = + -r{toxinidir}/requirements/dev.txt +commands = + isort --skip migrations events users manage.py + +[testenv:isort-check] +deps = + -r{toxinidir}/requirements/dev.txt +commands = + isort --skip migrations --check-only --diff events users manage.py +[testenv:quality] +setenv = + DJANGO_SETTINGS_MODULE = arbisoft_sessions_portal.settings.base +allowlist_externals = + rm + touch +deps = + -r{toxinidir}/requirements/base.txt + -r{toxinidir}/requirements/dev.txt +commands = + pylint events users manage.py + pycodestyle events users manage.py + isort --skip migrations --check-only --diff events users manage.py