Skip to content

Commit

Permalink
updated packaging execution conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
oakrizan committed Jan 4, 2024
1 parent 4f835b6 commit 2443985
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 48 deletions.
9 changes: 7 additions & 2 deletions .buildkite/filebeat/filebeat-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,17 @@ steps:

- group: "Packaging"
key: "packaging"
if: build.env("BUILDKITE_PULL_REQUEST") != "false" && build.env("FILEBEAT_CHANGESET") == "true"
if: build.env("BUILDKITE_PULL_REQUEST") != "false"

steps:
- label: ":ubuntu: Packaging Linux X86"
key: "package-linux-x86"
command: "echo Test me"
command:
- "sudo apt-get update"
# - "sudo apt-get install -y libsystemd-dev"
# - "sudo apt install -y python3-pip"
- "sudo apt-get install -y python3-venv"
- ".buildkite/filebeat/scripts/package.sh"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
Expand Down
26 changes: 21 additions & 5 deletions .buildkite/filebeat/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

set -euo pipefail

#WORKSPACE="$(pwd)"
WORKSPACE="$(pwd)"
BIN="${WORKSPACE}/bin"
HW_TYPE="$(uname -m)"
PLATFORM_TYPE="$(uname)"

#if [[ -z "${GOLANG_VERSION-""}" ]]; then
# export GOLANG_VERSION=$(cat "${WORKSPACE}/.go-version")
#fi

add_bin_path() {
echo "Adding PATH to the environment variables..."
create_bin
Expand Down Expand Up @@ -87,3 +83,23 @@ retry() {
done
return 0
}

are_files_changed() {
changeset=$1

if git diff --name-only HEAD@{1} HEAD | grep -qE "$changeset"; then
return 0;
else
echo "WARN! No files changed in $changeset"
return 1;
fi
}

prepare_win() {
local os
os="$(uname)"
if [[ $os = MINGW* ]]; then
choco install mingw -y
choco install python --version=3.11.0 -y
fi
}
31 changes: 30 additions & 1 deletion .buildkite/filebeat/scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,33 @@

set -euo pipefail

echo ":: Test me ::"
source .buildkite/filebeat/scripts/common.sh

echo ":: Evaluate Filebeat Changes ::"

changeset="^filebeat/
^go.mod
^pytest.ini
^dev-tools/
^libbeat/
^testing/
^\.buildkite/filebeat/"

if ! are_files_changed "$changeset" ; then
message="No files changed within Filebeat changeset"
echo "$message"
buildkite-agent annotate "$message" --style 'warning' --context 'ctx-warn'
# This should return any error but skip the release.
exit 0
fi

# ToDo - remove after Beats agent is created"
echo ":: Setup Env ::"
add_bin_path
with_go
with_mage
# ToDo - end

echo ":: Start Packaging ::"
cd filebeat
mage package
20 changes: 0 additions & 20 deletions .buildkite/filebeat/scripts/pre-common.sh

This file was deleted.

18 changes: 0 additions & 18 deletions .buildkite/hooks/post-checkout

This file was deleted.

3 changes: 1 addition & 2 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

set -euo pipefail

source .buildkite/filebeat/scripts/pre-common.sh
source .buildkite/filebeat/scripts/common.sh

if [[ "$BUILDKITE_PIPELINE_SLUG" == "filebeat" ]]; then
export WORKSPACE="$(pwd)"

prepare_win
echo "pre-command test echo"

if [[ -z "${GOLANG_VERSION-""}" ]]; then
export GOLANG_VERSION=$(cat "${WORKSPACE}/.go-version")
Expand Down

0 comments on commit 2443985

Please sign in to comment.