-
Notifications
You must be signed in to change notification settings - Fork 5k
migrate libbeat pipeline #37725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migrate libbeat pipeline #37725
Changes from 5 commits
d85e193
35fa203
ac9ac7b
8efb4f0
70bfa4e
9f5fd0d
e76a97a
bbe62dc
4b9b801
857f48d
36ffb33
22f4455
e64c72c
6c1747f
6180a26
8282de0
01a3e61
383320e
d95c25f
c1b2b35
d688a5c
7ab9718
b23fc85
dec018c
3ffa0e7
dff6341
0d5c9f8
1fe6f20
4af8233
d1e5d55
87ce234
d684936
da7b08a
0cf08cd
ae8c545
9aa7c6c
411d9d4
708000d
af0b962
a562733
b4efe61
6cd9880
a2c8826
e03d2b3
823a27c
b1155e8
0c4becf
ca6c241
82ebbfa
3774483
d5194bf
f3317c6
b96a16c
f151f98
6e57804
6ee43ff
5aaf276
e2a2afb
5d5ceb8
adf168a
5bfd917
b272833
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| checkout_merge() { | ||
| local target_branch=$1 | ||
| local pr_commit=$2 | ||
| local merge_branch=$3 | ||
|
|
||
| if [[ -z "${target_branch}" ]]; then | ||
| echo "No pull request target branch" | ||
| exit 1 | ||
| fi | ||
|
|
||
| git fetch -v origin "${target_branch}" | ||
| git checkout FETCH_HEAD | ||
| echo "Current branch: $(git rev-parse --abbrev-ref HEAD)" | ||
|
|
||
| # create temporal branch to merge the PR with the target branch | ||
| git checkout -b ${merge_branch} | ||
| echo "New branch created: $(git rev-parse --abbrev-ref HEAD)" | ||
|
|
||
| # set author identity so it can be run git merge | ||
| git config user.name "github-merged-pr-post-checkout" | ||
| git config user.email "auto-merge@buildkite" | ||
|
|
||
| git merge --no-edit "${BUILDKITE_COMMIT}" || { | ||
| local merge_result=$? | ||
| echo "Merge failed: ${merge_result}" | ||
| git merge --abort | ||
| exit ${merge_result} | ||
| } | ||
| } | ||
|
|
||
| pull_request="${BUILDKITE_PULL_REQUEST:-false}" | ||
|
|
||
| if [[ "${pull_request}" == "false" ]]; then | ||
| echo "Not a pull request, skipping" | ||
| exit 0 | ||
| fi | ||
|
|
||
| TARGET_BRANCH="${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-master}" | ||
| PR_COMMIT="${BUILDKITE_COMMIT}" | ||
| PR_ID=${BUILDKITE_PULL_REQUEST} | ||
| MERGE_BRANCH="pr_merge_${PR_ID}" | ||
|
|
||
| checkout_merge "${TARGET_BRANCH}" "${PR_COMMIT}" "${MERGE_BRANCH}" | ||
|
|
||
| echo "Commit information" | ||
| git --no-pager log --format=%B -n 1 | ||
|
|
||
| # Ensure buildkite groups are rendered | ||
| echo "" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| echo "Golang version:" | ||
| GO_VERSION=$(cat .go-version) | ||
| export GO_VERSION | ||
| echo "GO_VERSION: ${GO_VERSION}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,76 @@ | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json | ||
| env: | ||
| SETUP_GVM_VERSION: "v0.5.1" | ||
| SETUP_MAGE_VERSION: "1.13.0" | ||
| SETUP_WIN_PYTHON_VERSION: "3.11.0" | ||
| IMAGE_UBUNTU_X86_64: "family/core-ubuntu-2204" | ||
| IMAGE_UBUNTU_ARM_64: "core-ubuntu-2004-aarch64" | ||
| IMAGE_WIN_2016: "family/core-windows-2016" | ||
| IMAGE_WIN_2019: "family/core-windows-2019" | ||
| IMAGE_WIN_2022: "family/core-windows-2022" | ||
| IMAGE_MACOS_X86_64: "generic-13-ventura-x64" | ||
sharbuz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| GO_AGENT_IMAGE: "golang:${GO_VERSION}" | ||
| DOCKER_COMPOSE_VERSION: "1.21.0" | ||
| PIPELINE_NAME: "libbeat" | ||
|
|
||
| steps: | ||
| - label: "Example test" | ||
| command: echo "Hello!" | ||
|
|
||
| - group: "Mandatory Tests" | ||
| key: "mandatory-tests" | ||
| steps: | ||
| - label: ":linux: Ubuntu Unit Tests" | ||
| key: "mandatory-linux-unit-test" | ||
| command: ".buildkite/scripts/unit_tests.sh ${PIPELINE_NAME}" | ||
| agents: | ||
| provider: "gcp" | ||
| image: "${IMAGE_UBUNTU_X86_64}" | ||
| machineType: "c2-standard-16" | ||
| artifact_paths: "libbeat/build/*.*" | ||
|
|
||
| - label: ":go: Go Intergration Tests" | ||
| key: "mandatory-int-test" | ||
| command: ".buildkite/scripts/go_int_tests.sh ${PIPELINE_NAME}" | ||
| agents: | ||
| provider: "gcp" | ||
| image: "${IMAGE_UBUNTU_X86_64}" | ||
| machineType: "c2-standard-16" | ||
| artifact_paths: "libbeat/build/*.*" | ||
|
|
||
| - label: ":python: Python Integration Tests" | ||
| key: "mandatory-python-int-test" | ||
| command: ".buildkite/scripts/py_int_tests.sh ${PIPELINE_NAME}" | ||
| agents: | ||
| provider: "gcp" | ||
| image: "${IMAGE_UBUNTU_X86_64}" | ||
| machineType: "c2-standard-16" | ||
| artifact_paths: "libbeat/build/*.*" | ||
|
|
||
| - label: ":negative_squared_cross_mark: Cross compile" | ||
| key: "mandatory-cross-compile" | ||
| command: ".buildkite/scripts/crosscompile.sh ${PIPELINE_NAME}" | ||
| agents: | ||
| provider: "gcp" | ||
| image: "${IMAGE_UBUNTU_X86_64}" | ||
| machineType: "c2-standard-16" | ||
| artifact_paths: "libbeat/build/*.*" | ||
|
|
||
| - label: ":negative_squared_cross_mark: Stress Tests" | ||
| key: "mandatory-stress-test" | ||
| command: ".buildkite/scripts/stress_tests.sh ${PIPELINE_NAME}" | ||
| agents: | ||
| provider: "gcp" | ||
| image: "${IMAGE_UBUNTU_X86_64}" | ||
| machineType: "c2-standard-16" | ||
| artifact_paths: "libbeat/build/*.*" | ||
|
|
||
| - group: "Extended Tests" | ||
| key: "extended-tests" | ||
| steps: | ||
| - label: ":mac: Arm64 Unit Tests" | ||
| key: "extended-arm64-unit-tests" | ||
| command: ".buildkite/scripts/unit_tests.sh ${PIPELINE_NAME}" | ||
| agents: | ||
| provider: "aws" | ||
| imagePrefix: "${IMAGE_UBUNTU_ARM_64}" | ||
| instanceType: "t4g.xlarge" | ||
| artifact_paths: "libbeat/build/*.*" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| WORKSPACE=${WORKSPACE:-"$(pwd)"} | ||
| BIN="${WORKSPACE}/bin" | ||
| platform_type="$(uname)" | ||
| platform_type_lowercase=$(echo "$platform_type" | tr '[:upper:]' '[:lower:]') | ||
| arch_type="$(uname -m)" | ||
| pipeline_name="metricbeat" | ||
| DEBIAN_FRONTEND="noninteractive" | ||
| sudo mkdir -p /etc/needrestart | ||
| echo "\$nrconf{restart} = 'a';" | sudo tee -a /etc/needrestart/needrestart.conf > /dev/null | ||
|
|
||
| with_docker_compose() { | ||
| local version=$1 | ||
| echo "Setting up the Docker-compose environment..." | ||
| create_workspace | ||
| retry 5 curl -sSL -o ${BIN}/docker-compose "https://github.com/docker/compose/releases/download/${version}/docker-compose-${platform_type_lowercase}-${arch_type}" | ||
| chmod +x ${BIN}/docker-compose | ||
| docker-compose version | ||
| } | ||
|
|
||
| create_workspace() { | ||
| if [[ ! -d "${BIN}" ]]; then | ||
| mkdir -p "${BIN}" | ||
| fi | ||
| } | ||
|
|
||
| add_bin_path() { | ||
| echo "Adding PATH to the environment variables..." | ||
| create_workspace | ||
| export PATH="${PATH}:${BIN}" | ||
| } | ||
|
|
||
| check_platform_architeture() { | ||
| case "${arch_type}" in | ||
| "x86_64") | ||
| arch_type="amd64" | ||
| ;; | ||
| "aarch64") | ||
| arch_type="arm64" | ||
| ;; | ||
| "arm64") | ||
| arch_type="arm64" | ||
| ;; | ||
| *) | ||
| echo "The current platform/OS type is unsupported yet" | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| with_mage() { | ||
| local install_packages=( | ||
| "github.com/magefile/mage" | ||
| "github.com/elastic/go-licenser" | ||
| "golang.org/x/tools/cmd/goimports" | ||
| "github.com/jstemmer/go-junit-report" | ||
| "gotest.tools/gotestsum" | ||
| ) | ||
| create_workspace | ||
| for pkg in "${install_packages[@]}"; do | ||
| go install "${pkg}@latest" | ||
| done | ||
| } | ||
|
|
||
| with_go() { | ||
| echo "Setting up the Go environment..." | ||
| create_workspace | ||
| check_platform_architeture | ||
| retry 5 curl -sL -o "${BIN}/gvm" "https://github.com/andrewkroh/gvm/releases/download/${SETUP_GVM_VERSION}/gvm-${platform_type_lowercase}-${arch_type}" | ||
| chmod +x "${BIN}/gvm" | ||
| eval "$(gvm $GO_VERSION)" | ||
| go version | ||
| which go | ||
| local go_path="$(go env GOPATH):$(go env GOPATH)/bin" | ||
| export PATH="${PATH}:${go_path}" | ||
| go mod download | ||
| } | ||
|
|
||
| with_python() { | ||
| if [ "${platform_type}" == "Linux" ]; then | ||
| sudo apt-get update | ||
| sudo apt-get install -y python3-pip python3-venv libsystemd-dev libpcap-dev | ||
| elif [ "${platform_type}" == "Darwin" ]; then | ||
| brew update | ||
| pip3 install virtualenv libpcap | ||
| ulimit -Sn 10000 | ||
| fi | ||
| } | ||
|
|
||
| retry() { | ||
| local retries=$1 | ||
| shift | ||
| local count=0 | ||
| until "$@"; do | ||
| exit=$? | ||
| wait=$((2 ** count)) | ||
| count=$((count + 1)) | ||
| if [ $count -lt "$retries" ]; then | ||
| >&2 echo "Retry $count/$retries exited $exit, retrying in $wait seconds..." | ||
| sleep $wait | ||
| else | ||
| >&2 echo "Retry $count/$retries exited $exit, no more retries left." | ||
| return $exit | ||
| fi | ||
| done | ||
| return 0 | ||
| } | ||
|
|
||
| config_git() { | ||
| if [ -z "$(git config --get user.email)" ]; then | ||
| git config --global user.email "[email protected]" | ||
| git config --global user.name "beatsmachine" | ||
| fi | ||
| } | ||
|
|
||
|
|
||
| echo "--- Env preparation" | ||
|
|
||
| if command -v docker-compose &> /dev/null | ||
| then | ||
| set +e | ||
| echo "Found docker-compose. Checking version.." | ||
| FOUND_DOCKER_COMPOSE_VERSION=$(docker-compose --version|awk '{print $3}'|sed s/\,//) | ||
| if [ $FOUND_DOCKER_COMPOSE_VERSION == $DOCKER_COMPOSE_VERSION ]; then | ||
| echo "Versions match. No need to install docker-compose. Exiting." | ||
| else | ||
| echo "Versions don't match. Need to install the correct version of docker-compose." | ||
| with_docker_compose "${DOCKER_COMPOSE_VERSION}" | ||
| fi | ||
| set -e | ||
| fi | ||
|
|
||
| add_bin_path | ||
| with_go "${GO_VERSION}" | ||
| with_mage | ||
| with_python | ||
| config_git | ||
|
|
||
| mage dumpVariables |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
|
|
||
| source .buildkite/scripts/common.sh | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| beats_subfilder=$1 | ||
sharbuz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| echo "--- Run Crosscompile for $beats_subfilder" | ||
| make -C $beats_subfilder crosscompile | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/bin/bash | ||
|
|
||
| source .buildkite/scripts/common.sh | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| beats_subfilder=$1 | ||
|
|
||
| echo "--- Run Go Intergration Tests for $beats_subfilder" | ||
| sudo chmod -R go-w "${beats_subfilder}/" | ||
| pushd "${beats_subfilder}" > /dev/null | ||
| mage goIntegTest | ||
|
|
||
| popd > /dev/null |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/bin/bash | ||
|
|
||
| source .buildkite/scripts/common.sh | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| beats_subfilder=$1 | ||
|
|
||
| echo "--- Run Python Intergration Tests for $beats_subfilder" | ||
| pushd "${beats_subfilder}" > /dev/null | ||
|
|
||
| mage pythonIntegTest | ||
|
|
||
| popd > /dev/null |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
|
|
||
| source .buildkite/scripts/common.sh | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| beats_subfilder=$1 | ||
|
|
||
| echo "--- Run Stress Tests for $beats_subfilder" | ||
| make STRESS_TEST_OPTIONS='-timeout=20m -race -v -parallel 1' -C $beats_subfilder stress-tests |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/bin/bash | ||
|
|
||
| source .buildkite/scripts/common.sh | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| beats_subfilder=$1 | ||
|
|
||
| echo "--- Run Unit Tests" | ||
| sudo chmod -R go-w "${beats_subfilder}/" | ||
| pushd "${beats_subfilder}" > /dev/null | ||
| umask 0022 | ||
|
||
| mage build unitTest | ||
| popd > /dev/null | ||
Uh oh!
There was an error while loading. Please reload this page.