Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
acdab09
Adapt codeowners check
jsoriano Jan 14, 2026
265c135
[citools] Add ListPackages and extend packageManifest struct
mrodm Apr 16, 2026
58f0fe5
[citools] Expose ReadPackageManifest and consolidate manifest logic
mrodm Apr 16, 2026
d9100b9
[codeowners] Refactor validatePackages to use citools.ListPackages
mrodm Apr 16, 2026
91f9db5
[codeowners] Add tests for validatePackages with nested packages
mrodm Apr 16, 2026
a4af05b
[magefile] Add ListPackages mage target
mrodm Apr 16, 2026
741448f
Test with a subset of packages
mrodm Apr 17, 2026
218f948
[buildkite] Fix package path/name misusage after ListPackages refactor
mrodm Apr 17, 2026
3d92f36
[citools] Export ManifestFileName and remove duplicate constant
mrodm Apr 17, 2026
bb2e60f
[buildkite] Fix leftover issues in test_one_package.sh
mrodm Apr 17, 2026
e2454f2
Ensure that package_name_manifest is executed in the package path
mrodm Apr 17, 2026
99bfc48
[buildkite] Add should_test_package helper to common.sh
mrodm Apr 17, 2026
9f03436
[buildkite] Refactor build_packages.sh to support nested packages
mrodm Apr 17, 2026
71e903e
Update temprarily build_packages to test it - to be reverted
mrodm Apr 17, 2026
293da9f
[buildkite] Fix mage not found in build_packages.sh
mrodm Apr 17, 2026
5651580
[codeowners] Fix infinite loop in findOwnerForFile on absolute paths
mrodm Apr 17, 2026
b794a1b
Update loop to find findOwnerForFile
mrodm Apr 17, 2026
ac65fe1
[buildkite] Replace PACKAGE_FOLDER_NAME with get_package_path in back…
mrodm Apr 20, 2026
d7c0536
[buildkite] Fix CODEOWNERS removal for nested packages in removeOther…
mrodm Apr 20, 2026
1f1ebbf
[buildkite] Fix get_package_path early exit under set -e
mrodm Apr 20, 2026
6708fcd
Use as source branch the current commit - to be removed
mrodm Apr 20, 2026
2fea205
Use list_all_directories to get all directories/packages
mrodm Apr 20, 2026
ca7362b
Add more test packages
mrodm Apr 20, 2026
6835aef
Attempt to get the current branch as a source
mrodm Apr 20, 2026
237d836
Create temporal branch
mrodm Apr 20, 2026
1e50707
Restore location of removeOtherPackages call
mrodm Apr 20, 2026
06a49b5
Move some packages under nested directories to test CI scripts
mrodm Apr 20, 2026
dc25416
Allow to list more packages
mrodm Apr 20, 2026
b9fcd33
Test codeowners
mrodm Apr 20, 2026
0e64850
Revert changes in CODEOWNERS file
mrodm Apr 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .buildkite/pipeline.backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
name: "integrations-backport"

env:
SETUP_GVM_VERSION: "v0.6.0"
YQ_VERSION: 'v4.35.2'
# Agent images used in pipeline steps
LINUX_AGENT_IMAGE: "golang:${GO_VERSION}"
Expand Down Expand Up @@ -35,10 +36,6 @@ steps:
key: "PACKAGE_NAME"
required: true
default: ""
- text: "Enter name of the folder for the package (in most cases coincides with PACKAGE_NAME)"
key: "PACKAGE_FOLDER_NAME"
required: true
default: ""
- text: "Enter package version (examples: 1.5.7, 1.0.0-beta1)"
key: "PACKAGE_VERSION"
required: true
Expand Down
71 changes: 50 additions & 21 deletions .buildkite/scripts/backport_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ trap cleanup_gh EXIT
DRY_RUN="$(buildkite-agent meta-data get DRY_RUN --default "${DRY_RUN:-"true"}")"
BASE_COMMIT="$(buildkite-agent meta-data get BASE_COMMIT --default "${BASE_COMMIT:-""}")"
PACKAGE_NAME="$(buildkite-agent meta-data get PACKAGE_NAME --default "${PACKAGE_NAME:-""}")"
PACKAGE_FOLDER_NAME="$(buildkite-agent meta-data get PACKAGE_FOLDER_NAME --default "${PACKAGE_FOLDER_NAME:-""}")"
PACKAGE_VERSION="$(buildkite-agent meta-data get PACKAGE_VERSION --default "${PACKAGE_VERSION:-""}")"
REMOVE_OTHER_PACKAGES="$(buildkite-agent meta-data get REMOVE_OTHER_PACKAGES --default "${REMOVE_OTHER_PACKAGES:-"false"}")"

if [[ -z "$PACKAGE_NAME" ]] || [[ -z "$PACKAGE_FOLDER_NAME" ]] || [[ -z "$PACKAGE_VERSION" ]]; then
buildkite-agent annotate "The variables **PACKAGE_NAME**, **PACKAGE_FOLDER_NAME** or **PACKAGE_VERSION** aren't defined, please try again" --style "warning"
if [[ -z "$PACKAGE_NAME" ]] || [[ -z "$PACKAGE_VERSION" ]]; then
buildkite-agent annotate "The variables **PACKAGE_NAME** or **PACKAGE_VERSION** aren't defined, please try again" --style "warning"
exit 1
fi

Expand All @@ -30,7 +29,6 @@ PARAMETERS=(
"**DRY_RUN**=$DRY_RUN"
"**BASE_COMMIT**=$BASE_COMMIT"
"**PACKAGE_NAME**=$PACKAGE_NAME"
"**PACKAGE_FOLDER_NAME**=$PACKAGE_FOLDER_NAME"
"**PACKAGE_VERSION**=$PACKAGE_VERSION"
"**REMOVE_OTHER_PACKAGES**=$REMOVE_OTHER_PACKAGES"
)
Expand All @@ -43,6 +41,10 @@ echo "Parameters: ${PARAMETERS[*]}" | sed 's/ /\n- /g' | buildkite-agent annotat
FULL_ZIP_PACKAGE_NAME="${PACKAGE_NAME}-${PACKAGE_VERSION}.zip"
TRIMMED_PACKAGE_VERSION="$(echo "$PACKAGE_VERSION" | cut -d '.' -f -2)"
SOURCE_BRANCH="main"
# To be removed
git checkout -b test_main
SOURCE_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
echo "--- SOURCE_BRANCH: ${SOURCE_BRANCH}"
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
BACKPORT_BRANCH_NAME="backport-${PACKAGE_NAME}-${TRIMMED_PACKAGE_VERSION}"
PACKAGES_FOLDER_PATH="packages"
MSG=""
Expand Down Expand Up @@ -85,6 +87,24 @@ branchExist() {
fi
}

# get_package_path returns the path of the package with the given name as
# defined in the manifest.yml `name` field. Returns 1 if not found.
get_package_path() {
local package_name="${1}"
local package_path=""

while IFS= read -r package_path; do
local name
name=$(yq -r '.name' "${package_path}/manifest.yml")
if [[ "${name}" == "${package_name}" ]]; then
echo "${package_path}"
return 0
fi
done < <(list_all_directories)

return 1
}

createLocalBackportBranch() {
local branch_name=$1
local source_commit=$2
Expand All @@ -97,18 +117,18 @@ createLocalBackportBranch() {
}

removeOtherPackages() {
local sourceFolder=$1
local currentPackage=""
local dir
for dir in "$sourceFolder"/*; do
if [[ -d "$dir" ]] && [[ "$(basename "$dir")" != "$PACKAGE_FOLDER_NAME" ]]; then
echo "Removing directory: $dir"
rm -rf "$dir"

currentPackage=$(basename "${dir}")
echo "Removing ${currentPackage} from .github/CODEOWNERS"
sed -i "/^\/packages\/${currentPackage}\//d" .github/CODEOWNERS
sed -i "/^\/packages\/${currentPackage} /d" .github/CODEOWNERS
local package_path_to_keep="${1}"
local package_path
local package_paths=""
package_paths=$(list_all_directories)
for package_path in ${package_paths}; do
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
if [[ -d "$package_path" ]] && [[ "${package_path}" != "${package_path_to_keep}" ]]; then
echo "Removing directory: ${package_path}"
rm -rf "$package_path"

echo "Removing ${package_path} from .github/CODEOWNERS"
sed -i "\|^/${package_path}/|d" .github/CODEOWNERS
sed -i "\|^/${package_path} |d" .github/CODEOWNERS
fi
done
}
Expand Down Expand Up @@ -204,7 +224,7 @@ updateBackportBranchContents() {

if [ "${REMOVE_OTHER_PACKAGES}" == "true" ]; then
echo "--- Removing all packages from $PACKAGES_FOLDER_PATH folder"
removeOtherPackages "${PACKAGES_FOLDER_PATH}"
removeOtherPackages "${PACKAGE_PATH}"
ls -la "${PACKAGES_FOLDER_PATH}"

git add "${PACKAGES_FOLDER_PATH}/"
Expand All @@ -228,7 +248,7 @@ updateBackportBranchContents() {
if [ "$DRY_RUN" == "true" ];then
echo "--- DRY_RUN mode, nothing will be pushed."
# Show just the relevant files diff (go.mod, go.sum, .buildkite, dev, .go-version, .github/CODEOWNERS and package to be backported)
git --no-pager diff "$SOURCE_BRANCH...$BACKPORT_BRANCH_NAME" .buildkite/ dev/ go.sum go.mod .go-version tools.go .github/CODEOWNERS "packages/${PACKAGE_FOLDER_NAME}"
git --no-pager diff "$SOURCE_BRANCH...$BACKPORT_BRANCH_NAME" .buildkite/ dev/ go.sum go.mod .go-version tools.go .github/CODEOWNERS "${PACKAGE_PATH}"
else
echo "--- Pushing..."
git push origin "$BACKPORT_BRANCH_NAME"
Expand All @@ -245,6 +265,15 @@ fi
add_bin_path

with_yq
with_mage

echo "--- Resolve package path from PACKAGE_NAME"
PACKAGE_PATH="$(get_package_path "${PACKAGE_NAME}" || true)"
if [[ -z "${PACKAGE_PATH}" ]]; then
buildkite-agent annotate "Package **${PACKAGE_NAME}** not found" --style "error"
exit 1
fi
echo "Package path: ${PACKAGE_PATH}"

echo "--- Check if the package is published"
if ! isPackagePublished "$FULL_ZIP_PACKAGE_NAME"; then
Expand All @@ -268,15 +297,15 @@ if branchExist "$BACKPORT_BRANCH_NAME"; then
fi

# backport branch does not exist, running checks and create branch
version="$(git show "${BASE_COMMIT}":"packages/${PACKAGE_FOLDER_NAME}/manifest.yml" | yq -r .version)"
version="$(git show "${BASE_COMMIT}":"${PACKAGE_PATH}/manifest.yml" | yq -r .version)"
echo "--- Check if version from ${BASE_COMMIT} (${version}) matches with version from input step ${PACKAGE_VERSION}"
if [[ "${version}" != "${PACKAGE_VERSION}" ]]; then
buildkite-agent annotate "Unexpected version found in packages/${PACKAGE_FOLDER_NAME}/manifest.yml" --style "error"
buildkite-agent annotate "Unexpected version found in ${PACKAGE_PATH}/manifest.yml" --style "error"
exit 1
fi

echo "---Check that this changeset is the one creating the version $PACKAGE_NAME"
if ! git show -p "${BASE_COMMIT}" "packages/${PACKAGE_FOLDER_NAME}/manifest.yml" | grep -E "^\+version: \"{0,1}${PACKAGE_VERSION}" ; then
if ! git show -p "${BASE_COMMIT}" "${PACKAGE_PATH}/manifest.yml" | grep -E "^\+version: \"{0,1}${PACKAGE_VERSION}" ; then
buildkite-agent annotate "This changeset does not creates the version ${PACKAGE_VERSION}" --style "error"
exit 1
fi
Expand Down
42 changes: 21 additions & 21 deletions .buildkite/scripts/build_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,36 @@ report_build_failure() {
}

build_packages() {
pushd packages > /dev/null || exit 1
local packages=""
local version=""
local name=""
local package_zip=""
local package_path=""

for it in $(find . -maxdepth 1 -mindepth 1 -type d); do
local package
local version
local name
package=$(basename "${it}")
echo "Package ${package}: check"
packages=$(list_all_directories)
for package_path in ${packages}; do
pushd "${package_path}" > /dev/null || exit 1
echo "Package \"${package_path}\": check"

pushd "${package}" > /dev/null || exit 1
version=$(yq .version manifest.yml)
name=$(yq .name manifest.yml)

version=$(cat manifest.yml | yq .version)
name=$(cat manifest.yml | yq .name)

local package_zip="${name}-${version}.zip"
package_zip="${name}-${version}.zip"

if is_already_published "${package_zip}" ; then
echo "Skipping. ${package_zip} already published"
popd > /dev/null
continue
fi

echo "Build package as zip: ${package}"
if check_and_build_package "${package}" ; then
echo "Build package as zip: ${package_path}"
if check_and_build_package "${package_path}" ; then
unpublished="true"
else
report_build_failure "${package}"
report_build_failure "${package_path}"
fi
popd > /dev/null || exit 1
done
popd > /dev/null || exit 1
}

if [ "${SKIP_PUBLISHING}" == "true" ] ; then
Expand All @@ -88,13 +87,13 @@ fi

if skipPublishing ; then
echo "packageStoragePublish: not the main branch or a backport branch, nothing will be published"
exit 0
# exit 0
fi
Comment on lines 88 to 91
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium scripts/build_packages.sh:88

When skipPublishing returns true, the script prints "nothing will be published" but continues executing instead of exiting. This causes the script to proceed through expensive build steps (tool installation, package building, artifact copying, pipeline generation) on branches that should skip publishing entirely, wasting resources and potentially causing side effects.

if skipPublishing ; then
    echo "packageStoragePublish: not the main branch or a backport branch, nothing will be published"
-    # exit 0
+    exit 0
 fi
🤖 Copy this AI Prompt to have your agent fix this:
In file .buildkite/scripts/build_packages.sh around lines 88-91:

When `skipPublishing` returns true, the script prints "nothing will be published" but continues executing instead of exiting. This causes the script to proceed through expensive build steps (tool installation, package building, artifact copying, pipeline generation) on branches that should skip publishing entirely, wasting resources and potentially causing side effects.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes related to debugging. It will be reverted before merging.


Comment on lines 87 to 92
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium scripts/build_packages.sh:87

When skipPublishing returns true, the script prints "nothing will be published" but continues executing instead of exiting. It proceeds to build packages, copy artifacts, and generate the signing/publishing pipeline YAML, wasting CI resources on non-main/non-backport branches. If the DRY_RUN or buildkite-agent pipeline upload guards are re-enabled later, packages could be signed and published from arbitrary feature branches.

@@ -88,5 +88,5 @@
 if skipPublishing ; then
     echo "packageStoragePublish: not the main branch or a backport branch, nothing will be published"
-    # exit 0
+    exit 0
 fi
 
 add_bin_path
🤖 Copy this AI Prompt to have your agent fix this:
In file .buildkite/scripts/build_packages.sh around lines 87-92:

When `skipPublishing` returns true, the script prints "nothing will be published" but continues executing instead of exiting. It proceeds to build packages, copy artifacts, and generate the signing/publishing pipeline YAML, wasting CI resources on non-main/non-backport branches. If the `DRY_RUN` or `buildkite-agent pipeline upload` guards are re-enabled later, packages could be signed and published from arbitrary feature branches.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes related to debugging. It will be reverted before merging.

add_bin_path

with_yq
with_go
with_mage
use_elastic_package

echo "--- Build packages"
Expand All @@ -117,7 +116,7 @@ cp "${BUILD_PACKAGES_FOLDER}"/*.zip "${ARTIFACTS_FOLDER}"/

if [ "${DRY_RUN}" == "true" ]; then
echo "DRY_RUN enabled. Publish packages steps skipped."
exit 0
# exit 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium scripts/build_packages.sh:119

When DRY_RUN is true, the script prints the skip message but does not exit, so execution continues into the signing/publishing pipeline generation. If the commented buildkite-agent pipeline upload is re-enabled, a dry run would incorrectly trigger live signing/publishing. Consider uncommenting exit 0 to ensure dry runs actually skip the pipeline steps.

Suggested change
# exit 0
exit 0
🤖 Copy this AI Prompt to have your agent fix this:
In file .buildkite/scripts/build_packages.sh around line 119:

When `DRY_RUN` is `true`, the script prints the skip message but does not exit, so execution continues into the signing/publishing pipeline generation. If the commented `buildkite-agent pipeline upload` is re-enabled, a dry run would incorrectly trigger live signing/publishing. Consider uncommenting `exit 0` to ensure dry runs actually skip the pipeline steps.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will be removed before merging. It was required to be able to test this script/process

fi

# triggering dynamically the steps for signing and publishing
Expand Down Expand Up @@ -148,7 +147,7 @@ steps:
env:
SIGNING_STEP_KEY: "sign-service"
ARTIFACTS_FOLDER: "packageArtifacts"
DRY_RUN: "${DRY_RUN}"
DRY_RUN: "true"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium scripts/build_packages.sh:150

DRY_RUN is hardcoded to "true" on line 150, so the trigger_publish_packages.sh step always runs in dry-run mode regardless of the DRY_RUN environment variable value. Packages will never actually be published when the pipeline intends to run for real. Consider reverting to "${DRY_RUN}" to respect the environment variable.

Suggested change
DRY_RUN: "true"
DRY_RUN: "${DRY_RUN}"
🤖 Copy this AI Prompt to have your agent fix this:
In file .buildkite/scripts/build_packages.sh around line 150:

`DRY_RUN` is hardcoded to `"true"` on line 150, so the `trigger_publish_packages.sh` step always runs in dry-run mode regardless of the `DRY_RUN` environment variable value. Packages will never actually be published when the pipeline intends to run for real. Consider reverting to `"${DRY_RUN}"` to respect the environment variable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes related to debugging. It will be reverted before merging.

agents:
image: "${LINUX_AGENT_IMAGE}"
cpu: "8"
Expand All @@ -158,4 +157,5 @@ steps:
allow_failure: false
EOF

buildkite-agent pipeline upload "${PIPELINE_FILE}"
cat "${PIPELINE_FILE}"
# buildkite-agent pipeline upload "${PIPELINE_FILE}"
Comment on lines 159 to +161
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical scripts/build_packages.sh:159

The buildkite-agent pipeline upload command is replaced with cat, so the pipeline that signs and publishes packages is never uploaded to Buildkite. Built packages will remain in artifacts but never reach the package registry.

 cat "${PIPELINE_FILE}"
-# buildkite-agent pipeline upload "${PIPELINE_FILE}"
+buildkite-agent pipeline upload "${PIPELINE_FILE}"
🤖 Copy this AI Prompt to have your agent fix this:
In file .buildkite/scripts/build_packages.sh around lines 159-161:

The `buildkite-agent pipeline upload` command is replaced with `cat`, so the pipeline that signs and publishes packages is never uploaded to Buildkite. Built packages will remain in artifacts but never reach the package registry.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change to allow debugging the script safely. This will be reverted before merging the PR.

Loading
Loading