From db3fa257e8f99a3d80c2862b66d1c36625fead19 Mon Sep 17 00:00:00 2001 From: Svetlana <5437289+leo-ri@users.noreply.github.com> Date: Thu, 16 Nov 2023 19:07:44 +0100 Subject: [PATCH] add macos --- .buildkite/hooks/pre-command | 7 +++++++ .buildkite/pipeline.yml | 10 ++++++++++ .buildkite/scripts/common.sh | 26 ++++++++++++++++++++++++++ .buildkite/scripts/run-linux-tests.sh | 3 ++- catalog-info.yaml | 1 + 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index dc7d076efb..017a5c7dcc 100644 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -5,3 +5,10 @@ set -euo pipefail if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-agent-autodiscover" ]]; then export GO_VERSION=$(cat .go-version) fi + +# addtional preparation for macos step +if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-agent-autodiscover" && "$BUILDKITE_STEP_KEY" == "mac-test" ]]; then + echo "--- prepare env" + source .buildkite/scripts/common.sh + with_go ${GO_VERSION} ${SETUP_GVM_VERSION} +fi diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 58b9bdcd5d..44f3786ad5 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -32,6 +32,14 @@ steps: image: "${WINDOWS_AGENT_IMAGE}" artifact_paths: "*.xml" + - label: ":macos: Tests on MacOS" + key: mac-test + command: ".buildkite/scripts/junit-mac-report.xml.sh" + agents: + provider: "orka" + imagePrefix: generic-13-ventura-x64 + artifact_paths: "*.xml" + - label: ":junit: Junit annotate" plugins: - junit-annotate#v2.4.1: @@ -44,3 +52,5 @@ steps: allow_failure: true - step: "windows-test" allow_failure: true + - step: "mac-test" + allow_failure: true diff --git a/.buildkite/scripts/common.sh b/.buildkite/scripts/common.sh index 93224f51c4..5bf4ac36cf 100755 --- a/.buildkite/scripts/common.sh +++ b/.buildkite/scripts/common.sh @@ -23,6 +23,32 @@ install_go_dependencies() { done } +with_go() { + local go_version=$1 + local gvm_version=$2 + url=$(get_gvm_link "${gvm_version}") + WORKSPACE=${WORKSPACE:-"$(pwd)"} + mkdir -p "${WORKSPACE}/bin" + export PATH="${PATH}:${WORKSPACE}/bin" + retry 5 curl -L -o "${WORKSPACE}/bin/gvm" "${url}" + chmod +x "${WORKSPACE}/bin/gvm" + ls ${WORKSPACE}/bin/ + eval "$(gvm $go_version)" + go_path="$(go env GOPATH):$(go env GOPATH)/bin" + export PATH="${PATH}:${go_path}" + go version +} + +# for gvm link +get_gvm_link() { + local gvm_version=$1 + platform_type="$(uname)" + arch_type="$(uname -m)" + [[ ${arch_type} == "aarch64" ]] && arch_type="arm64" # gvm do not have 'aarch64' name for archetecture type + [[ ${arch_type} == "x86_64" ]] && arch_type="amd64" + echo "https://github.com/andrewkroh/gvm/releases/download/${gvm_version}/gvm-${platform_type}-${arch_type}" +} + retry() { local retries=$1 shift diff --git a/.buildkite/scripts/run-linux-tests.sh b/.buildkite/scripts/run-linux-tests.sh index 118049c741..2db1564b91 100755 --- a/.buildkite/scripts/run-linux-tests.sh +++ b/.buildkite/scripts/run-linux-tests.sh @@ -1,4 +1,5 @@ #!/bin/bash +junitfile=$1 # filename for jnit annotation plugin set -euo pipefail @@ -6,4 +7,4 @@ source .buildkite/scripts/common.sh install_go_dependencies -gotestsum --format testname --junitfile junit-linux-report.xml -- -v ./... +gotestsum --format testname --junitfile "${junitfile:-junit-linux-report.xml}" -- -v ./... diff --git a/catalog-info.yaml b/catalog-info.yaml index dd16d7c3e9..d8e7f0a80c 100644 --- a/catalog-info.yaml +++ b/catalog-info.yaml @@ -36,6 +36,7 @@ spec: spec: repository: elastic/elastic-agent-autodiscover pipeline_file: ".buildkite/pipeline.yml" + maximum_timeout_in_minutes: 60 provider_settings: build_pull_request_forks: false build_pull_requests: true # requires filter_enabled and filter_condition settings as below when used with buildkite-pr-bot