Repository navigation
58 lines (49 loc) · 1.72 KB
/
Copy pathpython-validation.yml
File metadata and controls
58 lines (49 loc) · 1.72 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
name: Python validation
on:
workflow_dispatch:
push:
paths:
- tools/**/*.py
- minecraft/config/versions.py
- .editorconfig
- .github/workflows/python-validation.yml
pull_request:
paths:
- tools/**/*.py
- minecraft/config/versions.py
- .editorconfig
- .github/workflows/python-validation.yml
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
python-lint:
name: Python syntax and lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install ruff
run: pip install --user ruff
- name: Collect Python files
id: python-files
run: |
mapfile -d '' -t python_files < <(find tools -maxdepth 1 -type f -name '*.py' -print0 | sort -z)
# versions.py is the only tracked Python helper outside tools/ that this repo validates.
[[ -f minecraft/config/versions.py ]] && python_files+=(minecraft/config/versions.py)
[[ ${#python_files[@]} -gt 0 ]]
printf '%s\n' "${python_files[@]}" > /tmp/mc-server-python-files.txt
- name: Run Python syntax checks
run: |
mapfile -t python_files < /tmp/mc-server-python-files.txt
python3 -m py_compile "${python_files[@]}"
- name: Run ruff
run: |
mapfile -t python_files < /tmp/mc-server-python-files.txt
~/.local/bin/ruff check "${python_files[@]}"
- name: Check formatting
run: |
mapfile -t python_files < /tmp/mc-server-python-files.txt
~/.local/bin/ruff format --diff "${python_files[@]}"