Files
xc-llm-kunlun/.github/workflows/pylint-check.yml
tanjunchen 1e1e870a71 update ci workflow (#159)
Signed-off-by: tanjunchen <tanjunchen20@gmail.com>
2026-01-28 20:28:38 +08:00

55 lines
1.3 KiB
YAML

name: Code Style Check
on:
pull_request:
push:
branches: [ main ]
jobs:
pylint-check:
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 }}