Skip to content

Commit

Permalink
Buildkite: add test on macos (#112)
Browse files Browse the repository at this point in the history
## What does this PR do? Why is it important?
to complete migration to BK (Jenkins job had tests on macos) 

## Checklist

- [x] My code follows the style guidelines of this project
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added an entry in `CHANGELOG.md`


## Related issues
- Relates [#1711](https://github.com/elastic/ingest-dev/issues/1711)

____
windows and MacOS are failing:
#109
  • Loading branch information
leo-ri authored Nov 16, 2023
1 parent 07870d6 commit c117bd8
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 @@ -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

0 comments on commit c117bd8

Please sign in to comment.