Skip to content

Commit

Permalink
Merge pull request #211 from certego/develop
Browse files Browse the repository at this point in the history
1.5.0
  • Loading branch information
eugenioseveri authored Aug 27, 2024
2 parents 32c1fe3 + 7eb2422 commit aa1fe1a
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 59 deletions.
34 changes: 14 additions & 20 deletions .github/actions/services/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
23 changes: 23 additions & 0 deletions .github/configurations/python_linters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
16 changes: 9 additions & 7 deletions .github/configurations/python_linters/requirements-linters.txt
Original file line number Diff line number Diff line change
@@ -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
pylint==3.2.6
9 changes: 9 additions & 0 deletions .github/workflows/pull_request_automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
34 changes: 14 additions & 20 deletions actions/services/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
23 changes: 23 additions & 0 deletions configurations/python_linters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
16 changes: 9 additions & 7 deletions configurations/python_linters/requirements-linters.txt
Original file line number Diff line number Diff line change
@@ -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
pylint==3.2.6
9 changes: 9 additions & 0 deletions workflows/pull_request_automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aa1fe1a

Please sign in to comment.