Skip to content

Commit d7efaf4

Browse files
authored
Fail CI on new linter ecosystem panics (#23597)
Summary -- The huge number of changes in #22205 (comment) should have obviously been a red flag, but I think it would be nice if CI failed when new ecosystem panics were introduced. This PR adds a check for diagnostic lines that start with `panic: Panicked at crates/`, raises a `ToolError` if any are found in the results from the comparison executable, and then ~~also exits non-zero if any errors are returned~~ fails the CI run if the corresponding error message was printed. After trying this out in CI, I opted not to change the script's exit code itself because that suppressed the ecosystem comment. It feels a little hackier this way but preserves the behavior I wanted of both failing CI and still getting the ecosystem comment to help with debugging. Test Plan -- Local testing on the 0.15.3 tag showing that ruff-ecosystem exited non-zero and some manual testing in CI, as you can see below.
1 parent b910e7d commit d7efaf4

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,12 @@ jobs:
663663
path: ecosystem-result
664664
if-no-files-found: "error"
665665

666+
- name: Fail on ecosystem errors
667+
run: |
668+
if grep -q "project error" ecosystem-result; then
669+
exit 1
670+
fi
671+
666672
fuzz-ty:
667673
name: "Fuzz for new ty panics"
668674
runs-on: ${{ github.repository == 'astral-sh/ruff' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}

python/ruff-ecosystem/ruff_ecosystem/check.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
r"^(?P<diff>[+-])? ?(?P<location>.*): (?P<code>[A-Z]{1,4}[0-9]{3,4}|[a-z\-]+:)(?P<fixable> \[\*\])? (?P<message>.*)"
5050
)
5151

52+
PANIC_DIAGNOSTIC_LINE_RE = re.compile(r"^[^:]+: panic: Panicked at ")
53+
5254
CHECK_VIOLATION_FIX_INDICATOR = " [*]"
5355

5456
GITHUB_MAX_COMMENT_LENGTH = 65536 # characters
@@ -530,6 +532,10 @@ async def compare_check(
530532
comparison_task.result(),
531533
)
532534

535+
for line in comparison_output:
536+
if PANIC_DIAGNOSTIC_LINE_RE.match(line):
537+
raise ToolError(line)
538+
533539
diff = Diff.from_pair(baseline_output, comparison_output)
534540

535541
return Comparison(diff=diff, repo=cloned_repo)

0 commit comments

Comments
 (0)