Skip to content

Fixup

Fixup #12

name: Python code quality
on:
push:
branches: [main, legacy6, legacy7, legacy8]
paths:
- '**.py'
- '.github/workflows/python-code-quality.yml'
- 'pyproject.toml'
pull_request:
branches: [main, legacy6, legacy7, legacy8]
paths:
- '**.py'
- '.github/workflows/python-code-quality.yml'
- 'pyproject.toml'
concurrency:
group: codequality-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
analyze:
name: Lint ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04]
python-version: [3.9]
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Identify precise Python version
id: full-python-version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Cache Python env for ${{ matrix.os }}-py${{ steps.full-python-version.outputs.version }}
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ matrix.os }}-py${{ steps.full-python-version.outputs.version }}-${{ hashFiles('requirements.txt') }}
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade --upgrade-strategy eager pip setuptools wheel babel
pip install --upgrade --upgrade-strategy eager pylint pyproject-flake8 flake8-deprecated black mypy isort
if [ "${{ runner.os }}" == "Windows" ]; then
pip install --upgrade --upgrade-strategy eager wxPython
else
pip install --upgrade --upgrade-strategy eager -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/${{ matrix.os }} wxPython
fi
if [ -f requirements-gui.txt ]; then pip install --upgrade --upgrade-strategy eager -r requirements-gui.txt; fi
- name: List environment
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
JOB_CONTEXT: ${{ toJSON(job) }}
STEPS_CONTEXT: ${{ toJSON(steps) }}
RUNNER_CONTEXT: ${{ toJSON(runner) }}
STRATEGY_CONTEXT: ${{ toJSON(strategy) }}
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
run: |
pip list
env
- name: Create output directory
run: mkdir -p artifacts
- name: Analyse with pylint
id: pylint
continue-on-error: true
run: |
pylint -j 0 --output-format=text:artifacts/pylint.txt,colorized meerk40t
- name: Analyse with flake8
id: flake8
continue-on-error: true
run: |
pflake8 meerk40t --tee --output-file=artifacts/flake8.txt
- name: Analyse with black
id: black
continue-on-error: true
run: |
black --diff --color meerk40t
- name: Analyse with isort
id: isort
continue-on-error: true
run: |
isort meerk40t -c --diff
# MK Not strongly typed - mypy is not going to be run
# - name: Analyse with mypy
# id: mypy
# continue-on-error: true
# run: |
# mypy meerk40t
# exit 0
- name: Upload analysis results
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: artifacts/
- name: "Set status"
run: |
if ${{ steps.pylint.outcome != 'success' || steps.flake8.outcome != 'success' || steps.black.outcome != 'success' || steps.isort.outcome != 'success' }}; then
exit 0
exit 1
fi