Skip to content
Closed
90 changes: 90 additions & 0 deletions .buildkite/job-version-bump-phase2-minor.json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env python
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0 and the following additional limitation. Functionality enabled by the
# files subject to the Elastic License 2.0 may only be used in production when
# invoked by an Elasticsearch process with a license key installed that permits
# use of machine learning features. You may not use this file except in
# compliance with the Elastic License 2.0 and the foregoing additional
# limitation.
#
# Phase 2 of the ml-cpp version bump pipeline for WORKFLOW=minor (uploaded by
# dev-tools/version_bump_upload_phase2.sh).

import contextlib
import json
import os


WOLFI_IMAGE = "docker.elastic.co/release-eng/wolfi-build-essential-release-eng:latest"


def main():
wolfi_agent = {
"image": WOLFI_IMAGE,
"cpu": "250m",
"memory": "512Mi",
}

pipeline_steps = [
{
"group": "Minor version freeze",
"key": "minor-freeze",
"steps": [
{
"label": "Create release branch ${BRANCH}",
"key": "create-minor-branch",
"agents": dict(wolfi_agent),
"command": [
"dev-tools/create_minor_branch.sh",
],
},
{
"label": "Bump main to next minor",
"key": "bump-main-minor-freeze",
"agents": dict(wolfi_agent),
"env": {
"VERSION_BUMP_MERGE_AUTO": os.environ.get(
"VERSION_BUMP_MERGE_AUTO", "true"
),
},
"command": [
"dev-tools/bump_main_minor_freeze.sh",
],
},
],
},
{
"label": "Notify :slack: — minor freeze PR needs approval",
"key": "queue-slack-notify",
"depends_on": "minor-freeze",
"command": [
".buildkite/pipelines/send_slack_version_bump_notification.sh",
],
"agents": dict(wolfi_agent),
},
{
"label": "Fetch DRA Artifacts",
"key": "fetch-dra-artifacts",
"depends_on": "queue-slack-notify",
"agents": {
**wolfi_agent,
"ephemeralStorage": "1Gi",
},
"command": [
"python3 dev-tools/wait_version_bump_dra.py",
],
"timeout_in_minutes": 240,
"retry": {
"automatic": [{"exit_status": "*", "limit": 2}],
"manual": {"permit_on_passed": True},
},
},
]

print(json.dumps({"steps": pipeline_steps}, indent=2))


if __name__ == "__main__":
with contextlib.suppress(KeyboardInterrupt):
main()
3 changes: 1 addition & 2 deletions .buildkite/job-version-bump-phase2.json.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def main():
"ephemeralStorage": "1Gi",
},
"command": [
"python3",
"dev-tools/wait_version_bump_dra.py",
"python3 dev-tools/wait_version_bump_dra.py",
],
"timeout_in_minutes": 240,
"retry": {
Expand Down
71 changes: 60 additions & 11 deletions .buildkite/pipelines/send_slack_version_bump_notification.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,69 @@ fi

pr_url=""
changed="false"
minor_branch_created="false"
workflow="${WORKFLOW:-patch}"
pr_url=$(buildkite-agent meta-data get "ml_cpp_version_bump_pr_url" 2>/dev/null || true)
changed=$(buildkite-agent meta-data get "ml_cpp_version_bump_changed" 2>/dev/null || echo "false")
# Meta-data values must not contain stray whitespace (Breaks truthiness.)
minor_branch_created=$(buildkite-agent meta-data get "ml_cpp_minor_branch_created" 2>/dev/null || echo "false")
# Meta-data values must not contain stray whitespace (breaks truthiness.)
pr_url=$(echo -n "${pr_url}" | tr -d '\r')
changed=$(echo -n "${changed}" | tr -d '\r')
minor_branch_created=$(echo -n "${minor_branch_created}" | tr -d '\r')
workflow=$(echo -n "${workflow}" | tr -d '\r')

if [[ -z "${pr_url}" && "${changed}" != "true" ]]; then
echo "No version-bump PR opened (pr_url empty, ml_cpp_version_bump_changed=${changed}); skipping Slack notification."
if [[ "${workflow}" == "minor" ]]; then
if [[ "${minor_branch_created}" != "true" && "${changed}" != "true" ]]; then
echo "Minor freeze: no branch created and no main-bump PR; skipping Slack notification."
exit 0
fi
branch_line="Release branch \${BRANCH:-\"(unset)\"} created (or already present) at \${NEW_VERSION:-\"(unset)\"}."
if [[ -n "${pr_url}" ]]; then
pr_line="Main bump pull request (approval required): ${pr_url}"
elif [[ "${changed}" == "true" ]]; then
pr_line="DRY RUN — main bump PR simulated (no URL)."
else
pr_line="Main bump — no PR required (already at derived next minor)."
fi
slack_title="**Minor feature freeze — action may be required**"
(
cat <<EOF
steps:
- label: "Schedule :slack: notification (version bump)"
command: "echo schedule :slack: notification"
notify:
- slack:
channels:
- "${CHANNEL}"
message: |
${slack_title}
${branch_line}
${pr_line}
WORKFLOW: \${WORKFLOW:-"(unset)"}
Branch: \${BUILDKITE_BRANCH}
NEW_VERSION: \${NEW_VERSION:-"(unset)"}
BRANCH (param): \${BRANCH:-"(unset)"}
VERSION_BUMP_MERGE_AUTO: \${VERSION_BUMP_MERGE_AUTO:-"(unset)"}
DRY_RUN: \${DRY_RUN:-"(unset)"}
Pipeline: \${BUILDKITE_BUILD_URL}
Build: \${BUILDKITE_BUILD_NUMBER}
Please review and approve the main bump pull request when present (subject to branch protection).
EOF
) | buildkite-agent pipeline upload
exit 0
fi

if [[ -z "${pr_url}" && "${changed}" == "true" ]]; then
body_line="DRY RUN — no pull request URL (simulated bump)."
else
body_line="Pull request (approval required): ${pr_url}"
if [[ -z "${pr_url}" && "${changed}" != "true" ]]; then
echo "No version-bump PR opened (pr_url empty, ml_cpp_version_bump_changed=${changed}); skipping Slack notification."
exit 0
fi

if [[ -z "${pr_url}" && "${changed}" == "true" ]]; then
body_line="DRY RUN — no pull request URL (simulated bump)."
else
body_line="Pull request (approval required): ${pr_url}"
fi
slack_title="**Version bump PR — approval required**"
slack_body="${body_line}"
fi

(
Expand All @@ -63,15 +111,16 @@ steps:
channels:
- "${CHANNEL}"
message: |
**Version bump PR — approval required**
${body_line}
${slack_title}
${slack_body}
WORKFLOW: \${WORKFLOW:-"(unset)"}
Branch: \${BUILDKITE_BRANCH}
NEW_VERSION: \${NEW_VERSION:-"(unset)"}
BRANCH (param): \${BRANCH:-"(unset)"}
VERSION_BUMP_MERGE_AUTO: \${VERSION_BUMP_MERGE_AUTO:-"(unset)"}
DRY_RUN: \${DRY_RUN:-"(unset)"}
Pipeline: \${BUILDKITE_BUILD_URL}
Build: \${BUILDKITE_BUILD_NUMBER}
Please review and approve this pull request so it can merge (subject to branch protection).
Please review and approve the main bump pull request when present (subject to branch protection).
EOF
) | buildkite-agent pipeline upload
36 changes: 0 additions & 36 deletions .buildkite/pipelines/send_version_bump_notification.sh

This file was deleted.

Loading