Skip to content

Update the RustPython Ruff fork to 0.17.2 #56

Update the RustPython Ruff fork to 0.17.2

Update the RustPython Ruff fork to 0.17.2 #56

Workflow file for this run

name: Daily parser fuzz
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
pull_request:
paths:
- ".github/workflows/daily_fuzz.yaml"
- "python/py-fuzzer/**"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
UV_LOCKED: 1
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUSTUP_MAX_RETRIES: 10
# Line-tables-only debug info: faster builds, backtraces still work.
CARGO_PROFILE_DEV_DEBUG: line-tables-only
CARGO_PROFILE_DEV_LTO: "false"
CARGO_PROFILE_DEV_OPT_LEVEL: 0
PACKAGE_NAME: ruff
FORCE_COLOR: 1
jobs:
fuzz:
name: Fuzz
runs-on: ${{ github.repository == 'astral-sh/ruff' && 'github-ubuntu-24.04-x86_64-4' || 'ubuntu-latest' }}
timeout-minutes: 20
env:
# Keep in sync with the job's timeout-minutes.
FUZZ_JOB_TIMEOUT_MINUTES: 20
permissions:
contents: read
outputs:
issue-report: ${{ steps.upload_report.outputs.artifact-id }}
# Don't run the cron job on forks:
if: ${{ github.repository == 'astral-sh/ruff' || github.event_name != 'schedule' }}
steps:
- name: Record job start time
run: echo "FUZZ_JOB_STARTED_AT=$(date +%s)" >> "$GITHUB_ENV"
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
# renovate: datasource=github-release-attachments depName=astral-sh/uv
version: "0.13.4"
checksum: "2b428396f12572d4429cf210ca234dd599a33b3af0958a4d5ed569d63e3f344f"
- name: "Install Rust toolchain"
run: rustup show
- name: "Install mold"
uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- name: Build ruff
# A debug build means the script runs slower once it gets started,
# but this is outweighed by the fact that a release build takes *much* longer to compile in CI
run: cargo build --locked
- name: Fuzz
id: fuzz
run: |
issue_options=()
if [[ "$GITHUB_EVENT_NAME" == "schedule" ]]; then
issue_options+=(--write-github-issue="$RUNNER_TEMP/fuzz-issue.md")
fi
# shellcheck disable=SC2046
(
uv run \
--python=3.14 \
--project=./python/py-fuzzer \
--locked \
fuzz \
--test-executable=target/debug/ruff \
--budget-minutes="${FUZZ_JOB_TIMEOUT_MINUTES}" \
--job-started-at="${FUZZ_JOB_STARTED_AT}" \
--bin=ruff \
"${issue_options[@]}" \
$(shuf -i 0-9999999999999999999 -n 1000)
)
- name: Upload the fuzz report
id: upload_report
if: ${{ failure() && github.event_name == 'schedule' && steps.fuzz.outcome == 'failure' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: daily-fuzz-issue
path: ${{ runner.temp }}/fuzz-issue.md
if-no-files-found: ignore
# The fuzz job runs third-party code, including build dependencies. Keep the
# issue-writing token in a separate job so that code cannot access it. That code
# could also alter the report, so use it only as issue text and never execute it.
create-issue-on-failure:
name: Report a failed fuzz run
runs-on: ${{ github.repository == 'astral-sh/ruff' && 'github-ubuntu-24.04-x86_64-4' || 'ubuntu-latest' }}
needs: fuzz
if: ${{ github.repository == 'astral-sh/ruff' && always() && github.event_name == 'schedule' && needs.fuzz.result != 'success' }}
permissions:
issues: write
steps:
- name: Download the fuzz report
id: download_report
if: ${{ needs.fuzz.outputs.issue-report != '' }}
continue-on-error: true
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: daily-fuzz-issue
path: ${{ runner.temp }}/fuzz-report
- name: Create an issue for the failed fuzz run
if: ${{ !cancelled() }}
env:
REPORT_DOWNLOAD_OUTCOME: ${{ steps.download_report.outcome }}
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue = {
owner: "astral-sh",
repo: "ruff",
title: `Daily parser fuzz failed on ${new Date().toDateString()}`,
labels: ["bug", "parser", "fuzzer"],
};
const fallbackBody = "Run listed here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}";
const createIssue = (body) => github.rest.issues.create({ ...issue, body });
if (process.env.REPORT_DOWNLOAD_OUTCOME === "success") {
try {
const report = require("node:fs").readFileSync(`${process.env.RUNNER_TEMP}/fuzz-report/fuzz-issue.md`, "utf8");
await createIssue(report);
return;
} catch (error) {
core.error(error);
await createIssue(fallbackBody);
throw error;
}
}
await createIssue(fallbackBody);