Skip to content

Latest commit

 

History

History
98 lines (62 loc) · 3.66 KB

check-python-task.md

File metadata and controls

98 lines (62 loc) · 3.66 KB

"Check Python" workflow (Task)

Workflow file: check-python-task.yml

Run flake8 and black on the Python files of the repository.

This is the version of the workflow for projects using the Task task runner tool.

Installation

1. Add configuration files

Copy the configuration files listed in the Assets section below into the project's repository.

If the project already contains a pyproject.toml file, then merge them.

2. Install tool dependencies

The tool dependencies of this workflow are managed by Poetry.

Install Poetry by following these instructions:
https://python-poetry.org/docs/#installation

If your project does not already use Poetry, you can initialize the pyproject.toml file using these commands:

poetry init --python="^3.9" --dev-dependency="black@^21.5b0" --dev-dependency="flake8@^3.9.2" --dev-dependency="pep8-naming@^0.11.1"
poetry install

If already using Poetry, add the tool using this command:

poetry add --dev "black@^21.5b0" "flake8@^3.9.2" "pep8-naming@^0.11.1"

Make sure to commit the resulting pyproject.toml and poetry.lock files.

3. Configuration

Add the following to pyproject.toml:

[tool.black]
line-length = 120

Assets

  • .flake8 - flake8 configuration file.
    • Install to: repository root
  • [Taskfile.yml](assets/check-python-task/Taskfile.yml] - Python linting and formatting tasks.
    • Install to: repository root (or add the tasks into the existing Taskfile.yml)
  • [Taskfile.yml](assets/shared/Taskfile.yml] - Installation task.
    • Add the poetry:install-deps task into the existing Taskfile.yml

The code style defined in pyproject.toml and .flake8 is the official standardized style to be used in all Arduino tooling projects and should not be modified.

Readme badge

Markdown badge:

[![Check Python status](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/check-python-task.yml/badge.svg)](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/check-python-task.yml)

Replace the REPO_OWNER and REPO_NAME placeholders in the URLs with the final repository owner and name (example).


Asciidoc badge:

image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-python-task.yml/badge.svg["Check Python status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-python-task.yml"]

Define the {repository-owner} and {repository-name} attributes and use them throughout the readme (example).

Commit message

Add CI workflow to lint and check formatting of Python files

On every push and pull request that affects relevant files, and periodically, run flake8 to check the Python files of
the repository for issues and black to check formatting.

The .flake8 file is used to configure flake8:
https://flake8.pycqa.org/en/latest/user/configuration.html

PR message

On every push and pull request that affects relevant files, and periodically, run [`flake8`](https://flake8.pycqa.org/) to check the Python files of the repository for issues and [black](https://github.com/psf/black) to check formatting.

The `.flake8` file is used to configure `flake8`:
https://flake8.pycqa.org/en/latest/user/configuration.html