-
-
Notifications
You must be signed in to change notification settings - Fork 3
127 lines (122 loc) · 5.22 KB
/
itinerant_ruff_fixes.yml
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: itinerant_ruff_fixes
on:
workflow_dispatch:
inputs:
repo:
description: 'Repo to test (user_name/repo_name)'
required: true
jobs:
home_dir:
runs-on: macos-14 # ubuntu-latest
steps:
- run: echo $HOME # '/home/runner'
- uses: actions/checkout@v4
- run: echo $HOME # '/home/runner'
- run: python3 scripts/home_dir.py # '/home/runner'
- run: sudo python3 scripts/home_dir.py # '/root'
- run: npm version
- run: npm config list
- run: npm config list -l
- run: npm doctor || true
- run: echo ${{ runner.name }}, ${{ runner.os }}, ${{ runner.arch }}, ${{ runner.debug }}, ${{ runner.temp }}, ${{ runner.tool_cache }}
# - run: echo ${{ toJson(runner) }}
# - run: echo ${{ runner }} # Object
# - run: echo toJSON( $runner ) || true
# - run: echo toJSON( ${{ runner }} ) || true
# - run: echo toJSON(runner) || true
dump_contexts_to_log:
runs-on: ubuntu-24.04
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: echo "$MATRIX_CONTEXT"
itinerant_ruff_fixes:
name: "${{ github.event.inputs.repo }}"
strategy:
fail-fast: false
matrix:
python-version: [3.x]
runs-on: ubuntu-latest
steps:
- run: pip install --user codespell[toml] ruff
- run: echo "Testing ${{ github.event.inputs.repo }}..."
- uses: actions/checkout@v4
- run: python3 scripts/ruff_generate_baseline.py
- run: |
pushd scripts
cp ruff_generate_baseline.py /tmp/
cp ruff_config_gen.py /tmp/
popd
- uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.repo }}
- run: ls -Fla
- run: codespell || true
# ruff check --exit-zero runs first...
# exit-zero on select=ALL
- run: ruff check --exit-zero --select=W605 --target-version=py38
- run: ruff check --exit-zero --select=ALL --target-version=py38
- run: ruff check --exit-zero --select=ALL --statistics --target-version=py38 | sort -k 2
# exit-zero on select=ALL that are fixable
- run: ruff check --exit-zero --select=ALL --statistics --target-version=py38 | grep "\[\*\]" | sort -k 2 || true
# exit-zero default issues
- run: ruff check --exit-zero --statistics --target-version=py38 | sort -k 2
# - run: cp /tmp/ruff_generate_baseline.py
# - run: python3 ruff_generate_baseline.py
# - run: python3 /tmp/ruff_generate_baseline.py
- run: ruff check --exit-zero --exclude="*/migrations/*,test/*,tests/*" --quiet --select=ALL --target-version=py38 | /tmp/ruff_config_gen.py
- run: ruff check --exit-zero --quiet --select=ALL --target-version=py38 | /tmp/ruff_config_gen.py
# - run: ruff check --exit-zero --select=E501 | tee long_lines.txt
# Just the showstopper issues without undefined names
- run: ruff check --output-format=github --select=E9,F63,F7 --target-version=py38
# Just the showstopper issues
- run: ruff check --output-format=github --select=E9,F63,F7,F82 --target-version=py38
# The default issues
- run: ruff check --output-format=github --target-version=py38
- run: |
ruff check --select=ALL --statistics --target-version=py38 | tee ruff.out.txt || true
echo "-------"
grep "\[\*\]" ruff.out.txt
ruff check --select=E501 > ruff_long_lines.txt || true
- name: ruff check --line-length=88 check --select=ALL --target-version=py38 --ignore=???
shell: python
run: |
with open("ruff.out.txt") as in_file:
errors = set(line.split()[1] for line in in_file if not line.startswith("warning"))
line_length = 88
if "E501" in errors: # Find the longest long line.
errors.remove("E501")
with open("ruff_long_lines.txt") as in_file:
longest = max(*(
int(line.split("(")[-1].split()[0])
for line in in_file if not line.startswith("Found ")
))
line_length = max(line_length, longest)
ignore = f" --ignore {','.join(sorted(errors))}" if errors else ""
print(f"ruff check --line-length={line_length} --select=ALL{ignore} --target-version=py38 .")
- run: ruff check --ignore=ANN,C4,COM,D,ERA,F841,I,PIE790,PT,Q,RSE102,RUF001,RUF003,RUF100,TID252,UP
--select=ALL --statistics --target-version=py38 | grep "\[\*\]" || true
- run: |
ruff check --select=SIM --fix . | true
git diff