diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 02b6f9197..1124be871 100644 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -3,3 +3,10 @@ set -euo pipefail export GO_VERSION=$(cat .go-version) + +# addtional preparation for macos step +if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-agent-system-metrics" && "$BUILDKITE_STEP_KEY" == "macos-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 92caedf86..8fe962a66 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -32,6 +32,14 @@ steps: image: "${WINDOWS_AGENT_IMAGE}" artifact_paths: "*.xml" + - label: ":linux: Tests on MacOS" + key: macos-test + command: ".buildkite/scripts/run-linux-tests.sh junit-mac-report.xml" + agents: + provider: "orka" + imagePrefix: generic-13-ventura-arm + 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: "macos-test" + allow_failure: true diff --git a/.buildkite/scripts/common.sh b/.buildkite/scripts/common.sh index 93224f51c..5bf4ac36c 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 af1cf16b7..0cebb5e0e 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-report.xml -- -v ./... +gotestsum --format testname --junitfile "${junitfile:-junit-lin-report.xml}" -- -v ./... diff --git a/catalog-info.yaml b/catalog-info.yaml index 0da8d7ae2..285c3d2f3 100644 --- a/catalog-info.yaml +++ b/catalog-info.yaml @@ -37,6 +37,7 @@ spec: branch_configuration: "main v0.*" repository: elastic/elastic-agent-system-metrics 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