adding ruff auto check for pull requests as well as fixing all ruff errors (#1)
Co-authored-by: Kadir <git@k8n.dev>
This commit is contained in:
parent
b1e0a414cf
commit
4c23acdb55
5 changed files with 60 additions and 10 deletions
39
.github/workflows/ruff.yml
vendored
Normal file
39
.github/workflows/ruff.yml
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
name: Run Ruff and Auto-merge
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
ruff-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# Fetch all history for diffing
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11' # Or your desired Python version
|
||||
|
||||
- name: Install Ruff
|
||||
run: pip install ruff
|
||||
|
||||
- name: Get changed files
|
||||
id: changed_files
|
||||
run: |
|
||||
# Get a list of changed files between the base and head commits of the PR
|
||||
git diff --name-only --diff-filter=d ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > changed_files.txt
|
||||
# Filter for Python files
|
||||
grep -E '\.py$' changed_files.txt > python_files.txt
|
||||
# Remove newlines and join with spaces
|
||||
echo "files=$(tr '\n' ' ' < python_files.txt)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Run Ruff on changed files
|
||||
if: steps.changed_files.outputs.files != ''
|
||||
run: |
|
||||
# The ruff command will only run if there are Python files to check
|
||||
ruff check ${{ steps.changed_files.outputs.files }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue