Files
letta-server/.github/workflows/isort_format.yml
2024-09-08 15:36:57 -07:00

40 lines
1.3 KiB
YAML

name: Code Formatter (isort)
on:
pull_request:
paths:
- '**.py'
workflow_dispatch:
jobs:
isort-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: "Setup Python, Poetry and Dependencies"
uses: packetcoders/action-setup-cache-python-poetry@main
with:
python-version: "3.12"
poetry-version: "1.8.2"
install-args: "-E dev" # TODO: change this to --group dev when PR #842 lands
- name: Run isort
id: isort
run: poetry run isort --profile black --check-only .
continue-on-error: true
- name: Auto-fix with isort and commit
if: steps.isort.outcome == 'failure' || ${{ !contains(github.event.issue.labels.*.name, 'check-only') }}
run: |
poetry run isort --profile black .
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "Apply isort import ordering" || echo "No changes to commit"
git push
- name: Error if 'check-only' label is present
if: steps.isort.outcome == 'failure' && contains(github.event.issue.labels.*.name, 'check-only')
run: echo "Isort check failed. Please run 'isort .' locally to fix import orders." && exit 1