Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Split formatter and linter jobs

Roland Geider86ae9597a4bb
diff --git a/.github/workflows/formatter.yml b/.github/workflows/formatter.yml
index b76934563..d464e273c 100644
--- a/.github/workflows/formatter.yml
+++ b/.github/workflows/formatter.yml
@@ -6,6 +6,7 @@ on:
- "master"
paths:
- '**.py'
+ - 'pyproject.toml'
permissions:
@@ -19,14 +20,23 @@ jobs:
- name: Checkout code
uses: actions/checkout@v7
+ - name: Install uv
+ uses: astral-sh/setup-uv@v7
+ with:
+ enable-cache: true
+
- name: Get dependencies
- run: pip install ruff
+ run: uv sync --only-group dev
- - name: Sort the imports
- run: ruff check --fix
+ # --exit-zero applies whatever can be fixed and does not abort on the
+ # rest, otherwise a single unfixable violation (a long line, say) would
+ # discard the fixes that were already written to disk. Pull requests are
+ # gated by the ruff workflow, this job only keeps master tidy.
+ - name: Lint the code
+ run: uv run ruff check --fix --exit-zero
- name: Format the code
- run: ruff format
+ run: uv run ruff format
- name: Push a commit with the changed files
@@ -34,7 +44,7 @@ jobs:
continue-on-error: true
run: |
- git config user.name git config user.name "github-actions[bot]"
+ git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Automatic linting"
diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml
new file mode 100644
index 000000000..7ea36ee12
--- /dev/null
+++ b/.github/workflows/ruff.yml
@@ -0,0 +1,35 @@
+name: Ruff
+
+on:
+ pull_request:
+ branches: [ master, ]
+ paths:
+ - '**.py'
+ - 'pyproject.toml'
+ - '.github/workflows/ruff.yml'
+
+jobs:
+ ruff-job:
+ name: Lint and format check
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+
+ steps:
+ - uses: actions/checkout@v7
+
+ - name: Install uv
+ uses: astral-sh/setup-uv@v7
+ with:
+ enable-cache: true
+
+ # local development environment.
+ - name: Install dependencies
+ run: uv sync --only-group dev
+
+ # --output-format=github reports the violations as annotations in the diff
+ - name: Lint the code
+ run: uv run ruff check --output-format=github
+
+ - name: Check the formatting
+ run: uv run ruff format --check