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 jobs: fuzz: runs-on: ubuntu-latest strategy: fail-fast: false matrix: # TODO: add 3.15; relies on libcst which doesn't support 3.15 yet python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: persist-credentials: false - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: ${{ matrix.python-version }} allow-prereleases: true pip-version: "25.3" 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 }}