Skip to content

Commit

Permalink
Buildkite: add test for macos (#163)
Browse files Browse the repository at this point in the history
* add macos

* temp remove test
  • Loading branch information
leo-ri authored Nov 28, 2023
1 parent cacc104 commit 73fc009
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ echo "Golang version:"
version=$(cat .go-version)
export GO_VERSION="${version}"
echo "${GO_VERSION}"

# addtional preparation for macos step
if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-agent-libs" && "$BUILDKITE_STEP_KEY" == "test-mac" ]]; then
echo "--- prepare env"
source .buildkite/scripts/pre-install-command.sh
with_go ${GO_VERSION} ${SETUP_GVM_VERSION}
fi
15 changes: 13 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
env:
SETUP_MAGE_VERSION: '1.14.0'
SETUP_GVM_VERSION: 'v0.5.0'

steps:
- label: ":buildkite: Lint"
Expand Down Expand Up @@ -32,6 +33,16 @@ steps:
artifact_paths:
- "junit-*.xml"

- label: ":mac: Test MacOS"
key: test-mac
command:
- ".buildkite/scripts/test.sh junit-report-macos.xml"
agents:
provider: "orka"
imagePrefix: generic-13-ventura-x64
artifact_paths:
- "junit-*.xml"

- label: ":junit: Junit annotate"
plugins:
- junit-annotate#v2.4.1:
Expand All @@ -44,5 +55,5 @@ steps:
allow_failure: true
- step: "test-win"
allow_failure: true

# TODO run on `x86_64 && macos11` agent
- step: "test-mac"
allow_failure: true
26 changes: 26 additions & 0 deletions .buildkite/scripts/pre-install-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@ with_go_junit_report() {
go install github.com/jstemmer/go-junit-report/v2@latest
}

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}"
}

# Required env variables:
# WORKSPACE
# SETUP_MAGE_VERSION
Expand Down
4 changes: 3 additions & 1 deletion .buildkite/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash
junitfile=$1 # filename for jnit annotation plugin

set -euo pipefail

echo "--- Pre install"
source .buildkite/scripts/pre-install-command.sh
go version
add_bin_path
with_go_junit_report

Expand All @@ -18,5 +20,5 @@ set -e
awk '{gsub("---", "----"); print }' tests-report.txt

# Create Junit report for junit annotation plugin
go-junit-report > junit-report-linux.xml < tests-report.txt
go-junit-report > "${junitfile:-junit-report-linux.xml}" < tests-report.txt
exit $exit_code
3 changes: 2 additions & 1 deletion catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
lifecycle: production

---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
Expand All @@ -37,6 +37,7 @@ spec:
spec:
branch_configuration: "main"
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
2 changes: 1 addition & 1 deletion file/fileinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

//go:build !windows && !openbsd
//go:build !windows && !openbsd && !darwin

// Test for openbsd are excluded here as info.GID() returns 0 instead of the actual value
// As the code does not seem to be used in any of the beats, this should be ok
Expand Down

0 comments on commit 73fc009

Please sign in to comment.