/cookiecutter-pydevops

Cookiecutter template for a dockerized dev-ops pipeline with SonarQube code quality monitoring

Primary LanguagePythonMIT LicenseMIT

Cookiecutter PyDevops

Cookiecutter template for a dockerized dev-ops pipeline with SonarQube code-quality monitoring. Cookiecutter provides a command-line interface for creating projects from templates.

Features

The template provides a minimal dev-ops pipeline that supports:

The dev-ops pipeline is mostly implemented in a Makefile and a Dockerfile which are independent of your Python code.

Quickstart

Install the latest cookiecutter:

pip install -U cookiecutter

Generate an instance of the template:

cookiecutter https://github.com/lrothack/cookiecutter-pydevops.git

Then switch to the project directory and:

  • Set up a virtual environment for your project and activate it (requires Python >= 3.6).
  • Run make help in order to get an overview of the targets provided by Makefile.
  • Run make install-dev in order to install the package (and all dependencies) in development mode.
  • Run make lint in order to run code analysis with pylint and bandit.
  • Run make test in order to run unit tests with pytest and coverage.
  • Run make dist in order to build a Python package (binary and source).
  • Run docker-compose -p sonarqube -f sonarqube/docker-compose.yml up -d in order to start a SonarQube server.
  • Run make sonar in order to run sonar-scanner and report results to your local SonarQube server. Make sure to create a SonarQube authentication token before. Save the token in the file .sonartoken within your project directory.
  • Run make docker-build in order to analyze, test, package and deploy in a multi-stage Docker build. Test your docker image with docker run.

Advanced configurations can be made in the configuration sections of Makefile. See lrothack/dev-ops for more information.