Skip to content

Commit 59bcea9

Browse files
committed
Run py-fuzzer with --profile=profiling locally and in CI
1 parent 1fe958c commit 59bcea9

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

.github/workflows/ci.yaml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ jobs:
437437
workspaces: "fuzz -> target"
438438
- name: "Install Rust toolchain"
439439
run: rustup show
440+
- name: "Install mold"
441+
uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
440442
- name: "Install cargo-binstall"
441443
uses: cargo-bins/cargo-binstall@b3f755e95653da9a2d25b99154edfdbd5b356d0a # v1.15.10
442444
- name: "Install cargo-fuzz"
@@ -645,45 +647,45 @@ jobs:
645647
name: "Fuzz for new ty panics"
646648
runs-on: ${{ github.repository == 'astral-sh/ruff' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
647649
needs:
648-
- cargo-test-linux
649650
- determine_changes
650651
# Only runs on pull requests, since that is the only we way we can find the base version for comparison.
651652
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-test') && github.event_name == 'pull_request' && (needs.determine_changes.outputs.ty == 'true' || needs.determine_changes.outputs.py-fuzzer == 'true') }}
652653
timeout-minutes: ${{ github.repository == 'astral-sh/ruff' && 10 || 20 }}
653654
steps:
654655
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
655656
with:
657+
fetch-depth: 0
656658
persist-credentials: false
657-
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
658-
name: Download new ty binary
659-
id: ty-new
660-
with:
661-
name: ty
662-
path: target/debug
663-
- uses: dawidd6/action-download-artifact@20319c5641d495c8a52e688b7dc5fada6c3a9fbc # v8
664-
name: Download baseline ty binary
665-
with:
666-
name: ty
667-
branch: ${{ github.event.pull_request.base.ref }}
668-
workflow: "ci.yaml"
669-
check_artifacts: true
670659
- uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
660+
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
661+
- name: "Install Rust toolchain"
662+
run: rustup show
663+
- name: "Install mold"
664+
uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
671665
- name: Fuzz
672666
env:
673667
FORCE_COLOR: 1
674-
NEW_TY: ${{ steps.ty-new.outputs.download-path }}
675668
run: |
676-
# Make executable, since artifact download doesn't preserve this
677-
chmod +x "${PWD}/ty" "${NEW_TY}/ty"
669+
echo "new commit"
670+
git rev-list --format=%s --max-count=1 "$GITHUB_SHA"
671+
cargo build --profile=profiling --bin=ty
672+
mv target/profiling/ty ty-new
673+
674+
MERGE_BASE="$(git merge-base "$GITHUB_SHA" "origin/$GITHUB_BASE_REF")"
675+
git checkout -b old_commit "$MERGE_BASE"
676+
echo "old commit (merge base)"
677+
git rev-list --format=%s --max-count=1 old_commit
678+
cargo build --profile=profiling --bin=ty
679+
mv target/profiling/ty ty-old
678680
679681
(
680682
uv run \
681683
--python="${PYTHON_VERSION}" \
682684
--project=./python/py-fuzzer \
683685
--locked \
684686
fuzz \
685-
--test-executable="${NEW_TY}/ty" \
686-
--baseline-executable="${PWD}/ty" \
687+
--test-executable=ty-new \
688+
--baseline-executable=ty-old \
687689
--only-new-bugs \
688690
--bin=ty \
689691
0-1000
@@ -715,6 +717,8 @@ jobs:
715717
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
716718
- name: "Install Rust toolchain"
717719
run: rustup show
720+
- name: "Install mold"
721+
uses: rui314/setup-mold@725a8794d15fc7563f59595bd9556495c0564878 # v1
718722
- name: "Run ty completion evaluation"
719723
run: cargo run --release --package ty_completion_eval -- all --threshold 0.4 --tasks /tmp/completion-evaluation-tasks.csv
720724
- name: "Ensure there are no changes"

python/py-fuzzer/fuzz.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,14 @@ def parse_args() -> ResolvedCliArgs:
395395

396396
if not args.test_executable:
397397
print(
398-
"Running `cargo build --release` since no test executable was specified...",
398+
"Running `cargo build --profile=profiling` since no test executable was specified...",
399399
flush=True,
400400
)
401401
cmd: list[str] = [
402402
"cargo",
403403
"build",
404-
"--release",
404+
"--profile",
405+
"profiling",
405406
"--locked",
406407
"--color",
407408
"always",

0 commit comments

Comments
 (0)