Skip to content

itinerant_ruff_fixes #355

itinerant_ruff_fixes

itinerant_ruff_fixes #355

name: itinerant_ruff_fixes
on:
workflow_dispatch:
inputs:
repo:
description: 'Repo to test (user_name/repo_name)'
required: true
jobs:
home_dir:
runs-on: 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
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 --exit-zero runs first...
# exit-zero on select=ALL
- run: ruff --exit-zero --select=ALL --statistics --target-version=py38 . | sort -k 2
# exit-zero on select=ALL that are fixable
- run: ruff --exit-zero --select=ALL --statistics --target-version=py38 . | grep "\[\*\]" | sort -k 2 || true
# exit-zero default issues
- run: ruff --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 --exit-zero --exclude="*/migrations/*,test/*,tests/*" --quiet --select=ALL --target-version=py38 . | /tmp/ruff_config_gen.py
- run: ruff --exit-zero --quiet --select=ALL --target-version=py38 . | /tmp/ruff_config_gen.py
# - run: ruff --exit-zero --select=E501 . | tee long_lines.txt
# Just the showstopper issues without undefined names
- run: ruff --output-format=github --select=E9,F63,F7 --target-version=py38 .
# Just the showstopper issues
- run: ruff --output-format=github --select=E9,F63,F7,F82 --target-version=py38 .
# The default issues
- run: ruff --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 --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 --select=SIM --fix . | true
git diff