mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 02:48:13 -05:00
* chore: add ruff linter with base config * ci: add ruff pre-commit hook * ci: add ruff github actions workflow * ci: run ruff only on changed files
50 lines
1.2 KiB
YAML
50 lines
1.2 KiB
YAML
name: Ruff
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dev
|
|
paths:
|
|
- 'backend/**'
|
|
- 'pyproject.toml'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- dev
|
|
paths:
|
|
- 'backend/**'
|
|
- 'pyproject.toml'
|
|
|
|
jobs:
|
|
ruff:
|
|
name: 'Lint & Format Backend'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get changed Python files
|
|
id: changed
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
|
BASE=${{ github.event.pull_request.base.sha }}
|
|
else
|
|
BASE=${{ github.event.before }}
|
|
fi
|
|
FILES=$(git diff --name-only --diff-filter=ACMR "$BASE" HEAD -- 'backend/**.py' | xargs)
|
|
echo "files=$FILES" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Ruff check
|
|
if: steps.changed.outputs.files != ''
|
|
uses: astral-sh/ruff-action@v3
|
|
with:
|
|
args: check ${{ steps.changed.outputs.files }}
|
|
|
|
- name: Ruff format
|
|
if: steps.changed.outputs.files != ''
|
|
uses: astral-sh/ruff-action@v3
|
|
with:
|
|
args: format --check ${{ steps.changed.outputs.files }}
|