@@ -2,39 +2,24 @@ name: fuzz
22
33on :
44 push :
5- paths :
6- - tox.ini
7- - .github/workflows/fuzz.yml
8- - scripts/fuzz.py
9- - src/**
10- - tests/**
11- - pyproject.toml
12-
5+ branches : main
136 pull_request :
147 paths :
15- - tox.ini
168 - .github/workflows/fuzz.yml
179 - scripts/fuzz.py
18- - src/**
19- - tests/**
20- - pyproject.toml
10+ schedule :
11+ - cron : " 0 0 * * * "
12+ workflow_dispatch :
2113
2214concurrency :
23- group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
15+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
2416 cancel-in-progress : true
2517
2618permissions :
2719 contents : read
2820
2921jobs :
3022 fuzz :
31- # We want to run on external PRs, but not on our own internal PRs as they'll be run
32- # by the push to the branch. Without this if check, checks are duplicated since
33- # internal PRs match both the push and pull_request events.
34- if :
35- github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
36- github.repository
37-
3823 runs-on : ubuntu-latest
3924 strategy :
4025 fail-fast : false
5540 pip-install : --group tox
5641
5742 - name : Run fuzz tests
58- run : tox -e fuzz
43+ id : fuzz
44+ run : tox -e fuzz --result-json $python_ver
45+ env :
46+ python_ver : ${{ matrix.python-version }}
47+
48+ - uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
49+ if : failure() && steps.fuzz.outcome == 'failure'
50+ with :
51+ name : ${{ matrix.python-version }}
52+ path : ${{ matrix.python-version }}
53+
54+ create-issue :
55+ runs-on : ubuntu-latest
56+ needs : fuzz
57+ if :
58+ github.repository == 'psf/black' && github.event_name != 'pull_request' &&
59+ failure()
60+ permissions :
61+ issues : write
62+ steps :
63+ - uses : actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
64+ with :
65+ merge-multiple : true
66+ path : ./output
67+
68+ - name : Generate issue data
69+ run : |
70+ output=issue-body.html
71+ touch $output
72+ for FILE in ./output/*; do
73+ echo "**Python $(basename $FILE)**" >> $output
74+ echo -e "\`\`\`py" >> $output
75+ echo -e "# stdout:" >> $output
76+ echo -e "$(jq .testenvs.fuzz.test[-1].output $FILE -r)\n" >> $output
77+ echo -e "# stderr:" >> $output
78+ echo -e "$(jq .testenvs.fuzz.test[-1].err $FILE -r)" >> $output
79+ echo -e "\`\`\`\n" >> $output
80+ done
81+
82+ - name : Get existing issue
83+ id : issue
84+ run : |
85+ echo "ISSUE=$( gh issue list \
86+ -A github-actions[bot] -l 'ci: fuzz error' \
87+ --json number -q .[0].number \
88+ -R $REPO )" >> $GITHUB_OUTPUT
89+ env :
90+ GITHUB_TOKEN : ${{ github.token }}
91+ REPO : ${{ github.repository }}
92+
93+ - name : Create new issue
94+ if : steps.issue.outputs.ISSUE == ''
95+ run : >
96+ gh issue create -t "Fuzz test failure" -F issue-body.html -l "ci: fuzz error"
97+ -R $REPO
98+ env :
99+ GITHUB_TOKEN : ${{ github.token }}
100+ REPO : ${{ github.repository }}
101+
102+ - name : Edit existing issue
103+ if : steps.issue.outputs.ISSUE != ''
104+ run : gh issue edit $ISSUE -F issue-body.html -R $REPO
105+ env :
106+ GITHUB_TOKEN : ${{ github.token }}
107+ REPO : ${{ github.repository }}
108+ ISSUE : ${{ steps.issue.outputs.ISSUE }}
0 commit comments