diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index b7a3fb21a..40ab0615d 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -167,3 +167,23 @@ jobs: - name: Check run: npx --yes @taplo/cli fmt --check + + python: + name: Style/Python + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: ruff + uses: astral-sh/ruff-action@v3 + with: + src: "./util" + + - name: ruff - format + uses: astral-sh/ruff-action@v3 + with: + src: "./util" + args: format --check diff --git a/util/analyze-gnu-results.py b/util/analyze-gnu-results.py index 82c13d778..b9e8534b3 100644 --- a/util/analyze-gnu-results.py +++ b/util/analyze-gnu-results.py @@ -29,6 +29,7 @@ Output: Prints shell export statements for TOTAL, PASS, FAIL, SKIP, XPASS, and ERROR that can be evaluated in a shell environment. """ + import json import sys from collections import defaultdict diff --git a/util/compare_gnu_result.py b/util/compare_gnu_result.py index b18d47065..e0b017e81 100755 --- a/util/compare_gnu_result.py +++ b/util/compare_gnu_result.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 """ -Compare the current results to the last results gathered from the main branch to highlight -if a PR is making the results better/worse. +Compare the current results to the last results gathered from the main branch to +highlight if a PR is making the results better/worse. Don't exit with error code if all failing tests are in the ignore-intermittent.txt list. """ @@ -28,17 +28,19 @@ skip_d = int(current["skip"]) - int(last["skip"]) # Get an annotation to highlight changes print( - f"::warning ::Changes from '{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d} / FAIL {fail_d:+d} / ERROR {error_d:+d} / SKIP {skip_d:+d} " + f"""::warning ::Changes from '{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d} / + FAIL {fail_d:+d} / ERROR {error_d:+d} / SKIP {skip_d:+d}""" ) # If results are worse, check if we should fail the job if pass_d < 0: print( - f"::error ::PASS count is reduced from '{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d} " + f"""::error ::PASS count is reduced from + '{REPO_DEFAULT_BRANCH}': PASS {pass_d:+d}""" ) # Check if all failing tests are intermittent based on the environment variable - only_intermittent = ONLY_INTERMITTENT.lower() == 'true' + only_intermittent = ONLY_INTERMITTENT.lower() == "true" if only_intermittent: print("::notice ::All failing tests are in the ignored intermittent list") diff --git a/util/gnu-json-result.py b/util/gnu-json-result.py index ffd39233b..86c2f59d0 100644 --- a/util/gnu-json-result.py +++ b/util/gnu-json-result.py @@ -37,5 +37,4 @@ for filepath in test_dir.glob("**/*.log"): except Exception as e: print(f"Error processing file {path}: {e}", file=sys.stderr) - print(json.dumps(out, indent=2, sort_keys=True)) diff --git a/util/remaining-gnu-error.py b/util/remaining-gnu-error.py index 20b3faee7..a632e891c 100755 --- a/util/remaining-gnu-error.py +++ b/util/remaining-gnu-error.py @@ -17,7 +17,7 @@ result_json = "result.json" try: urllib.request.urlretrieve( "https://raw.githubusercontent.com/uutils/coreutils-tracking/main/gnu-full-result.json", - result_json + result_json, ) except Exception as e: print(f"Failed to download the file: {e}") @@ -39,9 +39,9 @@ for files in types: list_of_files = sorted(tests, key=lambda x: os.stat(x).st_size) -def show_list(l): +def show_list(list_test): # Remove the factor tests and reverse the list (bigger first) - tests = list(filter(lambda k: "factor" not in k, l)) + tests = list(filter(lambda k: "factor" not in k, list_test)) for f in reversed(tests): if contains_require_root(f): diff --git a/util/size-experiment.py b/util/size-experiment.py index 2b1ec0fce..d383c906e 100644 --- a/util/size-experiment.py +++ b/util/size-experiment.py @@ -23,9 +23,7 @@ def config(name, val): sizes = {} -for (strip, panic, opt, lto) in product( - STRIP_VALS, PANIC_VALS, OPT_LEVEL_VALS, LTO_VALS -): +for strip, panic, opt, lto in product(STRIP_VALS, PANIC_VALS, OPT_LEVEL_VALS, LTO_VALS): if RECOMPILE: cmd = [ "cargo", @@ -77,8 +75,9 @@ collect_diff(2, "opt-level") collect_diff(3, "lto") -def analyze(l): - return f"MIN: {float(min(l)):.3}, AVG: {float(sum(l)/len(l)):.3}, MAX: {float(max(l)):.3}" +def analyze(change): + return f"""MIN: {float(min(change)):.3}, + AVG: {float(sum(change) / len(change)):.3}, MAX: {float(max(change)):.3}""" print("Absolute changes")