GitHub - ttw225-template/python-script: An easy to use template of Python script, include basic CI/CD setting

An easy to use template of Python script, include basic CI/CD settings.

Code style: black Imports: isort Code style: flake8 linting: pylint Checked with mypy security: bandit Ochrona

Development

Prerequisite

Package Name Version
Python 3.10.8
pipenv 2022.9.24

Environment setup

  • Install dependencies

Formatting

Code formatter

This template uses the following automatic format tool:

Linting

This template uses the following linting tool:

Analysis

This template uses the following security analysis tool:

Test

This template uses the following testing tool:

Deploy

Prerequisite

Package Name Version
Docker 20.10.21
docker-compose v2.12.2

Build image

Run container

Github workflows

CI

ci.yml

Trigger on: push and pull-request

Jobs:

  1. Lint
    • Run linting tools: flake8, pylint, mypy
  2. Analysis
    • Run security analysis tools: bandit, ochrona
  3. tests
    • Run pytest
    • Upload testing coverage report to Codecov

Build

build.yml

Trigger on: push and Bump version complete

Jobs:

  1. build-and-push-image
    • Build a test image and check the container can start without errors
    • Build and push image with test tag
    • If branch develop: build and push image with dev tag
    • If branch main: build and push image with latest and latest git tag

Bump and release version

bumpversion.yml

Trigger on: push to main branch

Tools: python commitizen tool

Jobs:

  1. bump-version
    • Create bump and changelog
    • Release latest version