refactor: make Agent.step()
multi-step
#1245
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
with: | |
ref: ${{ github.head_ref }} # Checkout the PR branch | |
fetch-depth: 0 # Fetch all history for all branches and tags | |
- 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: | | |
output=$(poetry run isort --profile black --check-only --diff . | grep -v "Skipped" || true) | |
echo "$output" | |
if [ -n "$output" ]; then | |
echo "isort_changed=true" >> $GITHUB_OUTPUT | |
else | |
echo "isort_changed=false" >> $GITHUB_OUTPUT | |
fi | |
continue-on-error: true | |
- name: Auto-fix with isort and commit | |
if: steps.isort.outputs.isort_changed == 'true' && !contains(github.event.pull_request.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" | |
if [[ -n $(git status -s) ]]; then | |
git add -A | |
git commit -m "Apply isort import ordering" | |
git push | |
else | |
echo "No changes to commit" | |
fi | |
- name: Error if 'check-only' label is present and changes are needed | |
if: steps.isort.outputs.isort_changed == 'true' && contains(github.event.pull_request.labels.*.name, 'check-only') | |
run: echo "Isort check failed. Please run 'isort .' locally to fix import orders." && exit 1 |