Giter Club home page Giter Club logo

py-generic-boilerplate's Introduction

Python Generic Boilerplate

Initialize local environment

Requirements:

  • Python 3.10+
  • Poetry (curl -sSL https://install.python-poetry.org | python3 -)
  • Make

Setup

poetry install
poetry shell
make init

Static analysis

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

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.

Running in Docker

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

GitHub Actions

Docker image build & push Workflow (on push event)

Push workflow is located at .github/workflows/push.yaml and does the following:

  1. Installs Python
  2. Install dependencies
  3. Runs pre-commit
  4. Runs unit tests
  5. Builds the Dockerfile
  6. Pushes the image to the GCR registry with latest tag
  7. Pushes the image to the GCR registry with <COMMIT_SHA> tag

The workflow requires 2 secrets to be present:

  1. GCLOUD_PROJECT_ID - GCP project ID
  2. GCLOUD_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.

Test (on PR event)

PR workflow is located at .github/workflows/pr.yaml and does the following:

  1. Installs Python
  2. Install dependencies
  3. Runs pre-commit
  4. Runs unit tests

py-generic-boilerplate's People

Contributors

aleksandar-babic avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.