Skip to content

fuzz

fuzz #7881

Workflow file for this run

name: fuzz
on:
push:
branches: main
pull_request:
paths:
- .github/workflows/fuzz.yml
- scripts/fuzz.py
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
env:
PIP_UPLOADED_PRIOR_TO: P2D
jobs:
fuzz:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
pip-version: "26.1"
- name: Install dependencies
run: python -m pip install --group tox
- name: Run fuzz tests
id: fuzz
run: tox -e fuzz --result-json $python_ver
env:
python_ver: ${{ matrix.python-version }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: failure() && steps.fuzz.outcome == 'failure'
with:
name: ${{ matrix.python-version }}
path: ${{ matrix.python-version }}
create-issue:
runs-on: ubuntu-latest
needs: fuzz
if:
github.repository == 'psf/black' && github.event_name != 'pull_request' &&
failure()
permissions:
issues: write # Needed to create issue
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
merge-multiple: true
path: ./output
- name: Generate issue data
run: |
output=issue-body.html
touch $output
for FILE in ./output/*; do
echo "**Python $(basename $FILE)**" >> $output
echo -e "\`\`\`py" >> $output
echo -e "# stdout:" >> $output
echo -e "$(jq .testenvs.fuzz.test[-1].output $FILE -r)\n" >> $output
echo -e "# stderr:" >> $output
echo -e "$(jq .testenvs.fuzz.test[-1].err $FILE -r)" >> $output
echo -e "\`\`\`\n" >> $output
done
- name: Get existing issue
id: issue
run: |
echo "ISSUE=$( gh issue list \
-A github-actions[bot] -l 'ci: fuzz error' \
--json number -q .[0].number \
-R $REPO )" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
- name: Create new issue
if: steps.issue.outputs.ISSUE == ''
run: >
gh issue create -t "Fuzz test failure" -F issue-body.html -l "ci: fuzz error"
-R $REPO
env:
GITHUB_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
- name: Edit existing issue
if: steps.issue.outputs.ISSUE != ''
run: gh issue edit $ISSUE -F issue-body.html -R $REPO
env:
GITHUB_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
ISSUE: ${{ steps.issue.outputs.ISSUE }}