Skip to content

ONSdigital/python-template-demo

Repository files navigation

python-template-demo

Build Status Build Status

Code style: black Linting: Ruff Checked with mypy poetry-managed License - MIT


Quick Setup: Enable MegaLinter CI

This repository includes a pre-configured MegaLinter workflow for automated code quality checks, but it needs to be manually enabled:

To activate MegaLinter:

  1. Rename .github/mega-linter.yml.example to .github/mega-linter.yml
  2. Move the file from .github to the .github/workflows folder
  3. Commit and push the change

Why this step is needed: GitHub Actions security restrictions prevent automatic creation of workflow files during template initialisation. Learn more about GitHub Token permissions and workflow limitations.

Once enabled, MegaLinter will automatically run on all Pull Requests and commits to main, checking:

  • Python code quality (Ruff, Black, Pylint, MyPy)
  • GitHub Actions workflows
  • Documentation formatting
  • Shell scripts, Dockerfiles, and more

python-template-demo

IMPORTANT: This README was generated from a template. Please update it with specific information about your project, including:

  • Detailed project description and purpose
  • Specific installation requirements
  • Usage examples and API documentation
  • Contributing guidelines specific to your project
  • Any project-specific compliance requirements

Compliance Checklist

Before you start developing, please ensure you've completed the following compliance requirements:

  • CODEOWNERS: Update .github/CODEOWNERS with the appropriate team/individuals responsible for this repository
  • README: Update this README with project-specific information (remove this notice when done)
  • Repository Settings: Ensure branch protection rules are enabled (should be automatic if using template setup)
  • Security: Review and configure security settings appropriate for your project
  • License: Verify the LICENSE file is appropriate for your project
  • Dependencies: Review and update dependencies as needed for your project

Table of Contents

Getting Started

To get a local copy up and running, follow these simple steps.

Pre-requisites

Ensure you have the following installed:

  1. Python: Version specified in .python-version. We recommend using pyenv for managing Python versions.
  2. Poetry: This is used to manage package dependencies and virtual environments.
  3. Docker
  4. Operation System: Ubuntu/MacOS

Installation

  1. Clone the repository and install the required dependencies.

    git clone https://github.com/ONSdigital/python-template-demo.git
  2. Install dependencies

    Poetry is used to manage dependencies in this project. For more information, read the Poetry documentation.

    To install all dependencies, including development dependencies, run:

    make install-dev

    To install only production dependencies, run:

    make install
  3. Run the application

    make run

Development

Get started with development by running the following commands. Before proceeding, make sure you have the development dependencies installed using the make install-dev command.

A Makefile is provided to simplify common development tasks. To view all available commands, run:

make

Run Tests with Coverage

The unit tests are written using the pytest framework. To run the tests and check coverage, run:

make test

Linting and Formatting

Various tools are used to lint and format the code in this project.

Python

The project uses Ruff, pylint and black for linting and formatting of the Python code.

The tools are configured using the pyproject.toml file.

To lint the Python code, run:

make lint

To auto-format the Python code, and correct fixable linting issues, run:

make format

MegaLinter (Lint/Format non-python files)

MegaLinter is utilised to lint the non-python files in the project. It offers a single interface to execute a suite of linters for multiple languages and formats, ensuring adherence to best practices and maintaining consistency across the repository without the need to install each linter individually.

MegaLinter examines various file types and tools, including GitHub Actions, Shell scripts, Dockerfile, etc. It is configured using the .mega-linter.yml file.

To run MegaLinter, ensure you have Docker installed on your system.

Note: The initial run may take some time to download the Docker image. However, subsequent executions will be considerably faster due to Docker caching. 🚀

To start the linter and automatically rectify fixable issues, run:

make megalint

Contributing

See CONTRIBUTING.md for details.

License

See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •