[CI/Build] update .pre-commit-config.yaml && add _pylint.yml && update installation.md (#155)
Signed-off-by: WeiJie_Hong <1462519292@qq.com>
This commit is contained in:
54
.github/workflows/_pylint.yml
vendored
Normal file
54
.github/workflows/_pylint.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
name: Code Style Check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
- name: Install tools
|
||||
run: |
|
||||
pip install black isort ruff
|
||||
|
||||
- name: Get changed python files
|
||||
id: changed
|
||||
shell: bash
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||
files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
|
||||
else
|
||||
files=$(git diff --name-only HEAD~1...HEAD)
|
||||
fi
|
||||
|
||||
files=$(echo "$files" | grep '\.py$' || true)
|
||||
|
||||
echo "files<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$files" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Run black
|
||||
if: steps.changed.outputs.files != ''
|
||||
run: |
|
||||
black --check ${{ steps.changed.outputs.files }}
|
||||
|
||||
- name: Run isort
|
||||
if: steps.changed.outputs.files != ''
|
||||
run: |
|
||||
isort --check-only ${{ steps.changed.outputs.files }}
|
||||
|
||||
- name: Run ruff
|
||||
if: steps.changed.outputs.files != ''
|
||||
run: |
|
||||
ruff check ${{ steps.changed.outputs.files }}
|
||||
Reference in New Issue
Block a user