mirror of
https://github.com/astral-sh/ruff
synced 2026-01-09 15:44:22 -05:00
[red-knot] Add fuzzer to catch panics for invalid syntax (#14678)
## Summary This PR adds a fuzzer harness for red knot that runs the type checker on source code that contains invalid syntax. Additionally, this PR also updates the `init-fuzzer.sh` script to increase the corpus size to: * Include various crates that includes Python source code * Use the 3.13 CPython source code And, remove any non-Python files from the final corpus so that when the fuzzer tries to minify the corpus, it doesn't produce files that only contains documentation content as that's just noise. ## Test Plan Run `./fuzz/init-fuzzer.sh`, say no to the large dataset. Run the fuzzer with `cargo +night fuzz run red_knot_check_invalid_syntax -- -timeout=5`
This commit is contained in:
9
.github/workflows/ci.yaml
vendored
9
.github/workflows/ci.yaml
vendored
@@ -32,6 +32,8 @@ jobs:
|
||||
# Flag that is raised when any code is changed
|
||||
# This is superset of the linter and formatter
|
||||
code: ${{ steps.changed.outputs.code_any_changed }}
|
||||
# Flag that is raised when any code that affects the fuzzer is changed
|
||||
fuzz: ${{ steps.changed.outputs.fuzz_any_changed }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -79,6 +81,11 @@ jobs:
|
||||
- python/**
|
||||
- .github/workflows/ci.yaml
|
||||
|
||||
fuzz:
|
||||
- fuzz/Cargo.toml
|
||||
- fuzz/Cargo.lock
|
||||
- fuzz/fuzz_targets/**
|
||||
|
||||
code:
|
||||
- "**/*"
|
||||
- "!**/*.md"
|
||||
@@ -288,7 +295,7 @@ jobs:
|
||||
name: "cargo fuzz build"
|
||||
runs-on: ubuntu-latest
|
||||
needs: determine_changes
|
||||
if: ${{ github.ref == 'refs/heads/main' }}
|
||||
if: ${{ github.ref == 'refs/heads/main' || needs.determine_changes.outputs.fuzz == 'true' }}
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
Reference in New Issue
Block a user