Skip to content

Commit a491c77

Browse files
authored
fix: fuzz testing (#98)
* fixed fuzz failure upload * fixed: always upload cached fuzz corpus * fixed: fuzz matrix should be compact Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent e635261 commit a491c77

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

.github/workflows/fuzz-test.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
fuzz_tests=$(\
4040
go test work -list Fuzz -json ./... |\
4141
jq '.|select(.Action == "output")|select( (.Output|test("^(ok)|(\\?)"))|not )|{package: .Package, test: (.Output|gsub("\n";""))}'|\
42-
jq --slurp \
42+
jq -c --slurp \
4343
)
4444
export fuzz_tests
4545
echo "matrix<<EOF" >> "${GITHUB_OUTPUT}"
@@ -125,7 +125,7 @@ jobs:
125125
fi
126126
127127
declare -i max_size_b=$(("${CORPUS_MAX_SIZE_MB}" * 1024 * 1024))
128-
purged_files=$(purge "${purged_dir}" "${max_size_b}");
128+
purged_files=$(purge "${CORPUS_DIR}" "${max_size_b}");
129129
echo "::notice:cache size is ${CURRENT_SIZE_MB} MB: purging oldest files to keep it under ${CORPUS_MAX_SIZE_MB} MB"
130130
if [[ ${purged_files} -gt 0 ]] ; then
131131
echo "::notice:removed ${purged_files} files to keep the cache size below ${CORPUS_MAX_SIZE_MB} MB"
@@ -145,7 +145,9 @@ jobs:
145145
name: Archive failed cases
146146
if: ${{ failure() }}
147147
run: |
148-
tar czf "fuzzcase-${{ matrix.test }}.tgz" $(find "${{ matrix.package }}/testdata/fuzz" -type f)
148+
# Package name needs to be reworked to account for v2 suffixes
149+
folder=$(go list -f '{{ printf "%s" .Dir }}' '${{ matrix.package }}'
150+
tar czf "fuzzcase-${{ matrix.test }}.tgz" $(find "${folder}/testdata/fuzz" -type f)
149151
-
150152
name: Upload failed cases
151153
if: ${{ failure() }}
@@ -157,9 +159,9 @@ jobs:
157159
name: '${{ runner.os }}-fuzz-corpus-failure'
158160
retention-days: 60
159161
-
160-
name: Upload failed corpus
162+
name: Upload current corpus
161163
# This is the current corpus, it does not contain the latest failed case
162-
if: ${{ failure() }}
164+
if: ${{ always() }}
163165
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
164166
with:
165167
path: ${{ env.CORPUS_DIR }}
@@ -168,5 +170,5 @@ jobs:
168170
-
169171
name: Report fuzz corpus cache size
170172
run: |
171-
FINAL_SIZE=$(du -m "${CORPUS_DIR}"|cut -f1)
173+
FINAL_SIZE=$(du -sm "${CORPUS_DIR}"|cut -f1)
172174
echo "::notice title=fuzz corpus size::${FINAL_SIZE}MB"

0 commit comments

Comments
 (0)