Skip to content

Commit

Permalink
add macos
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-ri committed Nov 16, 2023
1 parent 649a117 commit db3fa25
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -44,3 +52,5 @@ steps:
allow_failure: true
- step: "windows-test"
allow_failure: true
- step: "mac-test"
allow_failure: true
26 changes: 26 additions & 0 deletions .buildkite/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .buildkite/scripts/run-linux-tests.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
junitfile=$1 # filename for jnit annotation plugin

set -euo pipefail

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 ./...
1 change: 1 addition & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit db3fa25

Please sign in to comment.