feat: add V1 route refactor from integration branch into separate PR (#1734)

This commit is contained in:
Charles Packer
2024-09-09 20:49:59 -07:00
committed by GitHub
parent cb20fbfab9
commit 635fb1cc66
41 changed files with 2053 additions and 1830 deletions

View File

@@ -1,38 +1,36 @@
name: Code Formatter (Black)
on:
pull_request:
paths:
- '**.py'
workflow_dispatch:
jobs:
black-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 Black
id: black
run: poetry run black --check .
continue-on-error: true
- name: Auto-fix with Black and commit
if: steps.black.outcome == 'failure' || ${{ !contains(github.event.issue.labels.*.name, 'check-only') }}
if: steps.black.outcome == 'failure' && !contains(github.event.pull_request.labels.*.name, 'check-only')
run: |
poetry run black .
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "Apply Black formatting" || echo "No changes to commit"
git diff --quiet && git diff --staged --quiet || (git add -A && git commit -m "Apply Black formatting")
git push
- name: Error if 'check-only' label is present
if: steps.black.outcome == 'failure' && contains(github.event.issue.labels.*.name, 'check-only')
if: steps.black.outcome == 'failure' && contains(github.event.pull_request.labels.*.name, 'check-only')
run: echo "Black formatting check failed. Please run 'black .' locally to fix formatting issues." && exit 1

View File

@@ -1,39 +1,48 @@
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: poetry run isort --profile black --check-only .
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.outcome == 'failure' || ${{ !contains(github.event.issue.labels.*.name, 'check-only') }}
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"
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')
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