Debian Codegraph @

.github/workflows/fuzz.yml

raw
1 name: fuzz
2
3 on:
4 push:
5 branches: main
6 pull_request:
7 paths:
8 - .github/workflows/fuzz.yml
9 - scripts/fuzz.py
10 schedule:
11 - cron: "0 0 * * *"
12 workflow_dispatch:
13
14 concurrency:
15 group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
16 cancel-in-progress: true
17
18 permissions:
19 contents: read
20
21 jobs:
22 fuzz:
23 runs-on: ubuntu-latest
24 strategy:
25 fail-fast: false
26 matrix:
27 # TODO: add 3.15; relies on libcst which doesn't support 3.15 yet
28 python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
29
30 steps:
31 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
32 with:
33 persist-credentials: false
34
35 - name: Set up Python ${{ matrix.python-version }}
36 uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
37 with:
38 python-version: ${{ matrix.python-version }}
39 allow-prereleases: true
40 pip-version: "25.3"
41 pip-install: --group tox
42
43 - name: Run fuzz tests
44 id: fuzz
45 run: tox -e fuzz --result-json $python_ver
46 env:
47 python_ver: ${{ matrix.python-version }}
48
49 - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
50 if: failure() && steps.fuzz.outcome == 'failure'
51 with:
52 name: ${{ matrix.python-version }}
53 path: ${{ matrix.python-version }}
54
55 create-issue:
56 runs-on: ubuntu-latest
57 needs: fuzz
58 if:
59 github.repository == 'psf/black' && github.event_name != 'pull_request' &&
60 failure()
61 permissions:
62 issues: write # Needed to create issue
63 steps:
64 - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
65 with:
66 merge-multiple: true
67 path: ./output
68
69 - name: Generate issue data
70 run: |
71 output=issue-body.html
72 touch $output
73 for FILE in ./output/*; do
74 echo "**Python $(basename $FILE)**" >> $output
75 echo -e "\`\`\`py" >> $output
76 echo -e "# stdout:" >> $output
77 echo -e "$(jq .testenvs.fuzz.test[-1].output $FILE -r)\n" >> $output
78 echo -e "# stderr:" >> $output
79 echo -e "$(jq .testenvs.fuzz.test[-1].err $FILE -r)" >> $output
80 echo -e "\`\`\`\n" >> $output
81 done
82
83 - name: Get existing issue
84 id: issue
85 run: |
86 echo "ISSUE=$( gh issue list \
87 -A github-actions[bot] -l 'ci: fuzz error' \
88 --json number -q .[0].number \
89 -R $REPO )" >> $GITHUB_OUTPUT
90 env:
91 GITHUB_TOKEN: ${{ github.token }}
92 REPO: ${{ github.repository }}
93
94 - name: Create new issue
95 if: steps.issue.outputs.ISSUE == ''
96 run: >
97 gh issue create -t "Fuzz test failure" -F issue-body.html -l "ci: fuzz error"
98 -R $REPO
99 env:
100 GITHUB_TOKEN: ${{ github.token }}
101 REPO: ${{ github.repository }}
102
103 - name: Edit existing issue
104 if: steps.issue.outputs.ISSUE != ''
105 run: gh issue edit $ISSUE -F issue-body.html -R $REPO
106 env:
107 GITHUB_TOKEN: ${{ github.token }}
108 REPO: ${{ github.repository }}
109 ISSUE: ${{ steps.issue.outputs.ISSUE }}