Skip to content

Switch to ruff for lint and format #1640

Switch to ruff for lint and format

Switch to ruff for lint and format #1640

Workflow file for this run

name: Lint
on:
push:
branches:
- master
pull_request:
merge_group:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Get changed files
id: changed-files
run: |
if ${{ github.event_name == 'pull_request' }}; then
echo "changed_files=$(git diff -diff-filter=ACMR --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
else
echo "changed_files=$(git diff -diff-filter=ACMR --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
fi
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
- run: pip install --upgrade pre-commit
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Lint
run: pre-commit run --files ${{ steps.changed-files.outputs.changed_files }}