[ci] add upload of test results to s3 (#63629)

The upload steps are non-blocking, should they
fail the workflow status will not be affected.

This commit also changes the way the test logs are created,
now each Makefile accepts `TEST_LOG_DIR` as an optional parameter,
defaulting to `./test-logs`. This allows the top level Makefile
to propagate the location for the sub modules to write their
junit output, such that the CI jobs do not need to track
which top level make target corresponds to which directory.
Instead a simple glob is used to grab all the xml JUNIT files.

This approach also allows more targets to be added or removed in the future
without modifying the CI job definitons. Another benefit is allowing
the caller to modify the output destination should we want to bundle
the files as job artifacts in the future.

Makes `TEST_LOG_DIR` an order only dep for all targets.
This commit is contained in:
Luke Okraszewski
2026-02-20 14:23:25 +00:00
committed by GitHub
parent 0131499a23
commit eea85f5f49
14 changed files with 130 additions and 41 deletions
@@ -0,0 +1,27 @@
name: Upload test metrics
description: Uploads test logs to s3. Designed to be used in test workflows after test execution.
# Requires 'write' on 'id-token'.
# Assumes default artifact location of "$GITHUB_WORKSPACE/test-logs/"
runs:
using: "composite"
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 # v5.0.0
id: aws-setup
if: always()
continue-on-error: true
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::278576220453:role/tf-ci-test-artifacts-upload-gha-role
role-session-name: gha-ci-test-artifacts-${{ github.event.repository.name }}-${{ github.run_number }}
role-duration-seconds: 900 # Minimum by policy.
- name: Normalize test results and push to s3
uses: gravitational/shared-workflows/tools/ci-normalize@b676318d4b4d54844f19a6fc59473b95962b1887 # tools/ci-normalize/v0.0.4
if: always() && steps.aws-setup.outcome == 'success'
continue-on-error: true # Do not fail the workflow
with:
s3-bucket: "s3://tp-278576220453-ci-test-artifacts-storage/ci-metrics"
junit-files: "$GITHUB_WORKSPACE/test-logs/*.xml"
tool-version: v0.0.4
@@ -97,3 +97,8 @@ jobs:
timeout-minutes: 10
run: |
runuser -u ci -g ci make e2e-aws RDPCLIENT_SKIP_BUILD=1
- name: Upload test metrics
if: always()
continue-on-error: true # Do not fail the workflow
uses: ./.github/actions/upload-test-metrics
@@ -42,6 +42,7 @@ jobs:
permissions:
contents: read
packages: read
id-token: write # required for AWS credentials
container:
image: ghcr.io/gravitational/teleport-buildbox:teleport19
@@ -82,3 +83,8 @@ jobs:
- name: Run tests
timeout-minutes: 40
run: runuser -u ci -g ci make integration RDPCLIENT_SKIP_BUILD=1
- name: Upload test metrics
if: always()
continue-on-error: true # Do not fail the workflow
uses: ./.github/actions/upload-test-metrics
@@ -41,6 +41,7 @@ jobs:
permissions:
contents: read
id-token: write # required for AWS credentials
container:
image: ghcr.io/gravitational/teleport-buildbox:teleport19
@@ -60,3 +61,8 @@ jobs:
timeout-minutes: 40
run: |
make integration-root RDPCLIENT_SKIP_BUILD=1
- name: Upload test metrics
if: always()
continue-on-error: true # Do not fail the workflow
uses: ./.github/actions/upload-test-metrics
@@ -47,6 +47,7 @@ jobs:
permissions:
contents: read
packages: read
id-token: write # required for AWS credentials
container:
image: ghcr.io/gravitational/teleport-buildbox:teleport19
@@ -100,9 +101,14 @@ jobs:
# load the image into the kind cluster
make load-image
cd -
cd -
- name: Run tests
timeout-minutes: 40
run: |
runuser -u ci -g ci make integration-kube RDPCLIENT_SKIP_BUILD=1
- name: Upload test metrics
if: always()
continue-on-error: true # Do not fail the workflow
uses: ./.github/actions/upload-test-metrics
+6
View File
@@ -34,6 +34,7 @@ jobs:
permissions:
contents: read
packages: read
id-token: write # required for AWS credentials
container:
image: ghcr.io/gravitational/teleport-buildbox:teleport19
@@ -71,3 +72,8 @@ jobs:
- name: Run tests
timeout-minutes: 20
run: make -j"$(nproc)" test-go test-sh test-api
- name: Upload test metrics
if: always()
continue-on-error: true # Do not fail the workflow
uses: ./.github/actions/upload-test-metrics
@@ -46,6 +46,7 @@ jobs:
permissions:
contents: read
id-token: write # required for AWS credentials
container:
image: ghcr.io/gravitational/teleport-buildbox:teleport19
@@ -89,3 +90,8 @@ jobs:
- name: Run teleport-usage tests
timeout-minutes: 15
run: make test-teleport-usage
- name: Upload test metrics
if: always()
continue-on-error: true # Do not fail the workflow
uses: ./.github/actions/upload-test-metrics
+19 -19
View File
@@ -284,7 +284,7 @@ KUBECONFIG ?=
TEST_KUBE ?=
export
TEST_LOG_DIR = ${abspath ./test-logs}
TEST_LOG_DIR ?= ${abspath ./test-logs}
# Set CGOFLAG and BUILDFLAGS as needed for the OS/ARCH.
ifeq ("$(OS)","linux")
@@ -971,21 +971,21 @@ test-env-leakage:
# Runs test prepare steps
.PHONY: test-go-prepare
test-go-prepare: ensure-webassets rdpclient $(TEST_LOG_DIR) $(VERSRC)
test-go-prepare: ensure-webassets rdpclient $(VERSRC) | $(TEST_LOG_DIR)
# Runs base unit tests
.PHONY: test-go-unit
test-go-unit: rdpclient
test-go-unit: FLAGS ?= -race -shuffle on
test-go-unit: SUBJECT ?= $(shell go list ./... | grep -vE 'teleport/(e2e|integration|tool/tsh|integrations/operator|integrations/access|integrations/lib)')
test-go-unit: test-go-prepare
test-go-unit: test-go-prepare | $(TEST_LOG_DIR)
$(CGOFLAG) go test -json -tags "$(PAM_TAG) $(RDPCLIENT_TAG) $(FIPS_TAG) $(BPF_TAG) $(LIBFIDO2_TEST_TAG) $(TOUCHID_TAG) $(PIV_TEST_TAG) $(VNETDAEMON_TAG) $(ADDTAGS)" $(PACKAGES) $(SUBJECT) $(FLAGS) $(ADDFLAGS) \
| $(GOTESTSUM) --junitfile $(TEST_LOG_DIR)/unit-tests.xml --jsonfile $(TEST_LOG_DIR)/unit-tests.json --raw-command -- cat
# Runs tbot unit tests
.PHONY: test-go-unit-tbot
test-go-unit-tbot: FLAGS ?= -race -shuffle on
test-go-unit-tbot:
test-go-unit-tbot: | $(TEST_LOG_DIR)
$(CGOFLAG) go test -json $(FLAGS) $(ADDFLAGS) ./tool/tbot/... ./lib/tbot/... \
| $(GOTESTSUM) --junitfile $(TEST_LOG_DIR)/unit-tests-tbot.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-tbot.json --raw-command -- cat
@@ -993,7 +993,7 @@ test-go-unit-tbot:
.PHONY: test-go-touch-id
test-go-touch-id: FLAGS ?= -race -shuffle on
test-go-touch-id: SUBJECT ?= ./lib/auth/touchid/...
test-go-touch-id: test-go-prepare
test-go-touch-id: test-go-prepare | $(TEST_LOG_DIR)
ifneq ("$(TOUCHID_TAG)", "")
$(CGOFLAG) go test -json $(PACKAGES) $(SUBJECT) $(FLAGS) $(ADDFLAGS) \
| $(GOTESTSUM) --junitfile $(TEST_LOG_DIR)/unit-tests-touchid.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-touchid.json --raw-command -- cat
@@ -1033,7 +1033,7 @@ test-go-bench-root: $(BENCHFIND) | $(TEST_LOG_DIR)
.PHONY: test-go-vnet-daemon
test-go-vnet-daemon: FLAGS ?= -race -shuffle on
test-go-vnet-daemon: SUBJECT ?= ./lib/vnet/daemon/...
test-go-vnet-daemon: test-go-prepare
test-go-vnet-daemon: test-go-prepare | $(TEST_LOG_DIR)
ifneq ("$(VNETDAEMON_TAG)", "")
$(CGOFLAG) go test -json $(PACKAGES) $(SUBJECT) $(FLAGS) $(ADDFLAGS) \
| $(GOTESTSUM) --junitfile $(TEST_LOG_DIR)/unit-tests-vnet.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-vnet.json --raw-command -- cat
@@ -1043,14 +1043,14 @@ endif
.PHONY: test-go-tsh
test-go-tsh: FLAGS ?= -race -shuffle on
test-go-tsh: SUBJECT ?= github.com/gravitational/teleport/tool/tsh/...
test-go-tsh: test-go-prepare
test-go-tsh: test-go-prepare | $(TEST_LOG_DIR)
$(CGOFLAG_TSH) go test -json -tags "$(PAM_TAG) $(FIPS_TAG) $(LIBFIDO2_TEST_TAG) $(TOUCHID_TAG) $(PIV_TEST_TAG) $(VNETDAEMON_TAG)" $(PACKAGES) $(SUBJECT) $(FLAGS) $(ADDFLAGS) \
| $(GOTESTSUM) --junitfile $(TEST_LOG_DIR)/unit-tests-tsh.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-tsh.json --raw-command -- cat
# Chaos tests have high concurrency, run without race detector and have TestChaos prefix.
.PHONY: test-go-chaos
test-go-chaos: CHAOS_FOLDERS = $(shell find . -type f -name '*chaos*.go' | xargs dirname | uniq)
test-go-chaos: test-go-prepare
test-go-chaos: test-go-prepare | $(TEST_LOG_DIR)
$(CGOFLAG) go test -json -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" -test.run=TestChaos $(CHAOS_FOLDERS) \
| $(GOTESTSUM) --junitfile $(TEST_LOG_DIR)/unit-tests-chaos.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-chaos.json --raw-command -- cat
@@ -1059,7 +1059,7 @@ test-go-chaos: test-go-prepare
#
UNIT_ROOT_REGEX := ^TestRoot
.PHONY: test-go-root
test-go-root: ensure-webassets rdpclient $(TEST_LOG_DIR)
test-go-root: ensure-webassets rdpclient | $(TEST_LOG_DIR)
test-go-root: FLAGS ?= -race -shuffle on
test-go-root: PACKAGES = $(shell go list $(ADDFLAGS) ./... | grep -v -e e2e -e integration -e integrations/operator)
test-go-root: $(VERSRC)
@@ -1070,7 +1070,7 @@ test-go-root: $(VERSRC)
# Runs Go tests on the api module. These have to be run separately as the package name is different.
#
.PHONY: test-api
test-api: $(VERSRC) $(TEST_LOG_DIR)
test-api: $(VERSRC) | $(TEST_LOG_DIR)
test-api: FLAGS ?= -race -shuffle on
test-api: SUBJECT ?= $(shell cd api && go list ./...)
test-api:
@@ -1083,24 +1083,24 @@ test-api:
#
.PHONY: test-operator
test-operator:
make -C integrations/operator test
make -C integrations/operator test TEST_LOG_DIR=$(TEST_LOG_DIR)
#
# Runs Teleport Terraform provider tests.
#
.PHONY: test-terraform-provider
test-terraform-provider:
make -C integrations test-terraform-provider
make -C integrations test-terraform-provider TEST_LOG_DIR=$(TEST_LOG_DIR)
#
# Runs Teleport MWI Terraform provider tests.
#
.PHONY: test-terraform-provider-mwi
test-terraform-provider-mwi:
make -C integrations test-terraform-provider-mwi
make -C integrations test-terraform-provider-mwi TEST_LOG_DIR=$(TEST_LOG_DIR)
#
# Runs Go tests on the integrations/kube-agent-updater module. These have to be run separately as the package name is different.
#
.PHONY: test-kube-agent-updater
test-kube-agent-updater: $(VERSRC) $(TEST_LOG_DIR)
test-kube-agent-updater: $(VERSRC) | $(TEST_LOG_DIR)
test-kube-agent-updater: FLAGS ?= -race -shuffle on
test-kube-agent-updater: SUBJECT ?= $(shell cd integrations/kube-agent-updater && go list ./...)
test-kube-agent-updater:
@@ -1123,7 +1123,7 @@ test-integrations-lib:
# Runs Go tests on the examples/teleport-usage module. These have to be run separately as the package name is different.
#
.PHONY: test-teleport-usage
test-teleport-usage: $(VERSRC) $(TEST_LOG_DIR)
test-teleport-usage: $(VERSRC) | $(TEST_LOG_DIR)
test-teleport-usage: FLAGS ?= -race -shuffle on
test-teleport-usage: SUBJECT ?= $(shell cd examples/teleport-usage && go list ./...)
test-teleport-usage:
@@ -1187,7 +1187,7 @@ run-etcd:
.PHONY: integration
integration: FLAGS ?= -v -race
integration: PACKAGES = $(shell go list ./... | grep 'integration\([^s]\|$$\)' | grep -v integrations/lib/testing/integration )
integration: $(TEST_LOG_DIR)
integration: | $(TEST_LOG_DIR)
@echo KUBECONFIG is: $(KUBECONFIG), TEST_KUBE: $(TEST_KUBE)
$(CGOFLAG) go test -timeout 30m -json -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" $(PACKAGES) $(FLAGS) \
| $(GOTESTSUM) --junitfile $(TEST_LOG_DIR)/unit-tests-integration.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-integration.json --raw-command -- cat
@@ -1200,7 +1200,7 @@ INTEGRATION_KUBE_REGEX := TestKube.*
.PHONY: integration-kube
integration-kube: FLAGS ?= -v -race
integration-kube: PACKAGES = $(shell go list ./... | grep 'integration\([^s]\|$$\)' | grep -v 'integration/autoupdate')
integration-kube: $(TEST_LOG_DIR)
integration-kube: | $(TEST_LOG_DIR)
@echo KUBECONFIG is: $(KUBECONFIG), TEST_KUBE: $(TEST_KUBE)
$(CGOFLAG) go test -json -run "$(INTEGRATION_KUBE_REGEX)" $(PACKAGES) $(FLAGS) \
| $(GOTESTSUM) --junitfile $(TEST_LOG_DIR)/unit-tests-integration-kube.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-integration-kube.json --raw-command -- cat
@@ -1213,7 +1213,7 @@ INTEGRATION_ROOT_REGEX := ^TestRoot
.PHONY: integration-root
integration-root: FLAGS ?= -v -race
integration-root: PACKAGES = $(shell go list ./... | grep 'integration\([^s]\|$$\)')
integration-root: $(TEST_LOG_DIR)
integration-root: | $(TEST_LOG_DIR)
$(CGOFLAG) go test -json -run "$(INTEGRATION_ROOT_REGEX)" $(PACKAGES) $(FLAGS) \
| $(GOTESTSUM) --junitfile $(TEST_LOG_DIR)/unit-tests-integration-root.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-integration-root.json --raw-command -- cat
@@ -1221,7 +1221,7 @@ integration-root: $(TEST_LOG_DIR)
.PHONY: e2e-aws
e2e-aws: FLAGS ?= -v -race
e2e-aws: PACKAGES = $(shell go list ./... | grep 'e2e/aws')
e2e-aws: $(TEST_LOG_DIR)
e2e-aws: | $(TEST_LOG_DIR)
@echo TEST_KUBE: $(TEST_KUBE) TEST_AWS_DB: $(TEST_AWS_DB)
$(CGOFLAG) go test -json $(PACKAGES) $(FLAGS) $(ADDFLAGS)\
| $(GOTESTSUM) --junitfile $(TEST_LOG_DIR)/unit-tests-e2e-aws.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-e2e-aws.json --raw-command -- cat
+15 -11
View File
@@ -1,22 +1,26 @@
TEST_LOG_DIR ?= ${abspath ./test-logs}
.PHONY: test
test: test-access test-lib test-event-handler test-terraform-provider test-terraform-provider-mwi
$(TEST_LOG_DIR):
mkdir $(TEST_LOG_DIR)
.PHONY: test-access
test-access:
gotestsum --junitfile unit-tests-integrations-access.xml --jsonfile unit-tests-integrations-access.json ./access/...
test-access: | $(TEST_LOG_DIR)
gotestsum --junitfile $(TEST_LOG_DIR)/unit-tests-integrations-access.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-integrations-access.json ./access/...
.PHONY: test-lib
test-lib:
gotestsum --junitfile unit-tests-integrations-lib.xml --jsonfile unit-tests-integrations-lib.json ./lib/...
test-lib: | $(TEST_LOG_DIR)
gotestsum --junitfile $(TEST_LOG_DIR)/unit-tests-integrations-lib.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-integrations-lib.json ./lib/...
.PHONY: test-event-handler
test-event-handler:
make -C event-handler test
test-event-handler: | $(TEST_LOG_DIR)
make -C event-handler test TEST_LOG_DIR=$(TEST_LOG_DIR)
.PHONY: test-terraform-provider
test-terraform-provider:
make -C terraform test
test-terraform-provider: | $(TEST_LOG_DIR)
make -C terraform test TEST_LOG_DIR=$(TEST_LOG_DIR)
.PHONY: test-terraform-provider-mwi
test-terraform-provider-mwi:
make -C terraform-mwi test
test-terraform-provider-mwi: | $(TEST_LOG_DIR)
make -C terraform-mwi test TEST_LOG_DIR=$(TEST_LOG_DIR)
+7 -2
View File
@@ -14,6 +14,7 @@ GENTERRAFORMPATH := $(shell go env GOPATH)/bin
BUILDDIR ?= build
BINARY = $(BUILDDIR)/teleport-event-handler
TEST_LOG_DIR ?= ${abspath ./test-logs}
GITREF ?= $(shell git describe --dirty --long --tags --match '$(VERSION)')
ADDFLAGS ?=
@@ -94,9 +95,13 @@ docker-publish: ## Publishes a docker image from the private ECR registry to the
install: build
go install
$(TEST_LOG_DIR):
mkdir $(TEST_LOG_DIR)
.PHONY: test
test:
gotestsum --junitfile unit-tests-event-handler.xml --jsonfile unit-tests-event-handler.json
test: | $(TEST_LOG_DIR)
gotestsum --junitfile $(TEST_LOG_DIR)/unit-tests-event-handler.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-event-handler.json
.PHONY: configure
configure: build
+6 -2
View File
@@ -7,10 +7,14 @@ include ../../build.assets/images.mk
# Configure which compiler and buildbox to use
OS ?= $(shell go env GOOS)
ARCH ?= $(shell go env GOARCH)
TEST_LOG_DIR ?= ${abspath ./test-logs}
.PHONY: test
test: pkg/img/cosign_fixtures_test.go
gotestsum --junitfile unit-tests-kube-agent-updater.xml --jsonfile unit-tests-kube-agent-updater.json
test: pkg/img/cosign_fixtures_test.go | $(TEST_LOG_DIR)
gotestsum --junitfile $(TEST_LOG_DIR)/unit-tests-kube-agent-updater.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-kube-agent-updater.json
$(TEST_LOG_DIR):
mkdir $(TEST_LOG_DIR)
.PHONY: docker-build
docker-build: ## Build docker image
+7 -2
View File
@@ -41,6 +41,8 @@ PLATFORM_BUILDBOX ?= $(BUILDBOX_ARM)
endif
endif
TEST_LOG_DIR ?= ${abspath ./test-logs}
.PHONY: all
all: build
@@ -165,9 +167,12 @@ debug-dump-request:
"$${proto}"; \
done
$(TEST_LOG_DIR):
mkdir $(TEST_LOG_DIR)
.PHONY: test
test: generate ## Run tests.
gotestsum --junitfile unit-tests-operator.xml --jsonfile unit-tests-operator.json
test: generate | $(TEST_LOG_DIR) ## Run tests.
gotestsum --junitfile $(TEST_LOG_DIR)/unit-tests-operator.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-operator.json
##@ Build
+6 -2
View File
@@ -7,6 +7,7 @@ TERRAFORM_ARCH=$(OS)_$(ARCH)
RELEASE = terraform-provider-teleportmwi-v$(VERSION)-$(OS)-$(ARCH)-bin
BUILDDIR ?= build
TEST_LOG_DIR ?= ${abspath ./test-logs}
ADDFLAGS ?=
BUILDFLAGS ?= $(ADDFLAGS) -trimpath -ldflags '-w -s'
@@ -56,9 +57,12 @@ release: build
endif
tar -C $(BUILDDIR) -czf $(RELEASE).tar.gz .
PHONY: test
$(TEST_LOG_DIR):
mkdir $(TEST_LOG_DIR)
PHONY: test | $(TEST_LOG_DIR)
test:
gotestsum --junitfile unit-tests-terraform-mwi.xml --jsonfile unit-tests-terraform-mwi.json
gotestsum --junitfile $(TEST_LOG_DIR)/unit-tests-terraform-mwi.xml --jsonfile $(TEST_LOG_DIR)/unit-tests-terraform-mwi.json
PHONY: testacc
testacc:
+7 -2
View File
@@ -5,6 +5,7 @@ PROTOC_GEN_TERRAFORM:= $(shell command -v protoc-gen-terraform)
BUILDDIR ?= build
TFDIR ?= example
TEST_LOG_DIR ?= ${abspath ./test-logs}
ADDFLAGS ?=
BUILDFLAGS ?= $(ADDFLAGS) -trimpath -ldflags '-w -s'
@@ -209,15 +210,19 @@ CURRENT_ULIMIT := $(shell ulimit -n)
TEST_ARGS?=
$(TEST_LOG_DIR):
mkdir $(TEST_LOG_DIR)
.PHONY: test
test: install
test: install | $(TEST_LOG_DIR)
ifndef TERRAFORM_EXISTS
@echo "Terraform v1.4+ is not installed (tfenv install 1.5.6 && tfenv use 1.5.6)."
terraform -version
@exit -1
endif
gotestsum --junitfile unit-tests-terraform.xml --jsonfile unit-tests-terraform.json -- ./testlib -v $(TEST_ARGS)
gotestsum --junitfile $(TEST_LOG_DIR)/unit-tests-terraform.xml --jsonfile unit-tests-terraform.json -- ./testlib -v $(TEST_ARGS)
.PHONY: test-full
test-full: TEST_ARGS=--tags enterprisetests