A tool to check your Python projects for code smells in CI/CD pipelines using pycodestyle.
This tool has been written and tested using GitHub Actions but it should work out of the box with a lot of other CI/CD tools.
on: [push, pull_request]
jobs:
build:
name: Pycodestyle
runs-on: ubuntu-latest
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Run Pycodestyle
run: bash <(curl -s https://raw.githubusercontent.com/CICDToolbox/pycodestyle/master/pipeline.sh)
The following environment variables can be set in order to customise the script.
Name | Purpose | Default Value |
---|---|---|
EXCLUDE_FILES | A comma separated list of files to exclude from being scanned. You can also use regex to do pattern matching. |
Unset |
REPORT_ONLY | Generate the report but do not fail the build even if an error occurred. | False |
SHOW_ERRORS | Show the actual errors instead of just which files had errors. | True |
SHOW_SKIPPED | Show which files are being skipped. | False |
You can use any combination of the above settings.
on: [push, pull_request]
jobs:
build:
name: Pycodestyle
runs-on: ubuntu-latest
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Run Pycodestyle
env:
REPORT_ONLY: true
SHOW_ERRORS: true
run: bash <(curl -s https://raw.githubusercontent.com/CICDToolbox/pycodestyle/master/pipeline.sh)
This is an example of the output report generated by this tool, this is the actual output from the tool running against itself.
-------------------------------------------------------------------------- Stage 1 - Parameters --
No parameters given
--------------------------------------------------------------- Stage 2 - Install Prerequisites --
[ OK ] pip install --quiet pycodestyle
------------------------------------------------------------ Stage 3 - Run pycodestyle (v2.8.0) --
[ OK ] tests/test.py
------------------------------------------------------------------------------ Stage 4 - Report --
Total: 1, OK: 1, Failed: 0, Skipped: 0
---------------------------------------------------------------------------- Stage 5 - Complete --
Target files are identified using the following code:
file -b "${filename}" | grep -qE '^Python script'
AND
[[ ${filename} =~ \.py$ ]]