Skip to content

Commit da2f1b8

Browse files
yuriverweijCopilot
andcommitted
Update linting and formatting setup to use latest actions and enhance commands
Co-authored-by: Copilot <copilot@github.com>
1 parent 0261814 commit da2f1b8

4 files changed

Lines changed: 56 additions & 13 deletions

File tree

.github/workflows/LintFormatCheck.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v4
10+
- uses: actions/checkout@v6
1111

1212
- name: Set up Python
13-
uses: actions/setup-python@v5
13+
uses: actions/setup-python@v6
1414
with:
1515
python-version: "3.13"
1616

@@ -20,9 +20,22 @@ jobs:
2020
pip install -r requirements-dev.txt
2121
2222
- name: Ruff format check
23+
id: format
24+
continue-on-error: true
2325
run: |
24-
python -m ruff format --check --diff src/ utest/ atest/
26+
python -m invoke format --check
2527
2628
- name: Ruff lint
29+
id: lint
30+
continue-on-error: true
2731
run: |
28-
python -m invoke lint
32+
python -m invoke lint
33+
34+
- name: Fail if any Ruff step failed
35+
if: always()
36+
run: |
37+
echo "format outcome: ${{ steps.format.outcome }}"
38+
echo "lint outcome: ${{ steps.lint.outcome }}"
39+
if [ "${{ steps.format.outcome }}" != "success" ] || [ "${{ steps.lint.outcome }}" != "success" ]; then
40+
exit 1
41+
fi

CONTRIBUTING.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,23 @@ needed in internal code. When docstrings are added, they should follow
118118
`PEP-257`_. See `Documentation`_ section below for more details about
119119
documentation syntax, generating docs, etc.
120120

121-
The code should be formatted and linted with `Ruff`_. Ruff can be run by
122-
using command::
121+
The code should be formatted and linted with `Ruff`_. See Development commands below for more details.
123122

124-
inv lint
123+
Development commands
124+
~~~~~~~~~~~~~~~~~~~~
125+
126+
Use `invoke`_ tasks for common local checks and test runs::
127+
128+
inv format --check # Check formatting with Ruff
129+
inv format # Format source files with Ruff
130+
inv lint # Run Ruff lint checks
131+
inv lint --fix # Apply safe Ruff lint fixes
132+
inv utest # Run unit tests
133+
inv atest # Run acceptance tests (headlesschrome)
134+
135+
Run these before opening a pull request so local results are close to CI.
136+
Use the project virtual environment and pinned dependencies from
137+
``requirements-dev.txt`` for consistent results across local runs and CI.
125138

126139
Documentation
127140
-------------
@@ -149,7 +162,7 @@ individual keywords.
149162

150163
Keyword documentation can be easily created using `invoke`_ task::
151164

152-
inv keyword_documentation
165+
inv kw-docs
153166

154167
Resulting docs should be verified before the code is committed.
155168

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pytest-mockito == 0.0.4
1515
pytest-approvaltests == 0.2.4
1616
requests == 2.33.1
1717
robotframework-pabot == 5.2.2
18-
ruff == 0.4.10
18+
ruff == 0.15.12
1919

2020
# Requirements needed when generating releases. See BUILD.rst for details.
2121
rellu == 0.7

tasks.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,28 @@ def init_labels(ctx, username=None, password=None):
187187

188188
@task
189189
def lint(ctx, fix=False):
190-
"""Runs Ruff format check and linter for project Python code."""
191-
ruff_cmd = f"{sys.executable} -m ruff check --config pyproject.toml src/ utest/" # atest/"
190+
"""Run Ruff lint checkse.
191+
192+
Args:
193+
fix: Apply safe fixes when True. Defaults to False.
194+
"""
195+
cmd = f"{sys.executable} -m ruff check --config pyproject.toml src/ utest/" # atest/"
192196
if fix:
193-
ruff_cmd = f"{ruff_cmd} --fix"
194-
ctx.run(ruff_cmd)
197+
cmd = f"{cmd} --fix"
198+
ctx.run(cmd)
199+
200+
@task
201+
def format(ctx, check=False):
202+
"""Run Ruff formatter.
203+
204+
Args:
205+
check: When True, only check formatting and show diff.
206+
When False, apply formatting changes.
207+
"""
208+
cmd = f"{sys.executable} -m ruff format --config pyproject.toml src/ utest/ atest/"
209+
if check:
210+
cmd = f"{cmd} --check --diff"
211+
ctx.run(cmd)
195212

196213
@task
197214
def gen_stub(ctx):

0 commit comments

Comments
 (0)