-
Notifications
You must be signed in to change notification settings - Fork 1
59 lines (49 loc) · 1.75 KB
/
python-lint.yml
File metadata and controls
59 lines (49 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Python Code Quality
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
python-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get changed Python files
id: changed-files
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46
with:
files: |
**/*.py
- name: Set up Python
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
if: steps.changed-files.outputs.any_changed == 'true'
uses: astral-sh/setup-uv@v3
- name: Install ruff
if: steps.changed-files.outputs.any_changed == 'true'
run: uv tool install ruff
- name: Run ruff check on changed files
if: steps.changed-files.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
echo "Checking changed Python files:"
echo "${ALL_CHANGED_FILES}" | tr ' ' '\n'
uv tool run ruff check --output-format=github ${ALL_CHANGED_FILES}
- name: Run ruff format check on changed files
if: steps.changed-files.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
echo "Checking format of changed Python files:"
uv tool run ruff format --check ${ALL_CHANGED_FILES}
- name: Skip message
if: steps.changed-files.outputs.any_changed == 'false'
run: echo "No Python files changed - skipping Python linting"