Skip to content
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

ci: use .java-version and prepare to use VM with installed tools in BK #241

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
27 changes: 17 additions & 10 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,23 @@ echo "--- Configure git context :git:"
git config --global user.email "[email protected]"
git config --global user.name "apmmachine"

echo "--- Install JDK17 :java:"
JAVA_URL=https://jvm-catalog.elastic.co/jdk
JAVA_HOME=$(pwd)/.openjdk17
JAVA_PKG="$JAVA_URL/latest_openjdk_17_linux.tar.gz"
curl -L --output /tmp/jdk.tar.gz "$JAVA_PKG"
mkdir -p "$JAVA_HOME"
tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1

# Configure the java version
JAVA_VERSION=$(cat .java-version | xargs | tr -dc '[:print:]')
JAVA_HOME="${HOME}/.java/openjdk${JAVA_VERSION}"
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
PATH="${JAVA_HOME}/bin:$PATH"
v1v marked this conversation as resolved.
Show resolved Hide resolved
export PATH

java -version || true
# Fallback to install at runtime
if [ ! -d "${JAVA_HOME}" ] ; then
# This should not be the case normally untless the .java-version file has been changed
# and the VM Image is not yet available with the latest version.
echo "--- Install JDK${JAVA_VERSION} :java:"
JAVA_URL=https://jvm-catalog.elastic.co/jdk
JAVA_PKG="${JAVA_URL}/latest_openjdk_${JAVA_VERSION}_linux.tar.gz"
curl -L --output /tmp/jdk.tar.gz "$JAVA_PKG"
v1v marked this conversation as resolved.
Show resolved Hide resolved
mkdir -p "$JAVA_HOME"
tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1
v1v marked this conversation as resolved.
Show resolved Hide resolved
fi

java -version
1 change: 1 addition & 0 deletions .buildkite/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
agents:
provider: "gcp"
#image: "family/ecs-logging-java-ubuntu-2204"

steps:
- label: "Run the release"
Expand Down
1 change: 1 addition & 0 deletions .buildkite/snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
agents:
provider: "gcp"
#image: "family/ecs-logging-java-ubuntu-2204"

steps:
- label: "Run the snapshot"
Expand Down
15 changes: 10 additions & 5 deletions .ci/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ echo $PATH
java -version

set +x
echo "--- Release the binaries to Maven Central :maven:"
if [[ "${dry_run}" == "true" ]] ; then
./mvnw -V -s .ci/settings.xml -Pgpg clean package --batch-mode | tee release.txt
else
./mvnw -V -s .ci/settings.xml -Pgpg clean deploy --batch-mode | tee release.txt
# Default in dry-run mode
GOAL="install"
v1v marked this conversation as resolved.
Show resolved Hide resolved
DRY_RUN_MSG="(dry-run)"
# Otherwise, a RELEASE
if [[ "$dry_run" == "false" ]] ; then
GOAL="deploy"
DRY_RUN_MSG=""
fi

echo "--- Release the binaries to Maven Central :maven: [./mvnw $GOAL)] $DRY_RUN_MSG"
v1v marked this conversation as resolved.
Show resolved Hide resolved
./mvnw -V -s .ci/settings.xml -Pgpg clean $GOAL -DskipTests --batch-mode | tee release.txt
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
./mvnw -V -s .ci/settings.xml -Pgpg clean $GOAL -DskipTests --batch-mode | tee release.txt
./mvnw -V -s .ci/settings.xml -Pgpg clean ${GOAL} -DskipTests --batch-mode | tee release.txt

15 changes: 10 additions & 5 deletions .ci/snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ echo $PATH
java -version

set +x
echo "--- Deploy the snapshot :package:"
if [[ "$dry_run" == "true" ]] ; then
./mvnw -V -s .ci/settings.xml -Pgpg clean package --batch-mode | tee snapshot.txt
else
./mvnw -V -s .ci/settings.xml -Pgpg clean deploy --batch-mode | tee snapshot.txt
# Default in dry-run mode
GOAL="install"
v1v marked this conversation as resolved.
Show resolved Hide resolved
DRY_RUN_MSG="(dry-run)"
# Otherwise, a RELEASE
if [[ "$dry_run" == "false" ]] ; then
GOAL="deploy"
DRY_RUN_MSG=""
fi

echo "--- Deploy the snapshot :package: [./mvnw $GOAL)] $DRY_RUN_MSG"
./mvnw -V -s .ci/settings.xml -Pgpg clean $GOAL -DskipTests --batch-mode | tee release.txt
v1v marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 1 addition & 5 deletions .github/workflows/maven-goal/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ name: maven-goal
description: Install specific JDK and run a command

inputs:
version:
description: 'Java version'
required: true
default: '17'
distribution:
description: 'Java distribution'
required: true
Expand All @@ -26,7 +22,7 @@ runs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.version }}
java-version-file: .java-version
distribution: ${{ inputs.distribution }}
cache: 'maven'
- run: ${{ inputs.command }}
Expand Down
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17
Loading