1
+ name : Ruff
2
+
3
+ on : [push, pull_request]
4
+
5
+ permissions :
6
+ contents : write
7
+ pull-requests : write
8
+
9
+ jobs :
10
+ lint :
11
+ runs-on : ubuntu-latest
12
+ steps :
13
+ - uses : actions/checkout@v4
14
+ with :
15
+ fetch-depth : 0
16
+
17
+ - name : Set up Python
18
+ uses : actions/setup-python@v4
19
+ with :
20
+ python-version : " 3.x"
21
+
22
+ - name : Install Ruff
23
+ run : pip install ruff
24
+
25
+ - name : Run Ruff Format Check
26
+ id : ruff-format
27
+ continue-on-error : true
28
+ run : |
29
+ ruff format --check bbox_visualizer tests examples
30
+ echo "format_changes=$?" >> $GITHUB_OUTPUT
31
+
32
+ - name : Run Ruff Lint Check
33
+ id : ruff-lint
34
+ continue-on-error : true
35
+ run : |
36
+ ruff check bbox_visualizer tests examples
37
+ echo "lint_changes=$?" >> $GITHUB_OUTPUT
38
+
39
+ - name : Format and Fix with Ruff if needed
40
+ if : steps.ruff-format.outputs.format_changes == '1' || steps.ruff-lint.outputs.lint_changes == '1'
41
+ run : |
42
+ ruff format bbox_visualizer tests examples
43
+ ruff check --fix bbox_visualizer tests examples
44
+
45
+ - name : Create Pull Request
46
+ if : steps.ruff-format.outputs.format_changes == '1' || steps.ruff-lint.outputs.lint_changes == '1'
47
+ uses : peter-evans/create-pull-request@v5
48
+ with :
49
+ commit-message : " style: format and lint code with Ruff"
50
+ title : " style: format and lint code with Ruff"
51
+ body : |
52
+ Auto-formatted and linted code with Ruff.
53
+
54
+ This PR was automatically created by the Ruff GitHub Action.
55
+ - Formatted code with `ruff format`
56
+ - Fixed auto-fixable lint issues with `ruff check --fix`
57
+ branch : format-code-with-ruff
58
+ base : dev
59
+ delete-branch : true
60
+ token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments