TrueBrain / actions-flake8

Flake8 with GitHub Actions -- including annotations for Pull Requests
MIT License
25 stars 9 forks source link
actions annotations flake8 github-actions linter python

Flake8 with GitHub Actions -- including annotations for Pull Requests

GitHub License GitHub Tag GitHub commits since latest release

This GitHub Actions runs flake8 over your code. Any warnings or errors will be annotated in the Pull Request.

Usage

steps:
- uses: actions/checkout@v4
- uses: TrueBrain/actions-flake8@v2

By default, it uses the default Python version as installed on the GitHub Runner.

Different Python version

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
  with:
    python-version: 3.9
- uses: TrueBrain/actions-flake8@v2
  with:
    path: src

Parameter: flake8_version

In some cases you might want to pin a certain flake8 version.

This parameter is optional; by default the latest flake8 will be installed (if no flake8 is installed yet).

steps:
- uses: actions/checkout@v4
- uses: TrueBrain/actions-flake8@v2
  with:
    flake8_version: 6.1.0

Alternatively, you can pre-install flake8 before executing this action:

steps:
- uses: actions/checkout@v4
- run: pip install flake8==3.8.0
- uses: TrueBrain/actions-flake8@v2

If needed, this also allows you to install other flake8-plugins.

Parameter: path

Indicates the path to run flake8 in. This can be useful if your project is more than Python code.

This parameter is optional; by default flake8 will run on your whole repository.

steps:
- uses: actions/checkout@v4
- uses: TrueBrain/actions-flake8@v2
  with:
    path: src

Parameter: ignore

Indicates errors and warnings to skip.

This parameter is optional; by default no alerts will be ignored

steps:
- uses: actions/checkout@v4
- uses: TrueBrain/actions-flake8@v2
  with:
    ignore: E4,W

Parameter: max_line_length

Indicates the maximum allowed line length.

This parameter is optional; by default flake8's default line length will be used.

steps:
- uses: actions/checkout@v4
- uses: TrueBrain/actions-flake8@v2
  with:
    max_line_length: 90

Parameter: only_warn

Only warn about problems. All errors and warnings are annotated in Pull Requests, but it will act like everything was fine anyway. (In other words, the exit code is always 0.)

This parameter is optional; setting this to any value will enable it.

steps:
- uses: actions/checkout@v4
- uses: TrueBrain/actions-flake8@v2
  with:
    only_warn: 1

Parameter: plugins

List of plugins to install before running, This is passed directly to pip install.

This parameter is optional; setting this to any value will enable it.

steps:
- uses: actions/checkout@v4
- uses: TrueBrain/actions-flake8@v2
  with:
    plugins: flake8-bugbear cohesion==0.9.1

Parameter: error_classes

List of flake8 error classes to classify as Error.

This parameter is optional; by default E and F classes will be considered errors.

steps:
- uses: actions/checkout@v4
- uses: TrueBrain/actions-flake8@v2
  with:
    error_classes: E,H

Parameter: warning_classes

List of flake8 error classes to classify as Warning.

This parameter is optional; by default all classes not contained in error_classes will be considered a warning.

steps:
- uses: actions/checkout@v4
- uses: TrueBrain/actions-flake8@v2
  with:
    warning_classes: W,B,D

Parameter: extra_arguments

Extra arguments to give to flake8. Useful when you need to give an argument this action otherwise doesn't supply (like --max-complexity, --hang-closing, ...).

This parameter is optional; by default it is empty.

steps:
- uses: actions/checkout@v4
- uses: TrueBrain/actions-flake8@v2
  with:
    extra_arguments: "--hang-closing"

Parameter: working_directory

Change the current working-directory to execute flake8 in.

This parameter is optional; by default it is set to ".".

steps:
- uses: actions/checkout@v4
- uses: TrueBrain/actions-flake8@v2
  with:
    working_directory: "src"