Skip to content
Closed
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
54 changes: 40 additions & 14 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

env:
DOCKER_COMPOSE_VERSION: "1.25.5"
DOCKER_REGISTRY: "docker.elastic.co"
DOCKER_IMAGE: "${DOCKER_REGISTRY}/observability-ci/fleet-server" # needs to rename for rollback
DOCKER_IMAGE_SHA_TAG: "git-${BUILDKITE_COMMIT:0:12}" # needs to rename for rollback, should be "git-${BUILDKITE_COMMIT:0:12}"
DOCKER_IMAGE_LATEST_TAG: "latest" # needs to rename for rollback
DOCKER_IMAGE_GIT_TAG: "${BUILDKITE_BRANCH}" # needs to rename for rollback
GO_AGENT_IMAGE: "golang:${GO_VERSION}"
TERRAFORM_VERSION: "1.6.4"

steps:
Expand All @@ -16,19 +10,15 @@ steps:
steps:
- label: ":white_check_mark: Run check-ci"
key: check-ci
command: "make check-ci"
command: ".buildkite/scripts/check_ci.sh"
agents:
image: "${GO_AGENT_IMAGE}"
cpu: "8"
memory: "4G"
provider: "gcp"

- label: ":building_construction: Run local build"
key: make-local
command: "make local"
command: ".buildkite/scripts/local_build.sh"
agents:
image: "${GO_AGENT_IMAGE}"
cpu: "8"
memory: "4G"
provider: "gcp"

- label: ":building_construction: Run local build: MacOS"
key: make-local-macos
Expand All @@ -43,6 +33,8 @@ steps:
- label: "Run go benchmark for PR branch"
key: "go-benchmark-pr"
command: ".buildkite/scripts/run_benchmark.sh pr"
env:
BENCHMARK_ARGS: "-count=8 -benchmem"
artifact_paths:
- build/next.out
- build/next.stat
Expand All @@ -51,8 +43,11 @@ steps:
machineType: "c2-standard-8"

- label: "Run go benchmark for ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}"
skip: true # FIXME: Temporarily disabled until mage is on main
key: "go-benchmark-base"
command: ".buildkite/scripts/run_benchmark.sh base"
env:
BENCHMARK_ARGS: "-count=8 -benchmem"
artifact_paths:
- build/base.out
- build/base.stat
Expand All @@ -61,6 +56,7 @@ steps:
machineType: "c2-standard-8"

- label: "Compare results"
skip: true # FIXME: Temporarily disabled until mage is on main
key: "go-benchmark-compare"
command: ".buildkite/scripts/run_benchmark.sh compare"
artifact_paths:
Expand Down Expand Up @@ -98,6 +94,20 @@ steps:
- build/*.xml
- build/coverage*.out

<<<<<<< HEAD
=======
- label: ":smartbear-testexecute: Run fips140=only unit tests"
key: unit-test-fips140-only
command: ".buildkite/scripts/unit_test_fipsonly.sh"
env:
FIPS: "true"
agents:
provider: "gcp"
artifact_paths:
- build/*.xml
- build/coverage*.out

>>>>>>> db5f46b (Convert Makefile to magefile.go (#4912))
- label: ":smartbear-testexecute: Run unit tests: MacOS 13"
key: unit-test-macos-13
command: ".buildkite/scripts/unit_test.sh"
Expand Down Expand Up @@ -128,8 +138,11 @@ steps:
- label: "E2E Test"
key: "e2e-test"
command: ".buildkite/scripts/e2e_test.sh"
<<<<<<< HEAD
env:
TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED: "true"
=======
>>>>>>> db5f46b (Convert Makefile to magefile.go (#4912))
agents:
provider: "gcp"
artifact_paths:
Expand Down Expand Up @@ -177,6 +190,13 @@ steps:

- label: ":gcloud: Cloud e2e Test"
key: "cloud-e2e-test"
env:
DOCKER_REGISTRY: "docker.elastic.co"
DOCKER_IMAGE: "docker.elastic.co/beats-ci/elastic-agent-cloud-fleet"
DOCKER_IMAGE_TAG: "pr-${BUILDKITE_PULL_REQUEST}-${BUILDKITE_COMMIT:0:12}"
SNAPSHOT: "true"
PLATFORMS: "linux/amd64"
TF_VAR_pull_request: "${BUILDKITE_PULL_REQUEST}"
command: ".buildkite/scripts/cloud_e2e_test.sh"
agents:
provider: "gcp"
Expand All @@ -192,6 +212,12 @@ steps:
- label: ":docker: Publish docker image"
key: "publish"
command: ".buildkite/scripts/build_push_docker_image.sh"
env:
DOCKER_REGISTRY: "docker.elastic.co"
DOCKER_IMAGE: "docker.elastic.co/observability-ci/fleet-server" # needs to rename for rollback
DOCKER_IMAGE_SHA_TAG: "git-${BUILDKITE_COMMIT:0:12}" # needs to rename for rollback, should be "git-${BUILDKITE_COMMIT:0:12}"
DOCKER_IMAGE_LATEST_TAG: "latest" # needs to rename for rollback
DOCKER_IMAGE_GIT_TAG: "${BUILDKITE_BRANCH}" # needs to rename for rollback
if: "build.env('BUILDKITE_PULL_REQUEST') == 'false' && build.env('BUILDKITE_BRANCH') == 'main'"
agents:
provider: "gcp"
Expand Down
12 changes: 9 additions & 3 deletions .buildkite/scripts/build_push_docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ set -euo pipefail

source .buildkite/scripts/common.sh

add_bin_path

with_go

with_mage

echo "Building the docker image..."
if ! docker pull -q ${DOCKER_IMAGE}:${DOCKER_IMAGE_SHA_TAG} 2> /dev/null; then
DOCKER_IMAGE_TAG="${DOCKER_IMAGE_SHA_TAG}"
DOCKER_IMAGE=${DOCKER_IMAGE} DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG} make build-and-push-docker
DOCKER_IMAGE=${DOCKER_IMAGE} DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG} mage docker:image docker:push
fi

if [[ "${DOCKER_IMAGE_GIT_TAG}" == "main" ]]; then
DOCKER_IMAGE=${DOCKER_IMAGE} DOCKER_IMAGE_TAG="${DOCKER_IMAGE_LATEST_TAG}" make build-and-push-docker
DOCKER_IMAGE=${DOCKER_IMAGE} DOCKER_IMAGE_TAG="${DOCKER_IMAGE_LATEST_TAG}" mage docker:image docker:push
elif [[ ${BUILDKITE_PULL_REQUEST} == "false" ]]; then
DOCKER_IMAGE=${DOCKER_IMAGE} DOCKER_IMAGE_TAG="${DOCKER_IMAGE_GIT_TAG}" make build-and-push-docker
DOCKER_IMAGE=${DOCKER_IMAGE} DOCKER_IMAGE_TAG="${DOCKER_IMAGE_GIT_TAG}" mage docker:image docker:push
fi
13 changes: 13 additions & 0 deletions .buildkite/scripts/check_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euo pipefail

source .buildkite/scripts/common.sh

add_bin_path

with_go

with_mage

mage check:ci
35 changes: 34 additions & 1 deletion .buildkite/scripts/cloud_e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,37 @@ with_Terraform

with_docker_compose

USER=fleetserverci make test-cloude2e
with_mage

cleanup() {
r=$?

if [ -f dev-tools/cloud/terraform/.terraform.lock.hcl ] ; then
echo "--- Deployment detected, running cleanup."
mage test:cloudE2EDown
else
echo "--- No deployment detected, skipping cleanup."
fi
exit $r
}
trap cleanup EXIT INT TERM

USER=fleetserverci mage docker:cover docker:customAgentImage docker:push test:cloudE2EUp
FLEET_SERVER_URL=$(terraform output --raw --state=dev-tools/cloud/terraform/terraform.tfstate fleet_url)
echo "Fleet server: \"${FLEET_SERVER_URL}\""
echo "Deployment ID: $(terraform output --raw --state=dev-tools/cloud/terraform/terraform.tfstate deployment_id)"

if [[ "${FLEET_SERVER_URL}" == "" ]]; then
message="FLEET_SERVER_URL is empty, cloud e2e tests cannot be executed"
if [[ "${CI}" == "true" ]]; then
buildkite-agent annotate \
"${message}" \
--context "ctx-cloude2e-test" \
--style "error"
fi
echo "${message}"
exit 0
fi

echo "--- Trigger cloud E2E test"
mage test:cloudE2ERun
29 changes: 19 additions & 10 deletions .buildkite/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ with_go() {
export PATH="${PATH}:$(go env GOPATH):$(go env GOPATH)/bin"
}

<<<<<<< HEAD
=======
with_msft_go() {
echo "Setting up microsoft/go"
create_workspace
check_platform_architeture
MSFT_DOWNLOAD_URL=https://aka.ms/golang/release/latest/go$(cat .go-version).${platform_type}-${arch_type}.tar.gz
retry 5 $(curl -sL -o - $MSFT_DOWNLOAD_URL | tar -xz -f - -C ${WORKSPACE})
export PATH="${PATH}:${WORKSPACE}/go/bin"
go version
which go
export PATH="${PATH}:$(go env GOPATH)/bin"
}

>>>>>>> db5f46b (Convert Makefile to magefile.go (#4912))
with_docker_compose() {
echo "Setting up the Docker-compose environment..."
create_workspace
Expand Down Expand Up @@ -136,17 +151,11 @@ download_mbp_packages_from_gcp_bucket() {
}

with_mage() {
local install_packages=(
"github.com/magefile/mage"
"github.com/elastic/go-licenser"
"golang.org/x/tools/cmd/goimports"
"github.com/jstemmer/go-junit-report"
"gotest.tools/gotestsum"
)
create_workspace
for pkg in "${install_packages[@]}"; do
go install "${pkg}@latest"
done
go install github.com/magefile/mage # uses go.mod implicitly
mage -clean
mage -version
which mage
}

cleanup() {
Expand Down
15 changes: 7 additions & 8 deletions .buildkite/scripts/dra_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ set -euo pipefail

source .buildkite/scripts/common.sh

add_bin_path

with_go

with_mage

FOLDER_PATH="build/distributions"
BASE_DIR="${WORKSPACE}/${FOLDER_PATH}"
DRA_OUTPUT="release-manager.out"
Expand All @@ -12,7 +18,7 @@ export TYPE=${1}
# DRA_BRANCH can be used for manually testing packaging with PRs
# e.g. define `DRA_BRANCH="main"` under Options/Environment Variables in the Buildkite UI after clicking new Build
export BRANCH="${DRA_BRANCH:="${BUILDKITE_BRANCH:=""}"}"
export VERSION="$(make get-version)"
export VERSION="$(mage getVersion)"

if [[ "${VERSION}" == *"-SNAPSHOT"* || "${VERSION}" == "" ]]; then
echo "The 'version' parameter is required and it cannot contain the suffix '-SNAPSHOT'."
Expand All @@ -24,14 +30,7 @@ if [[ "${PROJECT}" == "" ]]; then
exit 1
fi

add_bin_path

download_mbp_packages_from_gcp_bucket "${FOLDER_PATH}" "${TYPE}"

with_go

with_mage

export RM_VERSION="${VERSION}"

if [[ ${TYPE} == "snapshot" ]]; then
Expand Down
4 changes: 3 additions & 1 deletion .buildkite/scripts/e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ with_go

with_docker_compose

with_mage

echo "Starting the E2E tests..."
make test-e2e junit-report
mage test:e2e test:junitReport
4 changes: 3 additions & 1 deletion .buildkite/scripts/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ with_go

with_docker_compose

with_mage

echo "Starting the integration tests..."
make test-int junit-report
mage test:integration test:junitReport
8 changes: 7 additions & 1 deletion .buildkite/scripts/local_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ source .buildkite/scripts/common.sh
add_bin_path
with_go

make local
<<<<<<< HEAD
make local
=======
with_mage

mage build:local
>>>>>>> db5f46b (Convert Makefile to magefile.go (#4912))
4 changes: 2 additions & 2 deletions .buildkite/scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ with_mage
case "${TYPE}" in
"snapshot")
export SNAPSHOT=true
make release
mage build:release
;;
"staging")
make release
mage build:release
;;
*)
echo "The option is unsupported yet"
Expand Down
8 changes: 5 additions & 3 deletions .buildkite/scripts/release_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ add_bin_path

with_go

make docker-release
with_mage

mage docker:release

upload_packages_to_gcp_bucket "build/distributions/"

make test-release
mage test:release

make build-docker
mage docker:image
14 changes: 6 additions & 8 deletions .buildkite/scripts/run_benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ add_bin_path

with_go

with_mage

export TYPE=${1}
#export BRANCH="${BUILDKITE_BRANCH}"
export BENCHMARK_ARGS="-count=8 -benchmem"

if [[ ${TYPE} == "pr" ]]; then
echo "Starting the go benchmark for the pull request"
BENCH_BASE=next.out make benchmark
BENCH_BASE=next.out make benchstat | tee build/next.stat
BENCH_BASE=next.out mage test:benchmark
BENCH_BASE=next.out mage test:benchstat | tee build/next.stat
BENCH=$(cat build/next.out)
buildkite-agent annotate --style 'info' --context "gobench_pr" --append << _EOF_
#### Benchmark for pull request
Expand All @@ -34,8 +34,8 @@ fi
if [[ ${TYPE} == "base" ]]; then
echo "Starting the go benchmark for the pull request"
git checkout ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}
BENCH_BASE=base.out make benchmark
BENCH_BASE=base.out make benchstat | tee build/base.stat
BENCH_BASE=base.out mage test:benchmark
BENCH_BASE=base.out mage test:benchstat | tee build/base.stat
BENCH=$(cat build/base.out)
buildkite-agent annotate --style 'info' --context "gobench_base" --append << _EOF_
#### Benchmark for the ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}
Expand Down Expand Up @@ -93,5 +93,3 @@ Download <a href="artifact://build/full_report.json">full_report.json</a>
_EOF_
fi
fi


6 changes: 6 additions & 0 deletions .buildkite/scripts/unit_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ add_bin_path

with_go

with_mage

echo "Starting the unit tests..."
<<<<<<< HEAD
if [[ ${FIPS:-} == "true" ]]; then
make test-unit-fips junit-report
else
make test-unit junit-report
fi
=======
mage test:unit test:junitReport
>>>>>>> db5f46b (Convert Makefile to magefile.go (#4912))
Loading
Loading