diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 1f4c846c..a9c8fa39 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -16,8 +16,13 @@ cd elastic-otel-php ``` This script will configure the project and build the libraries for the linux-x86-64 architecture. Adding the interactive argument allows you to interrupt the build using the `Ctrl + C` combination, and with the ncpu option, you can build in parallel using the specified number of processor threads. -If you are not adding new files to the project and just want to rebuild your changes, you can provide the `--skip_configure` argument - this will save time on reconfiguring the project. You can also save a lot of time by creating a local cache for Conan packages; the files will then be stored outside the container and reused repeatedly. To do this, provide a path to the `--conan_user_home` argument, e.g., `~/.conan`. The scipt will automatically execute native unit tests just after the build. - +If you are not adding new files to the project and just want to rebuild your changes, +you can provide the `--skip_configure` argument - this will save time on reconfiguring the project. +You can also save a lot of time by creating a local cache for Conan packages; +the files will then be stored outside the container and reused repeatedly. +To do this, provide a path to the `--conan_cache_path` argument, e.g., `~/.conan_cache`. +The script will automatically execute native unit tests just after the build. +If you would like to skip native unit tests you can use `--skip_unit_tests` command line option. Currently, we support the following architectures: diff --git a/tests/ElasticOTelTests/ComponentTests/UtilTests/ComponentTestsUtilComponentTest.php b/tests/ElasticOTelTests/ComponentTests/UtilTests/ComponentTestsUtilComponentTest.php index 496ecf2b..20a60259 100644 --- a/tests/ElasticOTelTests/ComponentTests/UtilTests/ComponentTestsUtilComponentTest.php +++ b/tests/ElasticOTelTests/ComponentTests/UtilTests/ComponentTestsUtilComponentTest.php @@ -139,12 +139,6 @@ private static function unsetLogLevelRelatedEnvVars(): array */ public function testRunAndEscalateLogLevelOnFailure(MixedMap $testArgs): void { - // TODO: Re-enable ComponentTestsUtilComponentTest::testRunAndEscalateLogLevelOnFailure - // Temporarily disable this test since it's flaky - if (self::dummyAssert()) { - return; - } - $logLevelRelatedEnvVarsToRestore = self::unsetLogLevelRelatedEnvVars(); $prodCodeSyslogLevelEnvVarName = OptionForProdName::log_level_syslog->toEnvVarName(); $initialLogLevelForProdCode = $testArgs->getLogLevel(self::LOG_LEVEL_FOR_PROD_CODE_KEY); diff --git a/tools/build/build_native.sh b/tools/build/build_native.sh index a3362e4f..b27cc8ea 100755 --- a/tools/build/build_native.sh +++ b/tools/build/build_native.sh @@ -5,18 +5,18 @@ set -x SKIP_CONFIGURE=false show_help() { - echo "Usage: $0 --build_architecture [--ncpu ] [--conan_user_home ] [--skip_configure] [--skip_unit_tests]" + echo "Usage: $0 --build_architecture [--ncpu ] [--conan_cache_path ] [--skip_configure] [--skip_unit_tests]" echo echo "Arguments:" - echo " --build_architecture Required. Build architecture (e.g., 'linux-x86-64')." - echo " --ncpu Optional. Number of CPUs to use for building. Default is one less than the installed CPUs." - echo " --conan_user_home Optional. Path to local user cache for Conan." - echo " --skip_configure Optional. Skip the configuration step." - echo " --interactive Optional. Run container in interactive mode." - echo " --skip_unit_tests Optional. Skip unit tests. Default is to run unit tests." + echo " --build_architecture Required. Build architecture (e.g., 'linux-x86-64')." + echo " --ncpu Optional. Number of CPUs to use for building. Default is one less than the installed CPUs." + echo " --conan_cache_path Optional. Path to local cache for Conan." + echo " --skip_configure Optional. Skip the configuration step." + echo " --interactive Optional. Run container in interactive mode." + echo " --skip_unit_tests Optional. Skip unit tests. Default is to run unit tests." echo echo "Example:" - echo " $0 --build_architecture linux-x86-64 --ncpu 4 --conan_user_home ~/ --skip_configure" + echo " $0 --build_architecture linux-x86-64 --ncpu 4 --conan_cache_path ~/.conan_cache --skip_configure" } parse_args() { @@ -30,8 +30,8 @@ parse_args() { NCPU=" -j$2 " shift ;; - --conan_user_home) - REPLACE_CONAN_USER_HOME="$2" + --conan_cache_path) + CONAN_CACHE_PATH="$2" shift ;; --skip_configure) @@ -65,12 +65,13 @@ if [[ -z "$BUILD_ARCHITECTURE" ]]; then exit 1 fi -# Building mount point and environment if $REPLACE_CONAN_USER_HOME not empty -if [[ -n "$REPLACE_CONAN_USER_HOME" ]]; then - echo "CONAN_USER_HOME: ${REPLACE_CONAN_USER_HOME}" +# Building mount point and environment if ${CONAN_CACHE_PATH} not empty +if [[ -n "${CONAN_CACHE_PATH}" ]]; then + echo "CONAN_CACHE_PATH: ${CONAN_CACHE_PATH}" # due safety not mounting user home folder but only .conan - mkdir -p ${REPLACE_CONAN_USER_HOME}/.conan - CONAN_USER_HOME_MP="-e CONAN_USER_HOME="${REPLACE_CONAN_USER_HOME}" -v "${REPLACE_CONAN_USER_HOME}/.conan:${REPLACE_CONAN_USER_HOME}/.conan"" + mkdir -p "${CONAN_CACHE_PATH}" + # https://docs.conan.io/2/reference/environment.html#conan-home + CONAN_HOME_MP=(-e "CONAN_HOME=/conan_home" -v "${CONAN_CACHE_PATH}:/conan_home") fi echo "BUILD_ARCHITECTURE: $BUILD_ARCHITECTURE" @@ -98,9 +99,9 @@ fi ls -al "${PWD}" docker run --rm -t ${INTERACTIVE} ${USERID} -v ${PWD}:/source \ - ${CONAN_USER_HOME_MP} \ + "${CONAN_HOME_MP[@]}" \ -w /source/prod/native \ -e GITHUB_SHA=${GITHUB_SHA} \ elasticobservability/apm-agent-php-dev:native-build-gcc-14.2.0-${BUILD_ARCHITECTURE}-0.0.1 \ - sh -c "id && echo CONAN_USER_HOME=\$CONAN_USER_HOME && ${CONFIGURE} cmake --build --preset ${BUILD_ARCHITECTURE}-release ${NCPU} && ${UNIT_TESTS}" + sh -c "id && echo CONAN_HOME: \$CONAN_HOME && ${CONFIGURE} cmake --build --preset ${BUILD_ARCHITECTURE}-release ${NCPU} && ${UNIT_TESTS}" diff --git a/tools/build/build_php_deps.sh b/tools/build/build_php_deps.sh index 8352961d..64ae5f69 100755 --- a/tools/build/build_php_deps.sh +++ b/tools/build/build_php_deps.sh @@ -20,6 +20,8 @@ parse_args() { while [[ "$#" -gt 0 ]]; do case $1 in --php_versions) + # SC2206: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. + # shellcheck disable=SC2206 PHP_VERSIONS=($2) shift ;; @@ -47,7 +49,7 @@ parse_args() { parse_args "$@" # Validate required arguments -if [[ -z "$PHP_VERSIONS" ]]; then +if [[ -z "${PHP_VERSIONS[*]}" ]]; then echo "Error: Missing required arguments." show_help exit 1 @@ -70,11 +72,11 @@ do fi docker run --rm \ - -v ${PWD}:/sources \ - -v ${PWD}/prod/php/vendor_${PHP_VERSION}:/sources/vendor \ - -e GITHUB_SHA=${GITHUB_SHA} \ + -v "${PWD}:/sources" \ + -v "${PWD}/prod/php/vendor_${PHP_VERSION}:/sources/vendor" \ + -e "GITHUB_SHA=${GITHUB_SHA}" \ -w /sources \ - php:${PHP_VERSION:0:1}.${PHP_VERSION:1:1}-cli sh -c "\ + "php:${PHP_VERSION:0:1}.${PHP_VERSION:1:1}-cli" sh -c "\ apt-get update && apt-get install -y unzip git \ && git config --global --add safe.directory /sources \ && curl -sS https://getcomposer.org/installer | php -- --filename=composer --install-dir=/usr/local/bin \ diff --git a/tools/shared.sh b/tools/shared.sh index b63b2d0e..4b6d7f5a 100755 --- a/tools/shared.sh +++ b/tools/shared.sh @@ -49,7 +49,7 @@ function convert_no_dot_to_dot_separated_version() { echo "${no_dot_version:0:1}.${no_dot_version:1:1}" } - function convert_dot_separated_to_no_dot_version() { +function convert_dot_separated_to_no_dot_version() { local dot_separated_version=${1:?} echo "${dot_separated_version/\./}" } diff --git a/tools/test/component/docker_entrypoint.sh b/tools/test/component/docker_entrypoint.sh index 62509a92..32eb903a 100755 --- a/tools/test/component/docker_entrypoint.sh +++ b/tools/test/component/docker_entrypoint.sh @@ -227,6 +227,7 @@ function main() { current_github_workflow_log_group_name="${current_github_workflow_log_group_name}, filter: ${ELASTIC_OTEL_PHP_TESTS_FILTER}" fi start_github_workflow_log_group "${current_github_workflow_log_group_name}" + # We close this GitHub workflow log group in on_script_exit() /repo_root/tools/test/component/test_installed_package_one_matrix_row.sh } diff --git a/tools/test/component/unpack_matrix_row.sh b/tools/test/component/unpack_matrix_row.sh index 6cc7ba13..d8ee9324 100755 --- a/tools/test/component/unpack_matrix_row.sh +++ b/tools/test/component/unpack_matrix_row.sh @@ -4,9 +4,9 @@ set -e -o pipefail function is_value_in_array () { # The first argument is the element that should be in array - local value_to_check="$1" + local value_to_check="${1:?}" # The rest of the arguments is the array - local -a array=( "${@:2}" ) + local -a array=("${@:2}") for current_value in "${array[@]}"; do if [ "${value_to_check}" == "${current_value}" ] ; then