Skip to content

Commit d68c5f3

Browse files
authored
feat(go-test): added input parameter to inject go test flags (#86)
fuzz tests: added upload of failed case (which is NOT located in corpus) Signed-off-by: Frederic BIDON <[email protected]>
1 parent 5fcd480 commit d68c5f3

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

.github/workflows/fuzz-test.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,25 @@ jobs:
142142
-fuzzminimizetime='${{ env.FUZZ_MINIMIZE_TIME }}'
143143
${{ matrix.package }}
144144
-
145-
name: Upload failed corpus
145+
name: Archive failed cases
146+
if: ${{ failure() }}
147+
run: |
148+
tar czf fuzzcase.tgz $(find "${{ matrix.package }}/testdata/fuzz" -type f)
149+
-
150+
name: Upload failed cases
146151
if: ${{ failure() }}
147152
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
148153
# TODO(fredbi): ideally, after uploading, we should fire a pull request to add
149154
# this corpus to testdata.
155+
with:
156+
path: fuzzcase.tgz
157+
name: '${{ runner.os }}-fuzz-corpus-failure'
158+
retention-days: 60
159+
-
160+
name: Upload failed corpus
161+
# This is the current corpus, it does not contain the latest failed case
162+
if: ${{ failure() }}
163+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
150164
with:
151165
path: ${{ env.CORPUS_DIR }}
152166
name: '${{ runner.os }}-fuzz-corpus-failure'

.github/workflows/go-test-monorepo.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ permissions:
66

77
on:
88
workflow_call:
9+
inputs:
10+
extra-flags:
11+
description: extra flags to add to go test
12+
type: string
13+
required: false
914

1015
defaults:
1116
run:
@@ -115,6 +120,8 @@ jobs:
115120
# This requires:
116121
# * go.work properly initialized with use of all known modules
117122
# * go.work committed to git
123+
env:
124+
EXTRA_FLAGS: ${{ inputs.extra-flags }}
118125
run: >
119126
gotestsum
120127
--jsonfile 'unit.report.${{ matrix.os }}-${{ matrix.go }}.json'
@@ -126,13 +133,16 @@ jobs:
126133
-timeout=20m
127134
-coverprofile='unit.coverage.${{ matrix.os }}-${{ matrix.go }}.out'
128135
-covermode=atomic
136+
-coverpkg="$(go list)"/... ${EXTRA_FLAGS}
129137
./...
130138
-
131139
name: Run unit tests on all modules (<go1.25 or no go.work) [monorepo]
132140
if: >
133141
${{
134142
needs.lint.outputs.is-monorepo == 'true' && steps.detect-go-version.outputs.is-gotestwork-supported != 'true'
135143
}}
144+
env:
145+
EXTRA_FLAGS: ${{ inputs.extra-flags }}
136146
run: |
137147
declare -a ALL_MODULES
138148
ALL_MODULES=(${{ needs.lint.outputs.bash-subpaths }}) # a bash array with all module folders, suffixed with "/..."
@@ -147,10 +157,13 @@ jobs:
147157
-timeout=20m \
148158
-coverprofile='unit.coverage.${{ matrix.os }}-${{ matrix.go }}.out' \
149159
-covermode=atomic \
160+
-coverpkg="$(go list)"/... ${EXTRA_FLAGS} \
150161
${ALL_MODULES[@]}
151162
-
152163
name: Run unit tests
153164
if: ${{ needs.lint.outputs.is-monorepo != 'true' }}
165+
env:
166+
EXTRA_FLAGS: ${{ inputs.extra-flags }}
154167
run: >
155168
gotestsum
156169
--jsonfile 'unit.report.${{ matrix.os }}-${{ matrix.go }}.json'
@@ -161,7 +174,7 @@ jobs:
161174
-timeout=20m
162175
-coverprofile='unit.coverage.${{ matrix.os }}-${{ matrix.go }}.out'
163176
-covermode=atomic
164-
-coverpkg="$(go list)"/...
177+
-coverpkg="$(go list)"/... ${EXTRA_FLAGS}
165178
./...
166179
-
167180
name: Upload coverage artifacts

.github/workflows/go-test.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ permissions:
66

77
on:
88
workflow_call:
9+
inputs:
10+
extra-flags:
11+
description: extra flags to add to go test
12+
type: string
13+
required: false
914

1015
defaults:
1116
run:
@@ -66,6 +71,8 @@ jobs:
6671
echo "TMP=${TMP}" >> "${GITHUB_ENV}"
6772
-
6873
name: Run unit tests
74+
env:
75+
EXTRA_FLAGS: ${{ inputs.extra-flags }}
6976
run: >
7077
gotestsum
7178
--jsonfile 'unit.report.${{ matrix.os }}-${{ matrix.go }}.json'
@@ -76,7 +83,7 @@ jobs:
7683
-timeout=20m
7784
-coverprofile='unit.coverage.${{ matrix.os }}-${{ matrix.go }}.out'
7885
-covermode=atomic
79-
-coverpkg="$(go list)"/...
86+
-coverpkg="$(go list)"/... ${EXTRA_FLAGS}
8087
./...
8188
-
8289
name: Upload coverage artifacts

0 commit comments

Comments
 (0)