Requirements:
- Python 3.10+
- Poetry (
curl -sSL https://install.python-poetry.org | python3 -
) - Make
poetry install
poetry shell
make init
Static analysis utilizes following external tools
black
isort
flake8
bandit
safety
mypy
In order to run all of them together simply run make static
.
Unit tests utilize following external tools
assertpy
pytest
pytest-cov
responses
In order to execute the unit tests run make test
or to create a code coverage report run make test_report
.
cp .env.example .env
vim .env # Change all required values
docker build -t py-generic-boilerplate .
docker run --rm --env-file .env py-generic-boilerplate
Push workflow is located at .github/workflows/push.yaml and does the following:
- Installs Python
- Install dependencies
- Runs pre-commit
- Runs unit tests
- Builds the
Dockerfile
- Pushes the image to the GCR registry with
latest
tag - Pushes the image to the GCR registry with
<COMMIT_SHA>
tag
The workflow requires 2 secrets to be present:
GCLOUD_PROJECT_ID
- GCP project IDGCLOUD_SERVICE_KEY
- Base64 encoded service account JSON (python3 -m base64 -e < sa.json
)
In order to successfully run the workflow, provided SA must have write access to GCR.
PR workflow is located at .github/workflows/pr.yaml and does the following:
- Installs Python
- Install dependencies
- Runs pre-commit
- Runs unit tests