diff --git a/.buildkite/env-scripts/util.sh b/.buildkite/env-scripts/util.sh index 261f2bbee2de..68fd08a75dfd 100755 --- a/.buildkite/env-scripts/util.sh +++ b/.buildkite/env-scripts/util.sh @@ -102,40 +102,3 @@ set_git_config() { git config user.name "${GITHUB_USERNAME_SECRET}" git config user.email "${GITHUB_EMAIL_SECRET}" } - -changeset_applies() { - local changeset=$1 - if are_files_changed "$changeset"; then - echo true - else - echo false - fi -} - -unset_secrets () { - for var in $(printenv | sed 's;=.*;;' | sort); do - if [[ "$var" == *_SECRET || "$var" == *_TOKEN ]]; then - unset "$var" - fi - done -} - -google_cloud_logout_active_account() { - local active_account=$(gcloud auth list --filter=status:ACTIVE --format="value(account)" 2>/dev/null) - if [[ -n "$active_account" && -n "${GOOGLE_APPLICATION_CREDENTIALS+x}" ]]; then - echo "Logging out from GCP for active account" - gcloud auth revoke $active_account > /dev/null 2>&1 - else - echo "No active GCP accounts found." - fi - if [ -n "${GOOGLE_APPLICATION_CREDENTIALS+x}" ]; then - unset GOOGLE_APPLICATION_CREDENTIALS - cleanup - fi -} - -cleanup() { - echo "Deleting temporary files..." - rm -rf ${BIN}/${TMP_FOLDER}.* - echo "Done." -} diff --git a/.buildkite/filebeat/scripts/packaging/package-util.sh b/.buildkite/filebeat/scripts/packaging/package-util.sh deleted file mode 100755 index cb409e8d4848..000000000000 --- a/.buildkite/filebeat/scripts/packaging/package-util.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -is_pr() { - if [[ $BUILDKITE_PULL_REQUEST != false ]]; then - return 0 - else - return 1 - fi -} - -define_tags() { - aliasVersion="${VERSION%.*}${IMG_POSTFIX}" - tags=("${BUILDKITE_COMMIT}") - - if is_pr; then - tags+=("pr-${GITHUB_PR_NUMBER}") - else - tags+=("${SOURCE_TAG}" "${aliasVersion}") - fi -} - -check_is_arm() { - if [[ ${HW_TYPE} == "aarch64" || ${HW_TYPE} == "arm64" ]]; then - is_arm="-arm" - else - is_arm="" - fi -} diff --git a/.buildkite/filebeat/scripts/packaging/package.sh b/.buildkite/filebeat/scripts/packaging/package.sh deleted file mode 100755 index f338e97c0b4c..000000000000 --- a/.buildkite/filebeat/scripts/packaging/package.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -source .buildkite/env-scripts/linux-env.sh -source .buildkite/filebeat/scripts/packaging/package-util.sh - -IMG_POSTFIX="-SNAPSHOT" -VARIANTS=("" "-ubi" "-oss") -VERSION="$(make get-version)" -SOURCE_TAG+="${VERSION}${IMG_POSTFIX}" -BEAT_NAME="filebeat" -TARGET="observability-ci/${BEAT_NAME}" - -echo "--- Creating package" -mage -d filebeat package - -#echo "--- Distribution list" -#dir="filebeat/build/distributions" -#buildkite-agent artifact upload "$dir/*.tar.gz;$dir/*.tar.gz.sha512" -# -#echo "--- Docker image list" -#docker images -# -#define_tags -#check_is_arm -# -#echo "--- Tag & Push" -#for variant in "${VARIANTS[@]}"; do -# source="beats/${BEAT_NAME}${variant}" -# -# for tag in "${tags[@]}"; do -# targetTag=$tag${is_arm} -# -# sourceName="${DOCKER_REGISTRY}/${source}:${SOURCE_TAG}" -# targetName="${DOCKER_REGISTRY}/${TARGET}:${targetTag}" -# # Remove following lines once beats fully migrated -# targetName="${targetName}-buildkite" -# -# if docker image inspect "${sourceName}" &>/dev/null; then -# echo "Source name: $sourceName Target name: $targetName" -# docker tag "$sourceName" "$targetName" -## docker push "$targetName" -# -# else -# echo "Docker image ${sourceName} does not exist" -# fi -#done -#done diff --git a/.buildkite/filebeat/scripts/packaging/packaging-env.sh b/.buildkite/filebeat/scripts/packaging/packaging-env.sh deleted file mode 100755 index 02c942361b4c..000000000000 --- a/.buildkite/filebeat/scripts/packaging/packaging-env.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -source .buildkite/env-scripts/util.sh - -docs_changeset="^.*\.(asciidoc|md)$ -deploy/kubernetes/.*-kubernetes.yaml" -packaging_changeset="^dev-tools/packaging/ -^.go-version" - -VERSION=$(make get-version | tr -d '\n') -ONLY_DOCS=$(changeset_applies "$docs_changeset") -PACKAGING_CHANGES=$(changeset_applies "$packaging_changeset") -GO_MOD_CHANGES=$(changeset_applies "^go.mod") -# Change the postfix to -SNAPSHOT, once Jenkins is disabled - - -export PACKAGING_CHANGES -export ONLY_DOCS -export GO_MOD_CHANGES -export DOCKER_REGISTRY -export VERSION -export REPO -#export IMG_POSTFIX - - -#VARIANTS -> foreach = IMAGES: image map with SOURCE, TARGET, ARCH - -#IMAGES -> foreach = tag and push -# registry: ${REGISTRY}, -# sourceTag: calculate_tags->sourceTag, -# targetTag: "${tag}" (non arm) // ${tag}-${image.arch} (arm) --> foreach $TAGS -# source: ${SOURCE}, -# target: ${TARGET} diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index c33bdaf4bec4..1631b7dc0a1e 100644 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -52,10 +52,6 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats" || "$BUILDKITE_PIPELINE_SLUG" == "fi git config user.name "$github_username" git config user.email "$github_email" fi - - if [[ "$BUILDKITE_STEP_KEY" == macos* ]]; then - ulimit -Sn 30000 - fi fi ENABLED_BEATS_PIPELINES_SLUGS=( diff --git a/.buildkite/metricbeat/pipeline.yml b/.buildkite/metricbeat/pipeline.yml index d0cece3a5900..2d3a7d04901e 100644 --- a/.buildkite/metricbeat/pipeline.yml +++ b/.buildkite/metricbeat/pipeline.yml @@ -29,55 +29,55 @@ steps: - group: "Metricbeat Mandatory Tests" key: "metricbeat-mandatory-tests" steps: - - label: ":linux: Ubuntu Unit Tests" - key: "mandatory-linux-unit-test" - command: "cd metricbeat && mage build unitTest" - retry: - automatic: - - limit: 3 - agents: - provider: "gcp" - image: "${IMAGE_UBUNTU_X86_64}" - machineType: "${GCP_DEFAULT_MACHINE_TYPE}" - artifact_paths: - - "metricbeat/build/*.xml" - - "metricbeat/build/*.json" - notify: - - github_commit_status: - context: "metricbeat: Ubuntu Unit Tests" - - - label: ":go: Go Integration Tests" - key: "mandatory-int-test" - command: | - set -euo pipefail - # defines the MODULE env var based on what's changed in a PR - source .buildkite/scripts/changesets.sh - defineModuleFromTheChangeSet metricbeat - echo "~~~ Will run tests with env var MODULE=$$MODULE" - - # TODO move this section to base image / pre-command hook - echo "~~~ Installing kind" - asdf plugin add kind - asdf install kind $ASDF_KIND_VERSION - - .buildkite/deploy/kubernetes/scripts/kind-setup.sh - - echo "~~~ Running tests" - export KUBECONFIG="$$PWD/kubecfg" - cd metricbeat && mage goIntegTest - retry: - automatic: - - limit: 3 - agents: - provider: "gcp" - image: "${IMAGE_UBUNTU_X86_64}" - machineType: "${GCP_HI_PERF_MACHINE_TYPE}" - artifact_paths: - - "metricbeat/build/*.xml" - - "metricbeat/build/*.json" - notify: - - github_commit_status: - context: "metricbeat: Go Integration Tests" +# - label: ":linux: Ubuntu Unit Tests" +# key: "mandatory-linux-unit-test" +# command: "cd metricbeat && mage build unitTest" +# retry: +# automatic: +# - limit: 3 +# agents: +# provider: "gcp" +# image: "${IMAGE_UBUNTU_X86_64}" +# machineType: "${GCP_DEFAULT_MACHINE_TYPE}" +# artifact_paths: +# - "metricbeat/build/*.xml" +# - "metricbeat/build/*.json" +# notify: +# - github_commit_status: +# context: "metricbeat: Ubuntu Unit Tests" +# +# - label: ":go: Go Integration Tests" +# key: "mandatory-int-test" +# command: | +# set -euo pipefail +# # defines the MODULE env var based on what's changed in a PR +# source .buildkite/scripts/changesets.sh +# defineModuleFromTheChangeSet metricbeat +# echo "~~~ Will run tests with env var MODULE=$$MODULE" +# +# # TODO move this section to base image / pre-command hook +# echo "~~~ Installing kind" +# asdf plugin add kind +# asdf install kind $ASDF_KIND_VERSION +# +# .buildkite/deploy/kubernetes/scripts/kind-setup.sh +# +# echo "~~~ Running tests" +# export KUBECONFIG="$$PWD/kubecfg" +# cd metricbeat && mage goIntegTest +# retry: +# automatic: +# - limit: 3 +# agents: +# provider: "gcp" +# image: "${IMAGE_UBUNTU_X86_64}" +# machineType: "${GCP_HI_PERF_MACHINE_TYPE}" +# artifact_paths: +# - "metricbeat/build/*.xml" +# - "metricbeat/build/*.json" +# notify: +# - github_commit_status: +# context: "metricbeat: Go Integration Tests" - label: ":python: Python Integration Tests" key: "mandatory-python-int-test" @@ -88,6 +88,10 @@ steps: defineModuleFromTheChangeSet metricbeat echo "~~~ Running tests with env var MODULE=$$MODULE" + source .buildkite/scripts/define_module.sh + defineModule metricbeat + echo "~~~ New MODULE definition is $$NEW_MODULE" + # TODO move this section to base image / pre-command hook echo "~~~ Installing kind" asdf plugin add kind @@ -112,219 +116,219 @@ steps: - github_commit_status: context: "metricbeat: Python Integration Tests" - - label: ":negative_squared_cross_mark: Cross compile" - key: "mandatory-cross-compile" - command: "make -C metricbeat crosscompile" - retry: - automatic: - - limit: 3 - agents: - provider: "gcp" - image: "${IMAGE_UBUNTU_X86_64}" - machineType: "${GCP_DEFAULT_MACHINE_TYPE}" - artifact_paths: - - "metricbeat/build/*.xml" - - "metricbeat/build/*.json" - notify: - - github_commit_status: - context: "metricbeat: Cross compile" - - - label: ":windows: Windows 2016 Unit Tests" - command: | - Set-Location -Path metricbeat - mage build unitTest - key: "mandatory-win-2016-unit-tests" - retry: - automatic: - - limit: 3 - agents: - provider: "gcp" - image: "${IMAGE_WIN_2016}" - machine_type: "${GCP_WIN_MACHINE_TYPE}" - disk_size: 100 - disk_type: "pd-ssd" - artifact_paths: - - "metricbeat/build/*.xml" - - "metricbeat/build/*.json" - notify: - - github_commit_status: - context: "metricbeat: Windows 2016 Unit Tests" - - - label: ":windows: Windows 2022 Unit Tests" - command: | - Set-Location -Path metricbeat - mage build unitTest - key: "mandatory-win-2022-unit-tests" - retry: - automatic: - - limit: 3 - agents: - provider: "gcp" - image: "${IMAGE_WIN_2022}" - machine_type: "${GCP_WIN_MACHINE_TYPE}" - disk_size: 100 - disk_type: "pd-ssd" - artifact_paths: - - "metricbeat/build/*.xml" - - "metricbeat/build/*.json" - notify: - - github_commit_status: - context: "metricbeat: Windows 2022 Unit Tests" - - - group: "Metricbeat Extended Windows Tests" - key: "metricbeat-extended-win-tests" - if: build.env("BUILDKITE_PULL_REQUEST") == "false" || build.env("GITHUB_PR_LABELS") =~ /.*[Ww]indows.*/ - steps: - - label: ":windows: Windows 10 Unit Tests" - command: | - Set-Location -Path metricbeat - mage build unitTest - key: "extended-win-10-unit-tests" - retry: - automatic: - - limit: 3 - agents: - provider: "gcp" - image: "${IMAGE_WIN_10}" - machineType: "${GCP_WIN_MACHINE_TYPE}" - disk_size: 100 - disk_type: "pd-ssd" - artifact_paths: - - "metricbeat/build/*.xml" - - "metricbeat/build/*.json" - notify: - - github_commit_status: - context: "metricbeat: Extended Windows 10 Unit Tests" - - - label: ":windows: Windows 11 Unit Tests" - command: | - Set-Location -Path metricbeat - mage build unitTest - key: "extended-win-11-unit-tests" - retry: - automatic: - - limit: 3 - agents: - provider: "gcp" - image: "${IMAGE_WIN_11}" - machineType: "${GCP_WIN_MACHINE_TYPE}" - disk_size: 100 - disk_type: "pd-ssd" - artifact_paths: - - "metricbeat/build/*.xml" - - "metricbeat/build/*.json" - notify: - - github_commit_status: - context: "metricbeat: Extended Windows 11 Unit Tests" - - - label: ":windows: Windows 2019 Unit Tests" - command: | - Set-Location -Path metricbeat - mage build unitTest - key: "extended-win-2019-unit-tests" - retry: - automatic: - - limit: 3 - agents: - provider: "gcp" - image: "${IMAGE_WIN_2019}" - machineType: "${GCP_WIN_MACHINE_TYPE}" - disk_size: 100 - disk_type: "pd-ssd" - artifact_paths: - - "metricbeat/build/*.xml" - - "metricbeat/build/*.json" - notify: - - github_commit_status: - context: "metricbeat: Extended Windows 2019 Unit Tests" - - - group: "Metricbeat Extended MacOS Tests" - key: "metricbeat-extended-macos-tests" - if: build.env("BUILDKITE_PULL_REQUEST") == "false" || build.env("GITHUB_PR_LABELS") =~ /.*macOS.*/ - steps: - - label: ":mac: MacOS x64_64 Unit Tests" - key: "extended-macos-x64-64-unit-tests" - command: | - set -euo pipefail - source .buildkite/scripts/install_macos_tools.sh - cd metricbeat && mage build unitTest - retry: - automatic: - - limit: 3 - agents: - provider: "orka" - imagePrefix: "${IMAGE_MACOS_X86_64}" - artifact_paths: - - "metricbeat/build/*.xml" - - "metricbeat/build/*.json" - notify: - - github_commit_status: - context: "metricbeat: Extended MacOS x86_64 Unit Tests" - - - label: ":mac: MacOS arm64 Unit Tests" - key: "extended-macos-arm64-unit-tests" - skip: "due to https://github.com/elastic/beats/issues/33035" - command: | - set -euo pipefail - source .buildkite/scripts/install_macos_tools.sh - cd metricbeat && mage build unitTest - retry: - automatic: - - limit: 3 - agents: - provider: "orka" - imagePrefix: "${IMAGE_MACOS_ARM}" - artifact_paths: - - "metricbeat/build/*.xml" - - "metricbeat/build/*.json" - notify: - - github_commit_status: - context: "metricbeat: Extended MacOS arm64 Unit Tests" - - - - wait: ~ - # with PRs, we want to run packaging only if mandatory tests succeed - # for other cases, e.g. merge commits, we want to run packaging (and publish) independently of other tests - # this allows building DRA artifacts even if there is flakiness in mandatory tests - if: build.env("BUILDKITE_PULL_REQUEST") != "false" - depends_on: "metricbeat-mandatory-tests" - - - group: "Metricbeat Packaging" - key: "metricbeat-packaging" - steps: - - label: ":linux: Packaging Linux" - key: "packaging-linux" - command: "cd metricbeat && mage package" - retry: - automatic: - - limit: 3 - timeout_in_minutes: 20 - agents: - provider: "gcp" - image: "${IMAGE_UBUNTU_X86_64}" - machineType: "${GCP_HI_PERF_MACHINE_TYPE}" - disk_size: 100 - disk_type: "pd-ssd" - env: - PLATFORMS: "+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64" - notify: - - github_commit_status: - context: "metricbeat: Packaging Linux" - - - label: ":linux: Packaging ARM" - key: "packaging-arm" - command: "cd metricbeat && mage package" - retry: - automatic: - - limit: 3 - timeout_in_minutes: 20 - agents: - provider: "aws" - imagePrefix: "${IMAGE_UBUNTU_ARM_64}" - instanceType: "${AWS_ARM_INSTANCE_TYPE}" - env: - PLATFORMS: "linux/arm64" - PACKAGES: "docker" - notify: - - github_commit_status: - context: "metricbeat: Packaging Linux ARM" +# - label: ":negative_squared_cross_mark: Cross compile" +# key: "mandatory-cross-compile" +# command: "make -C metricbeat crosscompile" +# retry: +# automatic: +# - limit: 3 +# agents: +# provider: "gcp" +# image: "${IMAGE_UBUNTU_X86_64}" +# machineType: "${GCP_DEFAULT_MACHINE_TYPE}" +# artifact_paths: +# - "metricbeat/build/*.xml" +# - "metricbeat/build/*.json" +# notify: +# - github_commit_status: +# context: "metricbeat: Cross compile" +# +# - label: ":windows: Windows 2016 Unit Tests" +# command: | +# Set-Location -Path metricbeat +# mage build unitTest +# key: "mandatory-win-2016-unit-tests" +# retry: +# automatic: +# - limit: 3 +# agents: +# provider: "gcp" +# image: "${IMAGE_WIN_2016}" +# machine_type: "${GCP_WIN_MACHINE_TYPE}" +# disk_size: 100 +# disk_type: "pd-ssd" +# artifact_paths: +# - "metricbeat/build/*.xml" +# - "metricbeat/build/*.json" +# notify: +# - github_commit_status: +# context: "metricbeat: Windows 2016 Unit Tests" +# +# - label: ":windows: Windows 2022 Unit Tests" +# command: | +# Set-Location -Path metricbeat +# mage build unitTest +# key: "mandatory-win-2022-unit-tests" +# retry: +# automatic: +# - limit: 3 +# agents: +# provider: "gcp" +# image: "${IMAGE_WIN_2022}" +# machine_type: "${GCP_WIN_MACHINE_TYPE}" +# disk_size: 100 +# disk_type: "pd-ssd" +# artifact_paths: +# - "metricbeat/build/*.xml" +# - "metricbeat/build/*.json" +# notify: +# - github_commit_status: +# context: "metricbeat: Windows 2022 Unit Tests" +# +# - group: "Metricbeat Extended Windows Tests" +# key: "metricbeat-extended-win-tests" +# if: build.env("BUILDKITE_PULL_REQUEST") == "false" || build.env("GITHUB_PR_LABELS") =~ /.*[Ww]indows.*/ +# steps: +# - label: ":windows: Windows 10 Unit Tests" +# command: | +# Set-Location -Path metricbeat +# mage build unitTest +# key: "extended-win-10-unit-tests" +# retry: +# automatic: +# - limit: 3 +# agents: +# provider: "gcp" +# image: "${IMAGE_WIN_10}" +# machineType: "${GCP_WIN_MACHINE_TYPE}" +# disk_size: 100 +# disk_type: "pd-ssd" +# artifact_paths: +# - "metricbeat/build/*.xml" +# - "metricbeat/build/*.json" +# notify: +# - github_commit_status: +# context: "metricbeat: Extended Windows 10 Unit Tests" +# +# - label: ":windows: Windows 11 Unit Tests" +# command: | +# Set-Location -Path metricbeat +# mage build unitTest +# key: "extended-win-11-unit-tests" +# retry: +# automatic: +# - limit: 3 +# agents: +# provider: "gcp" +# image: "${IMAGE_WIN_11}" +# machineType: "${GCP_WIN_MACHINE_TYPE}" +# disk_size: 100 +# disk_type: "pd-ssd" +# artifact_paths: +# - "metricbeat/build/*.xml" +# - "metricbeat/build/*.json" +# notify: +# - github_commit_status: +# context: "metricbeat: Extended Windows 11 Unit Tests" +# +# - label: ":windows: Windows 2019 Unit Tests" +# command: | +# Set-Location -Path metricbeat +# mage build unitTest +# key: "extended-win-2019-unit-tests" +# retry: +# automatic: +# - limit: 3 +# agents: +# provider: "gcp" +# image: "${IMAGE_WIN_2019}" +# machineType: "${GCP_WIN_MACHINE_TYPE}" +# disk_size: 100 +# disk_type: "pd-ssd" +# artifact_paths: +# - "metricbeat/build/*.xml" +# - "metricbeat/build/*.json" +# notify: +# - github_commit_status: +# context: "metricbeat: Extended Windows 2019 Unit Tests" +# +# - group: "Metricbeat Extended MacOS Tests" +# key: "metricbeat-extended-macos-tests" +# if: build.env("BUILDKITE_PULL_REQUEST") == "false" || build.env("GITHUB_PR_LABELS") =~ /.*macOS.*/ +# steps: +# - label: ":mac: MacOS x64_64 Unit Tests" +# key: "extended-macos-x64-64-unit-tests" +# command: | +# set -euo pipefail +# source .buildkite/scripts/install_macos_tools.sh +# cd metricbeat && mage build unitTest +# retry: +# automatic: +# - limit: 3 +# agents: +# provider: "orka" +# imagePrefix: "${IMAGE_MACOS_X86_64}" +# artifact_paths: +# - "metricbeat/build/*.xml" +# - "metricbeat/build/*.json" +# notify: +# - github_commit_status: +# context: "metricbeat: Extended MacOS x86_64 Unit Tests" +# +# - label: ":mac: MacOS arm64 Unit Tests" +# key: "extended-macos-arm64-unit-tests" +# skip: "due to https://github.com/elastic/beats/issues/33035" +# command: | +# set -euo pipefail +# source .buildkite/scripts/install_macos_tools.sh +# cd metricbeat && mage build unitTest +# retry: +# automatic: +# - limit: 3 +# agents: +# provider: "orka" +# imagePrefix: "${IMAGE_MACOS_ARM}" +# artifact_paths: +# - "metricbeat/build/*.xml" +# - "metricbeat/build/*.json" +# notify: +# - github_commit_status: +# context: "metricbeat: Extended MacOS arm64 Unit Tests" +# +# +# - wait: ~ +# # with PRs, we want to run packaging only if mandatory tests succeed +# # for other cases, e.g. merge commits, we want to run packaging (and publish) independently of other tests +# # this allows building DRA artifacts even if there is flakiness in mandatory tests +# if: build.env("BUILDKITE_PULL_REQUEST") != "false" +# depends_on: "metricbeat-mandatory-tests" +# +# - group: "Metricbeat Packaging" +# key: "metricbeat-packaging" +# steps: +# - label: ":linux: Packaging Linux" +# key: "packaging-linux" +# command: "cd metricbeat && mage package" +# retry: +# automatic: +# - limit: 3 +# timeout_in_minutes: 20 +# agents: +# provider: "gcp" +# image: "${IMAGE_UBUNTU_X86_64}" +# machineType: "${GCP_HI_PERF_MACHINE_TYPE}" +# disk_size: 100 +# disk_type: "pd-ssd" +# env: +# PLATFORMS: "+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64" +# notify: +# - github_commit_status: +# context: "metricbeat: Packaging Linux" +# +# - label: ":linux: Packaging ARM" +# key: "packaging-arm" +# command: "cd metricbeat && mage package" +# retry: +# automatic: +# - limit: 3 +# timeout_in_minutes: 20 +# agents: +# provider: "aws" +# imagePrefix: "${IMAGE_UBUNTU_ARM_64}" +# instanceType: "${AWS_ARM_INSTANCE_TYPE}" +# env: +# PLATFORMS: "linux/arm64" +# PACKAGES: "docker" +# notify: +# - github_commit_status: +# context: "metricbeat: Packaging Linux ARM" diff --git a/.buildkite/scripts/define_module.sh b/.buildkite/scripts/define_module.sh index d7187b589019..ebcc9304821c 100755 --- a/.buildkite/scripts/define_module.sh +++ b/.buildkite/scripts/define_module.sh @@ -4,52 +4,64 @@ set -euo pipefail OSS_MODULE_PATTERN="^[a-z0-9]+beat\\/module\\/([^\\/]+)\\/.*" XPACK_MODULE_PATTERN="^x-pack\\/[a-z0-9]+beat\\/module\\/([^\\/]+)\\/.*" -BEAT_PATH=$1 -MODULE='' definePattern() { - pattern="${XPACK_MODULE_PATTERN}" + local beatPath=$1 + pattern="${OSS_MODULE_PATTERN}" - if [[ "$BEAT_PATH" == *"x-pack/"* ]]; then - pattern="${OSS_MODULE_PATTERN}" + if [[ "$beatPath" == *"x-pack/"* ]]; then + pattern="${XPACK_MODULE_PATTERN}" fi + + echo "--- With MODULE Pattern: $pattern" } defineExclusions() { - local transformedDirectory=${BEAT_PATH//\//\\\/} + local beatPath=$1 + local transformedDirectory=${beatPath//\//\\\/} local exclusion="((?!^${transformedDirectory}\\/).)*\$" exclude="^(${exclusion}|((?!\\/module\\/).)*\$|.*\\.asciidoc|.*\\.png)" + + echo "--- With MODULE Exclusions: $exclude" } -getGitMatchingGroup() { +getMatchingModules() { local previousCommit - local matches - local match - + local from local changeTarget=${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-$BUILDKITE_BRANCH} - local baseCommit=$BUILDKITE_COMMIT - previousCommit=$(git rev-parse HEAD^) - from=$(echo ${changeTarget:+"origin/$changeTarget"}${previousCommit:-$baseCommit}) - to=$baseCommit - matches=$(git diff --name-only "$from"..."$to" | grep -v "$exclude" | grep -oP "$pattern" | sort -u) + previousCommit=$(git rev-parse HEAD^) + from=$(echo ${changeTarget:+"origin/$changeTarget"}${previousCommit:-$BUILDKITE_COMMIT}) - match=$(echo "$matches" | wc -w) + mapfile -t matchedModules < <(git diff --name-only "$from"..."$BUILDKITE_COMMIT" | grep -v "$exclude" | grep -oP "$pattern") + echo "--- Modules Matched: ${matchedModules[*]}" +} - if [ "$match" -eq 1 ]; then - echo "$matches" - else - echo '' +addModule() { + local module=$1 + if [ "$moduleList" != "" ]; then + moduleList+="," fi + moduleList+="$module" + + echo "--- Modules Added: $moduleList" } defineModule() { - cd "${BEAT_PATH}" - NEW_MODULE=$(getGitMatchingGroup "$pattern" "$exclude") - if [ ! -f "$BEAT_PATH/module/${module}" ]; then - NEW_MODULE='' - fi + local beatPath=$1 + moduleList='' + + definePattern $beatPath + defineExclusions $beatPath + getMatchingModules + + cd "${beatPath}" + for module in "${matchedModules[@]}"; do + if [ ! -f "$beatPath/module/${module}" ]; then + addModule ${module} + fi + done cd - >/dev/null - export NEW_MODULE + export NEW_MODULE=$moduleList } diff --git a/metricbeat/module/linux/deleteme b/metricbeat/module/linux/deleteme new file mode 100644 index 000000000000..e69de29bb2d1