From 13703de67ec4cea94f34c416bd9187555ef0fd4c Mon Sep 17 00:00:00 2001 From: Todd Treece <360020+toddtreece@users.noreply.github.com> Date: Fri, 9 Aug 2024 10:25:27 -0400 Subject: [PATCH] Chore: Update tests to use go-workspace script (#91746) --- .drone.yml | 54 +++++++++++++-------------- Makefile | 3 +- scripts/drone/steps/lib.star | 6 +-- scripts/go-workspace/test-includes.sh | 11 ++++++ 4 files changed, 43 insertions(+), 31 deletions(-) create mode 100755 scripts/go-workspace/test-includes.sh diff --git a/.drone.yml b/.drone.yml index ac3ccb9c97f..e684351091b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -397,8 +397,8 @@ steps: name: wire-install - commands: - apk add --update build-base shared-mime-info shared-mime-info-lang - - go list -f '{{.Dir}}/...' -m | xargs go test -tags requires_buildifer -short -covermode=atomic - -timeout=5m + - ./scripts/go-workspace/test-includes.sh | xargs go test -tags requires_buildifer + -short -covermode=atomic -timeout=5m depends_on: - wire-install image: golang:1.22.4-alpine @@ -1098,8 +1098,8 @@ steps: - commands: - apk add --update build-base - go clean -testcache - - go list -f '{{.Dir}}/...' -m | xargs go test -run IntegrationRedis -covermode=atomic - -timeout=2m + - ./scripts/go-workspace/test-includes.sh | xargs go test -run IntegrationRedis + -covermode=atomic -timeout=2m depends_on: - wire-install - wait-for-redis @@ -1114,8 +1114,8 @@ steps: - commands: - apk add --update build-base - go clean -testcache - - go list -f '{{.Dir}}/...' -m | xargs go test -run IntegrationMemcached -covermode=atomic - -timeout=2m + - ./scripts/go-workspace/test-includes.sh | xargs go test -run IntegrationMemcached + -covermode=atomic -timeout=2m depends_on: - wire-install - wait-for-memcached @@ -1776,8 +1776,8 @@ steps: name: wire-install - commands: - apk add --update build-base shared-mime-info shared-mime-info-lang - - go list -f '{{.Dir}}/...' -m | xargs go test -tags requires_buildifer -short -covermode=atomic - -timeout=5m + - ./scripts/go-workspace/test-includes.sh | xargs go test -tags requires_buildifer + -short -covermode=atomic -timeout=5m depends_on: - wire-install image: golang:1.22.4-alpine @@ -2604,8 +2604,8 @@ steps: - commands: - apk add --update build-base - go clean -testcache - - go list -f '{{.Dir}}/...' -m | xargs go test -run IntegrationRedis -covermode=atomic - -timeout=2m + - ./scripts/go-workspace/test-includes.sh | xargs go test -run IntegrationRedis + -covermode=atomic -timeout=2m depends_on: - wire-install - wait-for-redis @@ -2620,8 +2620,8 @@ steps: - commands: - apk add --update build-base - go clean -testcache - - go list -f '{{.Dir}}/...' -m | xargs go test -run IntegrationMemcached -covermode=atomic - -timeout=2m + - ./scripts/go-workspace/test-includes.sh | xargs go test -run IntegrationMemcached + -covermode=atomic -timeout=2m depends_on: - wire-install - wait-for-memcached @@ -2974,8 +2974,8 @@ steps: name: wire-install - commands: - apk add --update build-base shared-mime-info shared-mime-info-lang - - go list -f '{{.Dir}}/...' -m | xargs go test -tags requires_buildifer -short -covermode=atomic - -timeout=5m + - ./scripts/go-workspace/test-includes.sh | xargs go test -tags requires_buildifer + -short -covermode=atomic -timeout=5m depends_on: - wire-install image: golang:1.22.4-alpine @@ -3237,8 +3237,8 @@ steps: - commands: - apk add --update build-base - go clean -testcache - - go list -f '{{.Dir}}/...' -m | xargs go test -run IntegrationRedis -covermode=atomic - -timeout=2m + - ./scripts/go-workspace/test-includes.sh | xargs go test -run IntegrationRedis + -covermode=atomic -timeout=2m depends_on: - wire-install - wait-for-redis @@ -3253,8 +3253,8 @@ steps: - commands: - apk add --update build-base - go clean -testcache - - go list -f '{{.Dir}}/...' -m | xargs go test -run IntegrationMemcached -covermode=atomic - -timeout=2m + - ./scripts/go-workspace/test-includes.sh | xargs go test -run IntegrationMemcached + -covermode=atomic -timeout=2m depends_on: - wire-install - wait-for-memcached @@ -4360,8 +4360,8 @@ steps: name: wire-install - commands: - apk add --update build-base shared-mime-info shared-mime-info-lang - - go list -f '{{.Dir}}/...' -m | xargs go test -tags requires_buildifer -short -covermode=atomic - -timeout=5m + - ./scripts/go-workspace/test-includes.sh | xargs go test -tags requires_buildifer + -short -covermode=atomic -timeout=5m depends_on: - wire-install image: golang:1.22.4-alpine @@ -4782,8 +4782,8 @@ steps: name: wire-install - commands: - apk add --update build-base shared-mime-info shared-mime-info-lang - - go list -f '{{.Dir}}/...' -m | xargs go test -tags requires_buildifer -short -covermode=atomic - -timeout=5m + - ./scripts/go-workspace/test-includes.sh | xargs go test -tags requires_buildifer + -short -covermode=atomic -timeout=5m depends_on: - wire-install image: golang:1.22.4-alpine @@ -5391,8 +5391,8 @@ steps: - commands: - apk add --update build-base - go clean -testcache - - go list -f '{{.Dir}}/...' -m | xargs go test -run IntegrationRedis -covermode=atomic - -timeout=2m + - ./scripts/go-workspace/test-includes.sh | xargs go test -run IntegrationRedis + -covermode=atomic -timeout=2m depends_on: - wire-install - wait-for-redis @@ -5407,8 +5407,8 @@ steps: - commands: - apk add --update build-base - go clean -testcache - - go list -f '{{.Dir}}/...' -m | xargs go test -run IntegrationMemcached -covermode=atomic - -timeout=2m + - ./scripts/go-workspace/test-includes.sh | xargs go test -run IntegrationMemcached + -covermode=atomic -timeout=2m depends_on: - wire-install - wait-for-memcached @@ -6079,6 +6079,6 @@ kind: secret name: gcr_credentials --- kind: signature -hmac: 3ec8f984961a401ed9785c3f537a725e1ba3912b713e1796561634d9c99f93ba +hmac: fa7d6043308457e09a7d952ef254d086eae29793c42de5139fde06f9cb574670 ... diff --git a/Makefile b/Makefile index 01850e3e708..1424ea96ce0 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ include .bingo/Variables.mk GO = go GO_VERSION = 1.22.4 GO_LINT_FILES ?= $(shell ./scripts/go-workspace/golangci-lint-includes.sh) +GO_TEST_FILES ?= $(shell ./scripts/go-workspace/test-includes.sh) SH_FILES ?= $(shell find ./scripts -name *.sh) GO_RACE := $(shell [ -n "$(GO_RACE)" -o -e ".go-race-enabled-locally" ] && echo 1 ) GO_RACE_FLAG := $(if $(GO_RACE),-race) @@ -235,7 +236,7 @@ test-go: test-go-unit test-go-integration .PHONY: test-go-unit test-go-unit: ## Run unit tests for backend with flags. @echo "test backend unit tests" - go list -f '{{.Dir}}/...' -m | xargs \ + printf '$(GO_TEST_FILES)' | xargs \ $(GO) test $(GO_RACE_FLAG) -short -covermode=atomic -timeout=30m .PHONY: test-go-integration diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index bdc419324be..5249f09348b 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -553,7 +553,7 @@ def test_backend_step(): # shared-mime-info and shared-mime-info-lang is used for exactly 1 test for the # mime.TypeByExtension function. "apk add --update build-base shared-mime-info shared-mime-info-lang", - "go list -f '{{.Dir}}/...' -m | xargs go test -tags requires_buildifer -short -covermode=atomic -timeout=5m", + "./scripts/go-workspace/test-includes.sh | xargs go test -tags requires_buildifer -short -covermode=atomic -timeout=5m", ], } @@ -1056,7 +1056,7 @@ def mysql_integration_tests_steps(hostname, version): def redis_integration_tests_steps(): cmds = [ "go clean -testcache", - "go list -f '{{.Dir}}/...' -m | xargs go test -run IntegrationRedis -covermode=atomic -timeout=2m", + "./scripts/go-workspace/test-includes.sh | xargs go test -run IntegrationRedis -covermode=atomic -timeout=2m", ] environment = { @@ -1081,7 +1081,7 @@ def remote_alertmanager_integration_tests_steps(): def memcached_integration_tests_steps(): cmds = [ "go clean -testcache", - "go list -f '{{.Dir}}/...' -m | xargs go test -run IntegrationMemcached -covermode=atomic -timeout=2m", + "./scripts/go-workspace/test-includes.sh | xargs go test -run IntegrationMemcached -covermode=atomic -timeout=2m", ] environment = { diff --git a/scripts/go-workspace/test-includes.sh b/scripts/go-workspace/test-includes.sh new file mode 100755 index 00000000000..6b9b2af8747 --- /dev/null +++ b/scripts/go-workspace/test-includes.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +DELIMITER="/... +" + +REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. +go run scripts/go-workspace/main.go list-submodules --path "${REPO_ROOT}/go.work" --delimiter "${DELIMITER}"