Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,34 @@ steps:
mount-buildkite-agent: true
run: lint

# Send git commit metadata to the Test Engine plan-metadata pipeline on
# every build. Plan output is discarded -- the Tests and Coverage group
# below continues to use its declared parallelism. This step has no
# depends_on and no dependents, and is soft_fail, so a Test Engine API
# hiccup never blocks the build.
#
# Runs inside the `agent` compose service so bktec's gotest runner has
# `go` on PATH (needed for `go list ./...` package discovery) and the
# Test Engine API token is forwarded (declared in docker-compose.yml).
# See TE-5828.
- name: ":test_tube: Collect commit metadata"
key: collect-commit-metadata
command: .buildkite/steps/collect-commit-metadata.sh
soft_fail: true
env:
BUILDKITE_TEST_ENGINE_SUITE_SLUG: buildkite-agent
BUILDKITE_TEST_ENGINE_TEST_RUNNER: gotest
# Test Engine API rejects parallelism = 0 even on metadata-only plan
# requests. See TE-5766 verification on bk/bk-rspec.
BUILDKITE_TEST_ENGINE_MAX_PARALLELISM: "2"
BUILDKITE_TEST_ENGINE_TARGET_TIME: "1m"
plugins:
- docker-compose#v4.14.0:
config: .buildkite/docker-compose.yml
cli-version: 2
propagate-environment: true
run: agent

- group: ":go::scientist: Tests and Coverage"
if_changed:
- go.{mod,sum}
Expand Down
58 changes: 58 additions & 0 deletions .buildkite/steps/collect-commit-metadata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# Collect git commit metadata via `bktec plan --collect-git-metadata`.
#
# This is a metadata-only side-channel for the buildkite-agent Test Engine
# suite. The plan output is discarded -- the existing test steps continue to
# use their declared `parallelism:` values unchanged. The only purpose of this
# step is to ship commit / branch / diff metadata to the Test Engine plan
# metadata pipeline on every build.
#
# See TE-5828 (and the bk/bk-rspec reference implementation in TE-5766) for
# context. The step is soft-failed at the pipeline level so a Test Engine API
# hiccup never blocks the build.
#
# Runs inside the `agent` docker-compose service (see
# .buildkite/docker-compose.yml), which is a linux/amd64+arm64 golang image.
# The service provides `go` on PATH for bktec's gotest runner (which shells
# out to `go list ./...` to discover packages) and forwards
# BUILDKITE_TEST_ENGINE_API_ACCESS_TOKEN into the container.
#
# bktec is downloaded fresh each run from the test-engine-client GitHub
# release. The agent repo's go.mod pins test-engine-client v1.6.0 for use as
# a `go tool` on the runtime test path; that v1 shape predates the `plan`
# subcommand and is intentionally left untouched here. A future change should
# unify both call sites on a single bktec version.

set -euo pipefail

BKTEC_VERSION="${BKTEC_VERSION:-2.5.0}"

echo "+++ :test_tube: Installing bktec v${BKTEC_VERSION}"

case "$(uname -m)" in
x86_64) arch=amd64 ;;
aarch64|arm64) arch=arm64 ;;
*)
echo "Unsupported architecture: $(uname -m)" >&2
exit 1
;;
esac

bindir="$(mktemp -d)"
url="https://github.com/buildkite/test-engine-client/releases/download/v${BKTEC_VERSION}/bktec_${BKTEC_VERSION}_linux_${arch}"

curl --fail --silent --show-error --location --output "${bindir}/bktec" "${url}"
chmod +x "${bindir}/bktec"
export PATH="${bindir}:${PATH}"

bktec --version

echo "+++ :test_tube: Collecting git commit metadata via bktec plan (discarded)"

# bktec needs a writable RESULT_PATH for plan output config validation. The
# --json output is redirected to /dev/null below so this file is never read.
export BUILDKITE_TEST_ENGINE_RESULT_PATH=/tmp/bktec-plan-metadata.json

BKTEC_PREVIEW_SELECTION=1 bktec plan --json --collect-git-metadata > /dev/null

echo "Plan request issued -- git commit metadata sent to Test Engine."