mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 19:16:57 +08:00
171 lines
6.6 KiB
YAML
171 lines
6.6 KiB
YAML
# ==================================================================================================================== #
|
|
# Authors: #
|
|
# Patrick Lehmann #
|
|
# #
|
|
# ==================================================================================================================== #
|
|
# Copyright 2025-2025 The pyTooling Authors #
|
|
# #
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); #
|
|
# you may not use this file except in compliance with the License. #
|
|
# You may obtain a copy of the License at #
|
|
# #
|
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
|
# #
|
|
# Unless required by applicable law or agreed to in writing, software #
|
|
# distributed under the License is distributed on an "AS IS" BASIS, #
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
|
# See the License for the specific language governing permissions and #
|
|
# limitations under the License. #
|
|
# #
|
|
# SPDX-License-Identifier: Apache-2.0 #
|
|
# ==================================================================================================================== #
|
|
name: Code Quality Checking
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
ubuntu_image_version:
|
|
description: 'Ubuntu image version.'
|
|
required: false
|
|
default: '24.04'
|
|
type: string
|
|
python_version:
|
|
description: 'Python version.'
|
|
required: false
|
|
default: '3.13'
|
|
type: string
|
|
package_directory:
|
|
description: 'The package''s directory'
|
|
required: true
|
|
type: string
|
|
requirements:
|
|
description: 'Python dependencies to be installed through pip.'
|
|
required: false
|
|
default: '-r requirements.txt'
|
|
type: string
|
|
bandit:
|
|
description: 'Run bandit checks.'
|
|
required: false
|
|
default: 'true'
|
|
type: string
|
|
radon:
|
|
description: 'Run radon checks.'
|
|
required: false
|
|
default: 'true'
|
|
type: string
|
|
pylint:
|
|
description: 'Run pylint checks.'
|
|
required: false
|
|
default: 'true'
|
|
type: string
|
|
artifact:
|
|
description: 'Name of the package artifact.'
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
Bandit:
|
|
name: 🚨 Security Scanning (Bandit)
|
|
runs-on: "ubuntu-${{ inputs.ubuntu_image_version }}"
|
|
if: inputs.bandit == 'true'
|
|
|
|
steps:
|
|
- name: ⏬ Checkout repository
|
|
uses: actions/checkout@v5
|
|
with:
|
|
lfs: true
|
|
submodules: true
|
|
|
|
- name: 🐍 Setup Python ${{ inputs.python_version }}
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: ${{ inputs.python_version }}
|
|
|
|
- name: ⚙ Install dependencies for running bandit
|
|
run: python -m pip install --disable-pip-version-check bandit
|
|
|
|
- name: 👮 Bandit
|
|
if: inputs.artifact != ''
|
|
run: |
|
|
mkdir -p report/bandit
|
|
bandit -c pyproject.toml -r ${{ inputs.package_directory }} -f xml -o report/bandit/report.xml
|
|
|
|
- name: Debug
|
|
run: |
|
|
cat report/bandit/report.xml
|
|
|
|
- name: 📊 Publish Bandit Results
|
|
uses: dorny/test-reporter@v2
|
|
continue-on-error: true
|
|
with:
|
|
name: 'Bandit Results'
|
|
path: 'report/bandit/report.xml'
|
|
reporter: java-junit
|
|
|
|
Radon:
|
|
name: ☢️ Metrics and Complexity
|
|
runs-on: "ubuntu-${{ inputs.ubuntu_image_version }}"
|
|
if: inputs.radon == 'true'
|
|
|
|
steps:
|
|
- name: ⏬ Checkout repository
|
|
uses: actions/checkout@v5
|
|
with:
|
|
lfs: true
|
|
submodules: true
|
|
|
|
- name: 🐍 Setup Python ${{ inputs.python_version }}
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: ${{ inputs.python_version }}
|
|
|
|
- name: ⚙ Install dependencies for running radon
|
|
run: python -m pip install --disable-pip-version-check radon
|
|
|
|
- name: Code Metrics
|
|
# if: inputs.artifact != ''
|
|
run: |
|
|
radon raw ${{ inputs.package_directory }} -s
|
|
|
|
- name: Code Complexity
|
|
# if: inputs.artifact != ''
|
|
run: |
|
|
radon cc ${{ inputs.package_directory }} --total-average
|
|
|
|
- name: Halstead Complexity Metrics
|
|
# if: inputs.artifact != ''
|
|
run: |
|
|
radon hal ${{ inputs.package_directory }}
|
|
|
|
- name: Maintainability Index
|
|
# if: inputs.artifact != ''
|
|
run: |
|
|
radon mi ${{ inputs.package_directory }} -s
|
|
|
|
PyLint:
|
|
name: 🩺 Linting
|
|
runs-on: "ubuntu-${{ inputs.ubuntu_image_version }}"
|
|
if: inputs.pylint == 'true'
|
|
|
|
steps:
|
|
- name: ⏬ Checkout repository
|
|
uses: actions/checkout@v5
|
|
with:
|
|
lfs: true
|
|
submodules: true
|
|
|
|
- name: 🐍 Setup Python ${{ inputs.python_version }}
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: ${{ inputs.python_version }}
|
|
|
|
- name: ⚙ Install dependencies for running PyLint
|
|
run: |
|
|
python -m pip install --disable-pip-version-check pylint
|
|
python -m pip install --disable-pip-version-check ${{ inputs.requirements }}
|
|
|
|
- name: 🩺 PyLint
|
|
# if: inputs.artifact != ''
|
|
run: |
|
|
pylint ${{ inputs.package_directory }}
|