forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Mirror upstream elastic/elasticsearch#134118 for AI review (snapshot of HEAD tree) #130
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
Closed
+141
−1
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
steps: | ||
- command: .buildkite/scripts/trigger-if-java-ea-new-build.sh | ||
env: | ||
RECENT_TIME_WINDOW: "24" # time window to consider a build as new in hours | ||
agents: | ||
image: "docker.elastic.co/ci-agent-images/eck-region/buildkite-agent:1.5" | ||
memory: "4G" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# | ||
# 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
# Public License v 1"; you may not use this file except in compliance with, at | ||
# your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
# License v3.0 only", or the "Server Side Public License, v 1". | ||
# | ||
|
||
#!/bin/bash | ||
|
||
# Allow overriding the time window (in hours) to check for new builds, defaults to 24 | ||
RECENT_TIME_WINDOW=${RECENT_TIME_WINDOW:-24} | ||
|
||
# Extract current JDK major version from bundled_jdk in version.properties | ||
CURRENT_JDK=$(grep "^bundled_jdk =" build-tools-internal/version.properties | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1) | ||
TARGET_JDK=$((CURRENT_JDK + 1)) | ||
|
||
echo "Current JDK major version: $CURRENT_JDK" | ||
echo "Target JDK major version: $TARGET_JDK" | ||
|
||
# Query Elasticsearch JDK archive for available JDKs | ||
JDK_ARCHIVE_URL="https://builds.es-jdk-archive.com/jdks/openjdk/recent.json" | ||
echo "Querying JDK archive: $JDK_ARCHIVE_URL" | ||
|
||
# Fetch JDK info and filter for target major version | ||
JDK_DATA=$(curl -s "$JDK_ARCHIVE_URL") | ||
|
||
if [[ -z "$JDK_DATA" ]]; then | ||
echo "Failed to fetch JDK data from archive" | ||
exit 1 | ||
fi | ||
|
||
# Find the latest build for the target JDK version | ||
LATEST_BUILD=$(echo "$JDK_DATA" | jq -r --arg target "$TARGET_JDK" ' | ||
.majors[$target].builds | | ||
sort_by(.archived_at) | | ||
last' | ||
) | ||
|
||
if [[ "$LATEST_BUILD" == "null" || -z "$LATEST_BUILD" ]]; then | ||
echo "No builds found for JDK $TARGET_JDK" | ||
exit 1 | ||
fi | ||
|
||
# Extract timestamp and JDK identifier | ||
TIMESTAMP=$(echo "$LATEST_BUILD" | jq -r '.archived_at') | ||
JDK_IDENTIFIER=$(echo "$LATEST_BUILD" | jq -r '.id') | ||
|
||
echo "Latest JDK ${TARGET_JDK} build from ES archive:" | ||
echo " Timestamp: $TIMESTAMP" | ||
echo " JDK Identifier: $JDK_IDENTIFIER" | ||
|
||
# Set variables for use in the pipeline trigger | ||
jdkbuild="$JDK_IDENTIFIER" | ||
jdk_timestamp="$TIMESTAMP" | ||
|
||
# Check if timestamp is within last 24 hours | ||
CURRENT_TIME=$(date +%s) | ||
BUILD_TIME=$(date -d "$TIMESTAMP" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S" "${TIMESTAMP%Z}" +%s 2>/dev/null || echo "0") | ||
|
||
if [[ "$BUILD_TIME" == "0" ]]; then | ||
echo "Failed to parse timestamp: $TIMESTAMP" | ||
SHOULD_TRIGGER="false" | ||
else | ||
TIME_DIFF=$((CURRENT_TIME - BUILD_TIME)) | ||
TIME_WINDOW=$((RECENT_TIME_WINDOW * 60 * 60)) | ||
|
||
if [[ $TIME_DIFF -lt $TIME_WINDOW ]]; then | ||
echo "Build is recent (less than ${RECENT_TIME_WINDOW}h old)" | ||
SHOULD_TRIGGER="true" | ||
else | ||
echo "Build is older than ${RECENT_TIME_WINDOW} hours" | ||
SHOULD_TRIGGER="false" | ||
fi | ||
fi | ||
|
||
echo "SHOULD_TRIGGER: $SHOULD_TRIGGER" | ||
|
||
|
||
if [[ "$SHOULD_TRIGGER" == "true" ]]; then | ||
EFFECTIVE_START_DATE=$(date -u -d "@$BUILD_TIME" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u -r "$BUILD_TIME" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || echo "") | ||
echo "Triggering performance-esbench-jdk for new jdk build $JDK_IDENTIFIER" | ||
cat << EOF | buildkite-agent pipeline upload | ||
steps: | ||
- trigger: elasticsearch-performance-esbench-jdk | ||
label: Triggering performance-esbench-jdk for new jdk build $JDK_IDENTIFIER | ||
async: true | ||
build: | ||
branch: "$BUILDKITE_BRANCH" | ||
env: | ||
EFFECTIVE_START_DATE: "$EFFECTIVE_START_DATE" | ||
EXECUTION_MODE: "start-run" | ||
EOF | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the shebang to the very first line.
With the license block sitting above
#!/bin/bash
, the kernel ignores the shebang when the file is executed directly, so Buildkite will run the script under/bin/sh
. The script relies on bash-specific features ([[ … ]]
, arithmetic expansion, etc.), so it will break. Put the shebang on Line 1 and keep the license comment immediately after it.📝 Committable suggestion
🧰 Tools
🪛 Shellcheck (0.11.0)
[error] 10-10: The shebang must be on the first line. Delete blanks and move comments.
(SC1128)
🤖 Prompt for AI Agents