Skip to content

Commit d2dcf16

Browse files
pazonejsoriano
andauthored
[CI] MacOS 13 Unit tests (#3253)
* [CI] MacOS 13 Unit tests * Fixed platform_type lowercase * [CI] Check CI & Build on MacOS 13 * [CI] Cross-pltform unit test artifacts * [CI] Cross-pltform unit test artifacts * [CI] Local build for MacOS * [CI] Local build for MacOS * Update Makefile Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co> --------- Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
1 parent fa63284 commit d2dcf16

File tree

5 files changed

+42
-11
lines changed

5 files changed

+42
-11
lines changed

.buildkite/pipeline.yml

+24-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ steps:
3131
cpu: "8"
3232
memory: "4G"
3333

34+
- label: ":building_construction: Run local build: MacOS"
35+
key: make-local-macos
36+
command: ".buildkite/scripts/local_build.sh"
37+
agents:
38+
provider: orka
39+
imagePrefix: generic-13-ventura-arm
40+
3441
- group: "Performance test"
3542
key: "performance-test"
3643
steps:
@@ -77,7 +84,17 @@ steps:
7784
provider: "gcp"
7885
artifact_paths:
7986
- build/*.xml
80-
- build/coverage.out
87+
- build/coverage*.out
88+
89+
- label: ":smartbear-testexecute: Run unit tests: MacOS 13"
90+
key: unit-test-macos-13
91+
command: ".buildkite/scripts/unit_test.sh"
92+
agents:
93+
provider: orka
94+
imagePrefix: generic-13-ventura-arm
95+
artifact_paths:
96+
- build/*.xml
97+
- build/coverage*.out
8198

8299
- label: ":smartbear-testexecute: Run integration tests"
83100
key: int-test
@@ -105,6 +122,8 @@ steps:
105122
depends_on:
106123
- step: "unit-test"
107124
allow_failure: true
125+
- step: "unit-test-macos-13"
126+
allow_failure: true
108127
- step: "int-test"
109128
allow_failure: true
110129
- step: "e2e-test"
@@ -116,14 +135,16 @@ steps:
116135
agents:
117136
image: "docker.elastic.co/cloud-ci/sonarqube/buildkite-scanner:latest"
118137
command:
119-
- "buildkite-agent artifact download build/*coverage.out ."
120-
- "buildkite-agent artifact download build/test-unit.out.xml ."
138+
- "buildkite-agent artifact download build/*coverage*.out ."
139+
- "buildkite-agent artifact download build/test-unit*.out.xml ."
121140
- "/scan-source-code.sh"
122141
depends_on:
123142
- step: "unit-test"
124143
allow_failure: false
125144
- step: "e2e-test"
126145
allow_failure: false
146+
- step: "unit-test-macos-13"
147+
allow_failure: false
127148

128149
- label: ":gcloud: Cloud e2e Test"
129150
key: "cloud-e2e-test"

.buildkite/scripts/common.sh

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ set -euo pipefail
55
WORKSPACE="$(pwd)/bin"
66
TMP_FOLDER_TEMPLATE_BASE="tmp.fleet-server"
77
REPO="fleet-server"
8-
platform_type="$(uname)"
9-
platform_type_lowercase="${platform_type,,}"
8+
platform_type=$(uname | tr '[:upper:]' '[:lower:]')
109
hw_type="$(uname -m)"
1110

1211
check_platform_architeture() {
@@ -43,7 +42,7 @@ with_go() {
4342
echo "Setting up the Go environment..."
4443
create_workspace
4544
check_platform_architeture
46-
retry 5 curl -sL -o ${WORKSPACE}/gvm "https://github.com/andrewkroh/gvm/releases/download/${SETUP_GVM_VERSION}/gvm-${platform_type_lowercase}-${arch_type}"
45+
retry 5 curl -sL -o ${WORKSPACE}/gvm "https://github.com/andrewkroh/gvm/releases/download/${SETUP_GVM_VERSION}/gvm-${platform_type}-${arch_type}"
4746
chmod +x ${WORKSPACE}/gvm
4847
eval "$(gvm $(cat .go-version))"
4948
go version
@@ -54,7 +53,7 @@ with_go() {
5453
with_docker_compose() {
5554
echo "Setting up the Docker-compose environment..."
5655
create_workspace
57-
retry 5 curl -sSL -o ${WORKSPACE}/docker-compose "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-${platform_type_lowercase}-${hw_type}"
56+
retry 5 curl -sSL -o ${WORKSPACE}/docker-compose "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-${platform_type}-${hw_type}"
5857
chmod +x ${WORKSPACE}/docker-compose
5958
docker-compose version
6059
}
@@ -88,7 +87,7 @@ with_Terraform() {
8887
local path_to_file="${WORKSPACE}/terraform.zip"
8988
create_workspace
9089
check_platform_architeture
91-
retry 5 curl -sSL -o ${path_to_file} "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${platform_type_lowercase}_${arch_type}.zip"
90+
retry 5 curl -sSL -o ${path_to_file} "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${platform_type}_${arch_type}.zip"
9291
unzip -q ${path_to_file} -d ${WORKSPACE}/
9392
rm ${path_to_file}
9493
chmod +x ${WORKSPACE}/terraform

.buildkite/scripts/local_build.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
source .buildkite/scripts/common.sh
6+
add_bin_path
7+
with_go
8+
9+
make local

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ endif
6262
# Directory to dump build tools into
6363
GOBIN=$(shell go env GOPATH)/bin/
6464

65+
OS_NAME:=$(shell uname -s)
66+
6567
.PHONY: help
6668
help: ## - Show help message
6769
@printf "${CMD_COLOR_ON} usage: make [target]\n\n${CMD_COLOR_OFF}"
@@ -158,7 +160,7 @@ test-release: ## - Check that all release binaries are created
158160

159161
.PHONY: test-unit
160162
test-unit: prepare-test-context ## - Run unit tests only
161-
set -o pipefail; go test ${GO_TEST_FLAG} -v -race -coverprofile=build/coverage.out ./... | tee build/test-unit.out
163+
set -o pipefail; go test ${GO_TEST_FLAG} -v -race -coverprofile=build/coverage-${OS_NAME}.out ./... | tee build/test-unit-${OS_NAME}.out
162164

163165
.PHONY: benchmark
164166
benchmark: prepare-test-context install-benchstat ## - Run benchmark tests only

sonar-project.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ sonar.exclusions=**/*_test.go, .git/**, dev-tools/**, /magefile.go, changelog/**
66
sonar.tests=.
77
sonar.test.inclusions=**/*_test.go
88

9-
sonar.go.tests.reportPaths=build/test-unit.out.xml
10-
sonar.go.coverage.reportPaths=**/build/coverage.out,**/build/e2e-coverage.out
9+
sonar.go.tests.reportPaths=build/test-unit*.out.xml
10+
sonar.go.coverage.reportPaths=**/build/coverage*.out,**/build/e2e-coverage.out
1111
sonar.go.exclusions=**/vendor/**,**/*_mock.go
1212

1313
sonar.sourceEncoding=UTF-8

0 commit comments

Comments
 (0)