Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buildkite: add test on macos #112

Merged
merged 5 commits into from
Nov 16, 2023
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
7 changes: 7 additions & 0 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -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
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: ":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:
Expand All @@ -44,3 +52,5 @@ steps:
allow_failure: true
- step: "windows-test"
allow_failure: true
- step: "macos-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-report.xml -- -v ./...
gotestsum --format testname --junitfile "${junitfile:-junit-lin-report.xml}" -- -v ./...
1 change: 1 addition & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down