From 736555ad810dd8a54c16799ec7db525284c6549e Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 12 Aug 2026 10:38:31 +0200 Subject: [PATCH] feat(go-test): add input options to go-test workflows. Allows callers to disable -race and to specify timeout. Signed-off-by: Frederic BIDON --- .github/workflows/go-test-monorepo.yml | 69 +++++++++++++++++--------- .github/workflows/go-test.yml | 39 +++++++++++---- 2 files changed, 74 insertions(+), 34 deletions(-) diff --git a/.github/workflows/go-test-monorepo.yml b/.github/workflows/go-test-monorepo.yml index 7023bb9..1594e81 100644 --- a/.github/workflows/go-test-monorepo.yml +++ b/.github/workflows/go-test-monorepo.yml @@ -23,6 +23,16 @@ on: type: string required: false + no-race: + description: 'runs test without -race' + type: string + required: false + default: 'false' + timeout: + description: 'test timeout' + type: string + required: false + default: '30m' defaults: run: @@ -160,19 +170,25 @@ jobs: # * go.work committed to git env: EXTRA_FLAGS: ${{ inputs.extra-flags }} - run: > + WANTS_NORACE: ${{ inputs.no-race }} + TIMEOUT: ${{ inputs.timeout }} + run: | + RACEOPT="-race" + if [[ "${WANTS_NORACE}" == "true" ]] ; then + RACEOPT="" + fi - gotestsum - --jsonfile 'unit.report.${{ matrix.os }}-${{ matrix.go }}.json' - -- - work - -race - -p 2 - -count 1 - -timeout=30m - -coverprofile='unit.coverage.${{ matrix.os }}-${{ matrix.go }}.out' - -covermode=atomic - -coverpkg='${{ needs.lint.outputs.coverpkg }}' ${EXTRA_FLAGS} + gotestsum \ + --jsonfile 'unit.report.${{ matrix.os }}-${{ matrix.go }}.json' \ + -- \ + work \ + "${RACEOPT}" \ + -p 2 \ + -count 1 \ + -timeout="${TIMEOUT}" \ + -coverprofile='unit.coverage.${{ matrix.os }}-${{ matrix.go }}.out' \ + -covermode=atomic \ + -coverpkg='${{ needs.lint.outputs.coverpkg }}' ${EXTRA_FLAGS} \ ./... - name: Run unit tests on all modules ( - gotestsum - --jsonfile 'unit.report.${{ matrix.os }}-${{ matrix.go }}.json' - -- - -race - -p 2 - -count 1 - -timeout=30m - -coverprofile='unit.coverage.${{ matrix.os }}-${{ matrix.go }}.out' - -covermode=atomic - -coverpkg='${{ needs.lint.outputs.coverpkg }}' ${EXTRA_FLAGS} + WANTS_NORACE: ${{ inputs.no-race }} + TIMEOUT: ${{ inputs.timeout }} + run: | + RACEOPT="-race" + if [[ "${WANTS_NORACE}" == "true" ]] ; then + RACEOPT="" + fi + + gotestsum \ + --jsonfile 'unit.report.${{ matrix.os }}-${{ matrix.go }}.json' \ + -- \ + "${RACEOPT}" \ + -p 2 \ + -count 1 \ + -timeout="${TIMEOUT}" \ + -coverprofile='unit.coverage.${{ matrix.os }}-${{ matrix.go }}.out' \ + -covermode=atomic \ + -coverpkg='${{ needs.lint.outputs.coverpkg }}' ${EXTRA_FLAGS} \ ${ALL_MODULES} - name: Run unit tests diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index 8579b6c..8f15cd0 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -23,6 +23,16 @@ on: type: string required: false + no-race: + description: 'runs test without -race' + type: string + required: false + default: 'false' + timeout: + description: 'test timeout' + type: string + required: false + default: '30m' defaults: run: @@ -95,17 +105,24 @@ jobs: name: Run unit tests env: EXTRA_FLAGS: ${{ inputs.extra-flags }} - run: > - gotestsum - --jsonfile 'unit.report.${{ matrix.os }}-${{ matrix.go }}.json' - -- - -race - -p 2 - -count 1 - -timeout=30m - -coverprofile='unit.coverage.${{ matrix.os }}-${{ matrix.go }}.out' - -covermode=atomic - -coverpkg="$(go list)"/... ${EXTRA_FLAGS} + WANTS_NORACE: ${{ inputs.no-race }} + TIMEOUT: ${{ inputs.timeout }} + run: | + RACEOPT="-race" + if [[ "${WANTS_NORACE}" == "true" ]] ; then + RACEOPT="" + fi + + gotestsum \ + --jsonfile 'unit.report.${{ matrix.os }}-${{ matrix.go }}.json' \ + -- \ + "${RACEOPT}" \ + -p 2 \ + -count 1 \ + -timeout="${TIMEOUT}" \ + -coverprofile='unit.coverage.${{ matrix.os }}-${{ matrix.go }}.out' \ + -covermode=atomic \ + -coverpkg="$(go list)"/... ${EXTRA_FLAGS} \ ./... - name: Upload coverage artifacts