Skip to content

Commit

Permalink
🔧 Implement Ruff as check instead of Black creating a commit
Browse files Browse the repository at this point in the history
  • Loading branch information
georgepstaylor committed Sep 18, 2024
1 parent 9e954c8 commit c8e5190
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions .github/workflows/format-python.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
name: Format Python
name: Ensure formatted code
on:
pull_request:
types: [ opened, edited, reopened, synchronize, ready_for_review ]
workflow_dispatch:
jobs:
format:
format_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Format code with black
- name: Install ruff
run: pip install ruff
- name: Check formatting for Python code
run: |
pip install black
black --line-length 120 .
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: "Formatted code with black --line-length 120"
add: "."
trap 'format_output=$(ruff format --check); echo "$format_output"; echo "$format_output" | sed "s/^/::warning file=/" > format_output.txt; gh pr comment ${{ github.event.pull_request.number }} --body "$(cat format_output.txt)"' ERR
ruff format --check
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install ruff
run: pip install ruff
- name: Lint Python code
run: |
trap 'lint_output=$(ruff check); echo "$lint_output"; echo "$lint_output" | sed "s/^/::warning file=/" > lint_output.txt; gh pr comment ${{ github.event.pull_request.number }} --body "$(cat lint_output.txt)"' ERR
ruff check

0 comments on commit c8e5190

Please sign in to comment.