-
-
Notifications
You must be signed in to change notification settings - Fork 4
145 lines (141 loc) · 6.05 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: itinerant_ruff_fixes
on:
workflow_dispatch:
inputs:
repo:
description: 'Repo to test (user_name/repo_name)'
required: true
jobs:
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 auto-walrus codespell[toml] ruff
- run: echo "Testing ${{ github.event.inputs.repo }}..."
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- 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 }}
# ref: dev # branch, tag, or SHA
- run: ls -Fla
- run: codespell --count --ignore-words-list=assertin,astroid,crate || true
- run: auto-walrus . || ruff check --select=SIM108,UP034 --fix --unsafe-fixes || git diff || true
# ruff check --exit-zero runs first...
# exit-zero on select=ALL
- run: ruff check --exit-zero --select=W605 --target-version=py39
- run: ruff check --exit-zero --select=ALL --target-version=py39
- run: ruff check --exit-zero --select=ALL --statistics --target-version=py39 | sort -k 2
# exit-zero on select=ALL that are fixable
- run: ruff check --exit-zero --select=ALL --statistics --target-version=py39 | grep "\[\*\]" | sort -k 2 || true
# exit-zero default issues
- run: ruff check --exit-zero --statistics --target-version=py39 | 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/*" --output-format=concise --quiet --select=ALL --target-version=py39 | /tmp/ruff_config_gen.py
- run: ruff check --exit-zero --output-format=concise --quiet --select=ALL --target-version=py39 | /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=py39
# Just the showstopper issues
- run: ruff check --output-format=github --select=E9,F63,F7,F82 --target-version=py39
# The default issues
- run: ruff check --output-format=github --target-version=py39
- run: |
ruff check --select=ALL --statistics --target-version=py39 | 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=py39 --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=py39 | grep "\[\*\]" || true
- run: |
ruff check --select=SIM --fix . | true
git diff
dump_contexts_to_log:
runs-on: ubuntu-24.04
steps:
- run: env # Should not include environment_variables $A, $B, and $C
- shell: python
run: |
new_environment_variables = """\
A=Algol
B=Basic
C=C++
"""
import os
with open(os.getenv("GITHUB_ENV"), "a") as github_env:
github_env.write(new_environment_variables)
- run: env # Should include environment_variables $A, $B, and $C
- 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"
home_dir:
runs-on: macos-14 # ubuntu-latest
steps:
- run: echo $HOME # '/home/runner'
- run: echo $USER
- run: echo $GROUP
- 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