/pytest_template_application

Python application template with automated QA and Docker image publishing

Primary LanguagePythonMIT LicenseMIT

Python Application Template

build status

This is a minimal Python 3 application with automated tests using pytest, Coverage.py and GitHub Actions. It also provides pre-commit hooks (for Black, reorder_python_imports, Flake8 and Mypy) and automated Docker image storage via GitHub Packages. It was developed by the Imperial College Research Computing Service for the Essential Software Engineering for Researchers course.

To use this repository as a template for your own application:

  1. Click the green "Use this template" button above

  2. Name and create your repository

  3. Clone your new repository and make it your working directory

  4. Set up a virtual environment:

    # Either using venv:
    python3 -m venv .venv
    source .venv/bin/activate  # or `.venv\Scripts\activate.bat` if you're using Windows
    python -m pip install -U pip
    python -m pip install -U -r requirements-dev.txt
    
    # Or using conda:
    conda env create --name my_application --file requirements-dev.txt python=3
    conda activate my_application
  5. Install the git hooks:

    pre-commit install
  6. Run the tests:

    python -m pytest
  7. Edit/replace fibonacci.py, test_fibonacci.py, setup.cfg and ci.yml as required

Notes:

  • For a more comprehensive project template consistent with many Research Software Engineering best practices please consider using this Python Template from our colleagues at the Netherlands eScience Center.
  • GitHub Packages does not currently (08/2020) support unauthenticated pull access and is therefore not a drop-in replacement for Docker Hub.