From 8ca8a806cb36148a24f093bfc86c4518ea826e98 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Tue, 3 Sep 2024 12:08:50 +0200 Subject: [PATCH] [CI] Add some more steps to test on Macos ARM (#2030) Added a new step in the CI pipeline to test to build packages using elastic-package build command in MacOS ARM VMs. Doing that allows us to check that the at least can be executed this command in that platform and architecture. --- .../pipeline.trigger.integration.tests.sh | 15 +++++-- .buildkite/scripts/integration_tests.sh | 13 ++++-- Makefile | 3 ++ scripts/test-install-zip.sh | 4 +- scripts/test-just-build-zip.sh | 41 +++++++++++++++++++ 5 files changed, 66 insertions(+), 10 deletions(-) create mode 100755 scripts/test-just-build-zip.sh diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index e7f8ba76d..3addbe9cd 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -85,8 +85,7 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do echo " - build/test-results/*.xml" echo " - build/test-coverage/coverage-*.xml" # these files should not be used to compute the final coverage of elastic-package done - - popd > /dev/null +popd > /dev/null pushd test/packages/parallel > /dev/null for independent_agent in false true; do @@ -127,7 +126,6 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do echo " - build/test-coverage/coverage-*.xml" # these files should not be used to compute the final coverage of elastic-package done done - popd > /dev/null echo " - label: \":go: Integration test: build-zip\"" @@ -139,6 +137,17 @@ echo " artifact_paths:" echo " - build/elastic-stack-dump/build-zip/logs/*.log" echo " - build/packages/*.sig" +# TODO: Missing docker & docker-compose in MACOS ARM agent image, skip installation of packages in the meantime. +# If docker and docker-compose are available for this platform/architecture, it could be added a step to test the stack commands (or even replace this one). +echo " - label: \":macos: :go: Integration test: build-zip\"" +echo " command: ./.buildkite/scripts/integration_tests.sh -t test-just-build-zip" +echo " agents:" +echo " provider: \"orka\"" +echo " imagePrefix: \"${MACOS_ARM_AGENT_IMAGE}\"" +echo " artifact_paths:" +echo " - build/elastic-stack-dump/build-zip/logs/*.log" +echo " - build/packages/*.sig" + echo " - label: \":go: Integration test: install-zip\"" echo " command: ./.buildkite/scripts/integration_tests.sh -t test-install-zip" echo " agents:" diff --git a/.buildkite/scripts/integration_tests.sh b/.buildkite/scripts/integration_tests.sh index ffe259c43..2c30000be 100755 --- a/.buildkite/scripts/integration_tests.sh +++ b/.buildkite/scripts/integration_tests.sh @@ -31,6 +31,8 @@ PARALLEL_TARGET="test-check-packages-parallel" FALSE_POSITIVES_TARGET="test-check-packages-false-positives" KIND_TARGET="test-check-packages-with-kind" SYSTEM_TEST_FLAGS_TARGET="test-system-test-flags" +TEST_JUST_BUILD_ZIP_TARGET="test-just-build-zip" + GOOGLE_CREDENTIALS_FILENAME="google-cloud-credentials.json" REPO_NAME=$(repo_name "${BUILDKITE_REPO}") @@ -80,11 +82,14 @@ if [[ "$SERVERLESS" == "false" ]]; then echo "--- install go" with_go - echo "--- install docker" - with_docker + if [[ "${TARGET}" != "${TEST_JUST_BUILD_ZIP_TARGET}" ]]; then + # Not supported in Macos ARM + echo "--- install docker" + with_docker - echo "--- install docker-compose plugin" - with_docker_compose_plugin + echo "--- install docker-compose plugin" + with_docker_compose_plugin + fi fi if [[ "${TARGET}" == "${FALSE_POSITIVES_TARGET}" ]]; then diff --git a/Makefile b/Makefile index 00eba52ad..ba7818587 100644 --- a/Makefile +++ b/Makefile @@ -109,6 +109,9 @@ test-check-packages-with-custom-agent: test-build-zip: ./scripts/test-build-zip.sh +test-just-build-zip: + ./scripts/test-just-build-zip.sh + test-install-zip: ./scripts/test-install-zip.sh diff --git a/scripts/test-install-zip.sh b/scripts/test-install-zip.sh index 60621bdbb..f10bda209 100755 --- a/scripts/test-install-zip.sh +++ b/scripts/test-install-zip.sh @@ -46,14 +46,13 @@ installAndVerifyPackage() { } usage() { - echo "${0} [-s] [-h]" + echo "${0} [-s] [-v ] [-h]" echo "Run test-install-zip suite" echo -e "\t-s: Use elastic-package stack shellinit to export environment variablles. By default, they should be exported manually." echo -e "\t-v : Speciy which Elastic Stack version to use. If not specified it will use the default version in elastic-package." echo -e "\t-h: Show this message" } - USE_SHELLINIT=0 STACK_VERSION="default" while getopts ":sv:h" o; do @@ -81,7 +80,6 @@ while getopts ":sv:h" o; do esac done - ARG_VERSION="" if [ "${STACK_VERSION}" != "default" ]; then ARG_VERSION="--version ${STACK_VERSION}" diff --git a/scripts/test-just-build-zip.sh b/scripts/test-just-build-zip.sh new file mode 100755 index 000000000..bdd382cbb --- /dev/null +++ b/scripts/test-just-build-zip.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +set -euxo pipefail + +cleanup() { + r=$? + + # Clean used resources + for d in test/packages/*/*/; do + elastic-package clean -C "$d" -v + done + + exit $r +} + +testype() { + basename "$(dirname "$1")" +} + +trap cleanup EXIT + +OLDPWD=$PWD +# Build packages +export ELASTIC_PACKAGE_SIGNER_PRIVATE_KEYFILE="$OLDPWD/scripts/gpg-private.asc" +ELASTIC_PACKAGE_SIGNER_PASSPHRASE=$(cat "$OLDPWD/scripts/gpg-pass.txt") +export ELASTIC_PACKAGE_SIGNER_PASSPHRASE +ELASTIC_PACKAGE_LINKS_FILE_PATH="$(pwd)/scripts/links_table.yml" +export ELASTIC_PACKAGE_LINKS_FILE_PATH + +go run ./scripts/gpgkey + +for d in test/packages/*/*/; do + # Packages in false_positives can have issues. + if [ "$(testype $d)" == "false_positives" ]; then + continue + fi + elastic-package build -C "$d" --zip --sign -v +done + +# Remove unzipped built packages, leave .zip files +rm -r build/packages/*/