Skip to content

Commit

Permalink
Add auto-formatting GitHub workflow
Browse files Browse the repository at this point in the history
This commit introduces a new auto-format GitHub workflow. This is designed to automatically format code for pull requests and pushes to the 'master' branch, using self-hosted runners with a 30-minute timeout. The code formatting tool used is ruff.
  • Loading branch information
meanmail committed Jan 25, 2024
1 parent 2fa577b commit 8168e69
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/auto-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Format code
on:
pull_request:
push:
branches:
- 'master'

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
format_backend:
name: Format with ruff
runs-on: [ self-hosted, small ]
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Install Poetry
run: pipx install poetry==$(head -n 1 .poetry-version)

- uses: actions/setup-python@v5
with:
python-version-file: '.python-version'
cache: 'poetry'

- name: Install dependencies
run: poetry install --only main,dev --no-interaction --no-ansi

- run: poetry run ruff --fix --unsafe-fixes --preview --exit-zero .
- run: poetry run ruff format .

- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
fetch: false
default_author: github_actions
message: 'Backend: Auto format'
add: '.'

0 comments on commit 8168e69

Please sign in to comment.