diff --git a/.github/actions/services/action.yml b/.github/actions/services/action.yml index 63fe8f0..b814a03 100644 --- a/.github/actions/services/action.yml +++ b/.github/actions/services/action.yml @@ -57,11 +57,10 @@ runs: using: "composite" steps: - - name: Create mongo docker-compose file + - name: Create mongo docker compose file if: inputs.use_mongo run: | - echo "version: '3.8'" > mongo.yml - echo "services:" >> mongo.yml + echo "services:" > mongo.yml echo " mongo:" >> mongo.yml echo " image: library/mongo:${{ inputs.mongo_version }}" >> mongo.yml echo " container_name: mongo" >> mongo.yml @@ -74,11 +73,10 @@ runs: shell: bash - - name: Create postgres docker-compose file + - name: Create postgres docker compose file if: inputs.use_postgres run: | - echo "version: '3.8'" > postgres.yml - echo "services:" >> postgres.yml + echo "services:" > postgres.yml echo " postgres:" >> postgres.yml echo " image: library/postgres:${{ inputs.postgres_version }}-alpine" >> postgres.yml echo " container_name: postgres" >> postgres.yml @@ -96,11 +94,10 @@ runs: shell: bash - - name: Create elasticsearch docker-compose file + - name: Create elasticsearch docker compose file if: inputs.use_elastic_search run: | - echo "version: '3.8'" > elastic_search.yml - echo "services:" >> elastic_search.yml + echo "services:" > elastic_search.yml echo " elastic_search:" >> elastic_search.yml echo " image: elasticsearch:${{ inputs.elasticsearch_version }}" >> elastic_search.yml echo " container_name: elastic_search" >> elastic_search.yml @@ -117,11 +114,10 @@ runs: shell: bash - - name: Create memcached docker-compose file + - name: Create memcached docker compose file if: inputs.use_memcached run: | - echo "version: '3.8'" > memcached.yml - echo "services:" >> memcached.yml + echo "services:" > memcached.yml echo " memcached:" >> memcached.yml echo " container_name: memcached" >> memcached.yml echo " image: memcached:${{ inputs.memcached_version }}-alpine" >> memcached.yml @@ -130,11 +126,10 @@ runs: shell: bash - - name: Create redis docker-compose file + - name: Create redis docker compose file if: inputs.use_redis run: | - echo "version: '3.8'" > redis.yml - echo "services:" >> redis.yml + echo "services:" > redis.yml echo " redis:" >> redis.yml echo " container_name: redis" >> redis.yml echo " image: library/redis:${{ inputs.redis_version }}-alpine" >> redis.yml @@ -143,11 +138,10 @@ runs: shell: bash - - name: Create rabbitmq docker-compose file + - name: Create rabbitmq docker compose file if: inputs.use_rabbitmq run: | - echo "version: '3.8'" > rabbitmq.yml - echo "services:" >> rabbitmq.yml + echo "services:" > rabbitmq.yml echo " rabbitmq:" >> rabbitmq.yml echo " container_name: rabbitmq" >> rabbitmq.yml echo " image: library/rabbitmq:${{ inputs.rabbitmq_version }}-management-alpine" >> rabbitmq.yml @@ -157,9 +151,9 @@ runs: shell: bash - - name: Execute docker-compose up + - name: Execute docker compose up run: | - CLI=docker-compose + CLI="docker compose" if [[ ${{ inputs.use_postgres }} != 'false' ]]; then CLI="${CLI} -f postgres.yml" fi diff --git a/.github/configurations/python_linters/README.md b/.github/configurations/python_linters/README.md index fcf1ca3..9399ec7 100644 --- a/.github/configurations/python_linters/README.md +++ b/.github/configurations/python_linters/README.md @@ -54,3 +54,26 @@ In `.vscode/settings.json` "${workspaceFolder}/.github/configurations/python_linters/.black" ] } +``` + +- ### [PyCharm](https://www.jetbrains.com/pycharm/) +Linters can be run on demand as external tools in the IDE by adding their configurations under **File -> Settings... -> Tools -> External tools**. +Then, add a configuration for each linter by clicking on the **+** button (the working directory must be set to the folder where the `manage.py` file is). +After this configurations, the linters can be run from the menu **Tools -> External tools**. +* Flake8 + * _Name_: `Flake8` + * _Program_: `$PyInterpreterDirectory$/flake8` + * _Arguments_: `$FilePath$ --config ../.github/configurations/python_linters/.flake8` + * _Working directory_: `$ProjectFileDir$/DjangoMainProject` +* Black + * _Name_: `Black` + * _Program_: `$PyInterpreterDirectory$/black` + * _Arguments_: `--config ../.github/configurations/python_linters/.black $FilePath$` + * _Working directory_: `$ProjectFileDir$/DjangoMainProject` +* isort + * _Name_: `isort` + * _Program_: `$PyInterpreterDirectory$/isort` + * _Arguments_: `--sp ../.github/configurations/python_linters/.isort.cfg --profile black $FilePath$` + * _Working directory_: `$ProjectFileDir$/DjangoMainProject` + +With this configuration, the linters are run against the opened file in the editor; to do it against the whole codebase, change the variable *$FilePath$* to the Django root directory. diff --git a/.github/configurations/python_linters/requirements-linters.txt b/.github/configurations/python_linters/requirements-linters.txt index c931ff0..39fb9e3 100644 --- a/.github/configurations/python_linters/requirements-linters.txt +++ b/.github/configurations/python_linters/requirements-linters.txt @@ -1,8 +1,10 @@ -black==23.11.0 -isort==5.12.0 -flake8==6.1.0 -flake8-django==1.4 -pylint==2.17.7 +autoflake==2.3.1 +bandit==1.7.9 +black==24.8.0 +# use fork since main repo is not updated +# see https://github.com/rocioar/flake8-django/pull/134 +flake8-django @ git+https://github.com/terencehonles/flake8-django.git@a6e369e89d275dfd5514f2aa9d091aa36c5ff84b +flake8==7.1.1 +isort==5.13.2 pylint-django==2.5.5 -bandit==1.7.5 -autoflake==2.2.1 \ No newline at end of file +pylint==3.2.6 \ No newline at end of file diff --git a/.github/workflows/pull_request_automation.yml b/.github/workflows/pull_request_automation.yml index 46ac709..c1a29b0 100644 --- a/.github/workflows/pull_request_automation.yml +++ b/.github/workflows/pull_request_automation.yml @@ -76,10 +76,19 @@ jobs: check_dockerfile: Dockerfile use_postgres: false + postgres_db: db + postgres_user: user + postgres_password: password + postgres_version: latest use_memcached: false + memcached_version: latest use_elastic_search: false + elasticsearch_version: 8.11.1 + elasticsearch_port: 9200 use_rabbitmq: true + rabbitmq_version: 3 use_mongo: false + mongo_version: latest use_celery: true celery_app: python_test.celery diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6566756..9aa1555 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,32 +11,32 @@ repos: args: ["--rcfile", ".github/configurations/python_linters/.pylintrc"] - repo: https://github.com/pycqa/bandit - rev: 1.7.4 + rev: 1.7.9 hooks: - id: bandit args: ["-c", ".github/configurations/python_linters/.bandit.yaml"] - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 + rev: 7.1.1 hooks: - id: flake8 exclude: docs/conf.py args: ["--config", ".github/configurations/python_linters/.flake8"] - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort args: ["--settings-path", ".github/configurations/python_linters/.isort.cfg", "--filter-files", "--skip", "venv"] - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 24.8.0 hooks: - id: black args: ["--config", ".github/configurations/python_linters/.black"] - repo: https://github.com/PyCQA/autoflake - rev: v1.7.7 + rev: v2.3.1 hooks: - id: autoflake args: ["-i", "--remove-all-unused-imports", "--remove-unused-variables", "--ignore-init-module-imports", "--ignore-pass-statements"] diff --git a/actions/services/action.yml b/actions/services/action.yml index 63fe8f0..b814a03 100644 --- a/actions/services/action.yml +++ b/actions/services/action.yml @@ -57,11 +57,10 @@ runs: using: "composite" steps: - - name: Create mongo docker-compose file + - name: Create mongo docker compose file if: inputs.use_mongo run: | - echo "version: '3.8'" > mongo.yml - echo "services:" >> mongo.yml + echo "services:" > mongo.yml echo " mongo:" >> mongo.yml echo " image: library/mongo:${{ inputs.mongo_version }}" >> mongo.yml echo " container_name: mongo" >> mongo.yml @@ -74,11 +73,10 @@ runs: shell: bash - - name: Create postgres docker-compose file + - name: Create postgres docker compose file if: inputs.use_postgres run: | - echo "version: '3.8'" > postgres.yml - echo "services:" >> postgres.yml + echo "services:" > postgres.yml echo " postgres:" >> postgres.yml echo " image: library/postgres:${{ inputs.postgres_version }}-alpine" >> postgres.yml echo " container_name: postgres" >> postgres.yml @@ -96,11 +94,10 @@ runs: shell: bash - - name: Create elasticsearch docker-compose file + - name: Create elasticsearch docker compose file if: inputs.use_elastic_search run: | - echo "version: '3.8'" > elastic_search.yml - echo "services:" >> elastic_search.yml + echo "services:" > elastic_search.yml echo " elastic_search:" >> elastic_search.yml echo " image: elasticsearch:${{ inputs.elasticsearch_version }}" >> elastic_search.yml echo " container_name: elastic_search" >> elastic_search.yml @@ -117,11 +114,10 @@ runs: shell: bash - - name: Create memcached docker-compose file + - name: Create memcached docker compose file if: inputs.use_memcached run: | - echo "version: '3.8'" > memcached.yml - echo "services:" >> memcached.yml + echo "services:" > memcached.yml echo " memcached:" >> memcached.yml echo " container_name: memcached" >> memcached.yml echo " image: memcached:${{ inputs.memcached_version }}-alpine" >> memcached.yml @@ -130,11 +126,10 @@ runs: shell: bash - - name: Create redis docker-compose file + - name: Create redis docker compose file if: inputs.use_redis run: | - echo "version: '3.8'" > redis.yml - echo "services:" >> redis.yml + echo "services:" > redis.yml echo " redis:" >> redis.yml echo " container_name: redis" >> redis.yml echo " image: library/redis:${{ inputs.redis_version }}-alpine" >> redis.yml @@ -143,11 +138,10 @@ runs: shell: bash - - name: Create rabbitmq docker-compose file + - name: Create rabbitmq docker compose file if: inputs.use_rabbitmq run: | - echo "version: '3.8'" > rabbitmq.yml - echo "services:" >> rabbitmq.yml + echo "services:" > rabbitmq.yml echo " rabbitmq:" >> rabbitmq.yml echo " container_name: rabbitmq" >> rabbitmq.yml echo " image: library/rabbitmq:${{ inputs.rabbitmq_version }}-management-alpine" >> rabbitmq.yml @@ -157,9 +151,9 @@ runs: shell: bash - - name: Execute docker-compose up + - name: Execute docker compose up run: | - CLI=docker-compose + CLI="docker compose" if [[ ${{ inputs.use_postgres }} != 'false' ]]; then CLI="${CLI} -f postgres.yml" fi diff --git a/configurations/python_linters/README.md b/configurations/python_linters/README.md index fcf1ca3..9399ec7 100644 --- a/configurations/python_linters/README.md +++ b/configurations/python_linters/README.md @@ -54,3 +54,26 @@ In `.vscode/settings.json` "${workspaceFolder}/.github/configurations/python_linters/.black" ] } +``` + +- ### [PyCharm](https://www.jetbrains.com/pycharm/) +Linters can be run on demand as external tools in the IDE by adding their configurations under **File -> Settings... -> Tools -> External tools**. +Then, add a configuration for each linter by clicking on the **+** button (the working directory must be set to the folder where the `manage.py` file is). +After this configurations, the linters can be run from the menu **Tools -> External tools**. +* Flake8 + * _Name_: `Flake8` + * _Program_: `$PyInterpreterDirectory$/flake8` + * _Arguments_: `$FilePath$ --config ../.github/configurations/python_linters/.flake8` + * _Working directory_: `$ProjectFileDir$/DjangoMainProject` +* Black + * _Name_: `Black` + * _Program_: `$PyInterpreterDirectory$/black` + * _Arguments_: `--config ../.github/configurations/python_linters/.black $FilePath$` + * _Working directory_: `$ProjectFileDir$/DjangoMainProject` +* isort + * _Name_: `isort` + * _Program_: `$PyInterpreterDirectory$/isort` + * _Arguments_: `--sp ../.github/configurations/python_linters/.isort.cfg --profile black $FilePath$` + * _Working directory_: `$ProjectFileDir$/DjangoMainProject` + +With this configuration, the linters are run against the opened file in the editor; to do it against the whole codebase, change the variable *$FilePath$* to the Django root directory. diff --git a/configurations/python_linters/requirements-linters.txt b/configurations/python_linters/requirements-linters.txt index c931ff0..39fb9e3 100644 --- a/configurations/python_linters/requirements-linters.txt +++ b/configurations/python_linters/requirements-linters.txt @@ -1,8 +1,10 @@ -black==23.11.0 -isort==5.12.0 -flake8==6.1.0 -flake8-django==1.4 -pylint==2.17.7 +autoflake==2.3.1 +bandit==1.7.9 +black==24.8.0 +# use fork since main repo is not updated +# see https://github.com/rocioar/flake8-django/pull/134 +flake8-django @ git+https://github.com/terencehonles/flake8-django.git@a6e369e89d275dfd5514f2aa9d091aa36c5ff84b +flake8==7.1.1 +isort==5.13.2 pylint-django==2.5.5 -bandit==1.7.5 -autoflake==2.2.1 \ No newline at end of file +pylint==3.2.6 \ No newline at end of file diff --git a/workflows/pull_request_automation.yml b/workflows/pull_request_automation.yml index 46ac709..c1a29b0 100644 --- a/workflows/pull_request_automation.yml +++ b/workflows/pull_request_automation.yml @@ -76,10 +76,19 @@ jobs: check_dockerfile: Dockerfile use_postgres: false + postgres_db: db + postgres_user: user + postgres_password: password + postgres_version: latest use_memcached: false + memcached_version: latest use_elastic_search: false + elasticsearch_version: 8.11.1 + elasticsearch_port: 9200 use_rabbitmq: true + rabbitmq_version: 3 use_mongo: false + mongo_version: latest use_celery: true celery_app: python_test.celery