[CI/Build] Fixed bug related to conflicts in the code inspection tool (#169)
Signed-off-by: WeiJie_Hong <1462519292@qq.com>
This commit is contained in:
20
.github/workflows/pylint-check.yml
vendored
20
.github/workflows/pylint-check.yml
vendored
@@ -4,7 +4,6 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pylint-check:
|
pylint-check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -27,9 +26,9 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||||
files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
|
files=$(git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref }}...HEAD)
|
||||||
else
|
else
|
||||||
files=$(git diff --name-only HEAD~1...HEAD)
|
files=$(git diff --name-only --diff-filter=ACMRT HEAD~1...HEAD)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
files=$(echo "$files" | grep '\.py$' || true)
|
files=$(echo "$files" | grep '\.py$' || true)
|
||||||
@@ -38,17 +37,18 @@ jobs:
|
|||||||
echo "$files" >> $GITHUB_OUTPUT
|
echo "$files" >> $GITHUB_OUTPUT
|
||||||
echo "EOF" >> $GITHUB_OUTPUT
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Run ruff
|
||||||
|
if: steps.changed.outputs.files != ''
|
||||||
|
run: |
|
||||||
|
echo "${{ steps.changed.outputs.files }}" | xargs ruff check --fix
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Run black
|
- name: Run black
|
||||||
if: steps.changed.outputs.files != ''
|
if: steps.changed.outputs.files != ''
|
||||||
run: |
|
run: |
|
||||||
black --check ${{ steps.changed.outputs.files }}
|
echo "${{ steps.changed.outputs.files }}" | xargs black --check
|
||||||
|
|
||||||
- name: Run isort
|
- name: Run isort
|
||||||
if: steps.changed.outputs.files != ''
|
if: steps.changed.outputs.files != ''
|
||||||
run: |
|
run: |
|
||||||
isort --check-only ${{ steps.changed.outputs.files }}
|
echo "${{ steps.changed.outputs.files }}" | xargs isort --check-only --profile black
|
||||||
|
|
||||||
- name: Run ruff
|
|
||||||
if: steps.changed.outputs.files != ''
|
|
||||||
run: |
|
|
||||||
ruff check ${{ steps.changed.outputs.files }}
|
|
||||||
@@ -21,6 +21,21 @@ repos:
|
|||||||
args: ["--maxkb=10240"] # Maximum allowed file size (10MB)
|
args: ["--maxkb=10240"] # Maximum allowed file size (10MB)
|
||||||
|
|
||||||
# -----------------------
|
# -----------------------
|
||||||
|
# Python Linting (Ruff)
|
||||||
|
# Characteristics: Fast, suitable for CI, replaces flake8/isort/etc.
|
||||||
|
# -----------------------
|
||||||
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
|
rev: v0.14.14 # Ruff version
|
||||||
|
hooks:
|
||||||
|
- id: ruff-check # Main linting checks
|
||||||
|
types_or: [ python, pyi ] # Check .py and .pyi files
|
||||||
|
args: [ --fix ] # Auto-fix fixable issues
|
||||||
|
# Checks include:
|
||||||
|
# - Unused imports/variables
|
||||||
|
# - Syntax errors
|
||||||
|
# - Code style issues
|
||||||
|
# - Potential bugs
|
||||||
|
# -----------------------
|
||||||
# Python import sorting (compatible with black)
|
# Python import sorting (compatible with black)
|
||||||
# -----------------------
|
# -----------------------
|
||||||
- repo: https://github.com/pycqa/isort
|
- repo: https://github.com/pycqa/isort
|
||||||
@@ -48,21 +63,6 @@ repos:
|
|||||||
# - Fast execution
|
# - Fast execution
|
||||||
# - Produces uniform code style
|
# - Produces uniform code style
|
||||||
|
|
||||||
# -----------------------
|
|
||||||
# Python Linting (Ruff)
|
|
||||||
# Characteristics: Fast, suitable for CI, replaces flake8/isort/etc.
|
|
||||||
# -----------------------
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
||||||
rev: v0.14.14 # Ruff version
|
|
||||||
hooks:
|
|
||||||
- id: ruff-check # Main linting checks
|
|
||||||
types_or: [ python, pyi ] # Check .py and .pyi files
|
|
||||||
args: [ --fix ] # Auto-fix fixable issues
|
|
||||||
# Checks include:
|
|
||||||
# - Unused imports/variables
|
|
||||||
# - Syntax errors
|
|
||||||
# - Code style issues
|
|
||||||
# - Potential bugs
|
|
||||||
- repo: https://github.com/jackdewinter/pymarkdown
|
- repo: https://github.com/jackdewinter/pymarkdown
|
||||||
rev: v0.9.29
|
rev: v0.9.29
|
||||||
hooks:
|
hooks:
|
||||||
|
|||||||
Reference in New Issue
Block a user