adding gotestsum for better test output (#40753)

**Related issue:** Resolves #30896

## Testing

- [x] QA'd all new/changed functionality manually
This commit is contained in:
Konstantin Sykulev
2026-03-03 16:01:11 -06:00
committed by GitHub
parent 8c48b7d93b
commit 75c05aeb3f
3 changed files with 33 additions and 3 deletions
+14 -1
View File
@@ -115,6 +115,9 @@ jobs:
with:
go-version-file: 'go.mod'
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
# Pre-starting dependencies here means they are ready to go when we need them.
- name: Start Infra Dependencies
if: ${{ env.NEED_DOCKER }}
@@ -230,7 +233,9 @@ jobs:
- name: Run Go Tests
run: |
GO_TEST_EXTRA_FLAGS="-v -race=$RACE_ENABLED -timeout=$GO_TEST_TIMEOUT ${{ env.RUN_TESTS_ARG }}" \
USE_GOTESTSUM=1 \
GOTESTSUM_FORMAT=testdox \
GO_TEST_EXTRA_FLAGS="-v -race=$RACE_ENABLED -timeout=$GO_TEST_TIMEOUT ${{ env.RUN_TESTS_ARG }}" \
TEST_LOCK_FILE_PATH=$(pwd)/lock \
TEST_CRON_NO_RECOVER=1 \
NETWORK_TEST=1 \
@@ -298,6 +303,14 @@ jobs:
name: ${{ env.ARTIFACT_PREFIX }}-summary-test-log
path: /tmp/summary.txt
- name: Upload JSON test output
if: always()
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: ${{ env.ARTIFACT_PREFIX }}-test-json
path: /tmp/test-output.json
if-no-files-found: warn
- name: Set test status
if: always()
run: |
+14 -2
View File
@@ -128,6 +128,9 @@ jobs:
with:
go-version-file: 'go.mod'
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: verify mysql
run: |
while ! mysqladmin ping --host=localhost --port=$PORT --protocol=TCP --silent; do
@@ -144,9 +147,10 @@ jobs:
- name: Run Go tests
run: |
go test -v -parallel 8 -race=$RACE_ENABLED -timeout=$GO_TEST_TIMEOUT \
gotestsum --format=testdox --jsonfile=/tmp/test-output.json -- \
-v -parallel 8 -race=$RACE_ENABLED -timeout=$GO_TEST_TIMEOUT \
-coverprofile=coverage.txt -covermode=atomic -coverpkg=github.com/fleetdm/fleet/v4/server/mdm/nanomdm/... \
./server/mdm/nanomdm/storage/mysql 2>&1 | tee /tmp/gotest.log
./server/mdm/nanomdm/storage/mysql 2>&1 | tee /tmp/gotest.log
- name: Save coverage
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
@@ -198,6 +202,14 @@ jobs:
name: nanomdm-summary-test-log
path: /tmp/summary.txt
- name: Upload JSON test output
if: always()
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: nanomdm-test-json
path: /tmp/test-output.json
if-no-files-found: warn
# We upload all backend coverage in one step so that we're less like to end up in a situation with a partial coverage report.
upload-coverage:
needs: [test-go-no-db, test-go, test-go-extended-mysql, test-go-nanomdm]
+5
View File
@@ -267,10 +267,15 @@ dlv_test_pkg_to_test := $(addprefix github.com/fleetdm/fleet/v4/,$(PKG_TO_TEST))
.run-go-tests:
ifeq ($(PKG_TO_TEST), "")
@echo "Please specify one or more packages to test. See '$(TOOL_CMD) help run-go-tests' for more info.";
else
ifdef USE_GOTESTSUM
@echo Running Go tests with gotestsum:
gotestsum --format=$(GOTESTSUM_FORMAT) --jsonfile=/tmp/test-output.json -- -tags full,fts5,netgo -run=${TESTS_TO_RUN} ${GO_TEST_MAKE_FLAGS} ${GO_TEST_EXTRA_FLAGS} -parallel 8 -coverprofile=coverage.txt -covermode=atomic -coverpkg=$(COVER_PKG) $(go_test_pkg_to_test)
else
@echo Running Go tests with command:
go test -tags full,fts5,netgo -run=${TESTS_TO_RUN} ${GO_TEST_MAKE_FLAGS} ${GO_TEST_EXTRA_FLAGS} -parallel 8 -coverprofile=coverage.txt -covermode=atomic -coverpkg=$(COVER_PKG) $(go_test_pkg_to_test)
endif
endif
# This is the base command to debug Go tests.
# Wrap this to run tests with presets (see `debug-go-tests`)