Skip to content

Commit 1a7a941

Browse files
authored
buildkite: use VM with the installed tools (#163)
1 parent 091edb2 commit 1a7a941

File tree

9 files changed

+44
-66
lines changed

9 files changed

+44
-66
lines changed

.buildkite/hooks/pre-command

100644100755
Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,31 @@ if [[ "$BUILDKITE_COMMAND" =~ .*"upload".* ]]; then
1515
fi
1616

1717
if [ "$BUILDKITE_PIPELINE_SLUG" == "elastic-otel-java-snapshot" ]; then
18-
source .buildkite/hooks/prepare-release.sh
18+
source .buildkite/hooks/prepare-release.sh
1919
fi
2020

2121
if [ "$BUILDKITE_PIPELINE_SLUG" == "elastic-otel-java-release" ]; then
22-
source .buildkite/hooks/prepare-release.sh
22+
source .buildkite/hooks/prepare-release.sh
2323
fi
2424

25-
# Run always
26-
source .buildkite/hooks/prepare-common.sh
25+
# Configure the java version
26+
JAVA_VERSION=$(cat .java-version | xargs | tr -dc '[:print:]')
27+
JAVA_HOME="${HOME}/.java/openjdk${JAVA_VERSION}"
28+
export JAVA_HOME
29+
PATH="${JAVA_HOME}/bin:$PATH"
30+
export PATH
2731

32+
# Fallback to install at runtime
33+
if [ ! -d "${JAVA_HOME}" ] ; then
34+
# This should not be the case normally untless the .java-version file has been changed
35+
# and the VM Image is not yet available with the latest version.
36+
echo "--- Install JDK${JAVA_VERSION} :java:"
37+
JAVA_URL=https://jvm-catalog.elastic.co/jdk
38+
JAVA_PKG="${JAVA_URL}/latest_openjdk_${JAVA_VERSION}_linux.tar.gz"
39+
curl -L --output /tmp/jdk.tar.gz "${JAVA_PKG}"
40+
mkdir -p "${JAVA_HOME}"
41+
tar --extract --file /tmp/jdk.tar.gz --directory "${JAVA_HOME}" --strip-components 1
42+
fi
43+
44+
# Validate the java version
45+
java -version

.buildkite/hooks/prepare-common.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

.buildkite/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
agents:
22
provider: "gcp"
3+
image: "family/elastic-otel-java-ubuntu-2204"
34

45
steps:
56
- label: "Build and publish release"

.buildkite/snapshot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
agents:
22
provider: "gcp"
3+
image: "family/elastic-otel-java-ubuntu-2204"
34

45
steps:
56
- label: "Build and publish snapshot"

.ci/release.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ echo $PATH
2323
java -version
2424

2525
publishArg=''
26-
if [[ "$dry_run" == "true" ]] ; then
27-
echo "--- Build and publish the release :package: (dry-run)"
28-
publishArg='publishAllPublicationsToDryRunRepository'
29-
else
26+
if [[ "$dry_run" == "false" ]] ; then
3027
echo "--- Build and publish the release :package:"
3128
publishArg='publishToSonatype closeAndReleaseStagingRepository'
29+
else
30+
echo "--- Build and publish the release :package: (dry-run)"
31+
publishArg='publishAllPublicationsToDryRunRepository'
3232
fi
3333

3434
./gradlew \

.ci/snapshot.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ echo $PATH
2323
java -version
2424

2525
publishArg=''
26-
if [[ "$dry_run" == "true" ]] ; then
27-
echo "--- Build and publish the snapshot :package: (dry-run)"
28-
publishArg='publishAllPublicationsToDryRunRepository'
29-
else
26+
if [[ "$dry_run" == "false" ]] ; then
3027
echo "--- Build and publish the snapshot :package:"
3128
publishArg='publishToSonatype closeAndReleaseStagingRepository'
29+
else
30+
echo "--- Build and publish the snapshot :package: (dry-run)"
31+
publishArg='publishAllPublicationsToDryRunRepository'
3232
fi
3333

3434
./gradlew \

.github/workflows/build.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,15 @@ jobs:
2626
- name: Checkout
2727
uses: actions/checkout@v4
2828

29-
- name: Gradle JDK
30-
uses: actions/setup-java@v4
31-
with:
32-
distribution: temurin
33-
java-version: 17
34-
cache: gradle
35-
3629
- name: Gradle build, test and check
37-
uses: gradle/gradle-build-action@v3
30+
uses: ./.github/workflows/gradle-goal
3831
with:
39-
arguments: check
32+
command: "./gradlew check"
4033

34+
- name: Warmup gradle wrapper
35+
uses: ./.github/workflows/gradle-goal
36+
with:
37+
command: "./gradlew check"
4138
- name: Store test results
4239
if: success() || failure()
4340
uses: actions/upload-artifact@v3

.github/workflows/gradle-goal/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ name: gradle-goal
44
description: Install specific JDK and run a command
55

66
inputs:
7-
version:
8-
description: 'Java version'
9-
required: true
10-
default: '17'
7+
java-version-file:
8+
description: 'The path to the .java-version file'
9+
required: false
10+
default: '.java-version'
1111
distribution:
1212
description: 'Java distribution'
1313
required: true
@@ -26,7 +26,7 @@ runs:
2626
- name: Set up JDK
2727
uses: actions/setup-java@v4
2828
with:
29-
java-version: ${{ inputs.version }}
29+
java-version-file: ${{ inputs.java-version-file }}
3030
distribution: ${{ inputs.distribution }}
3131
cache: 'gradle'
3232
- run: ${{ inputs.command }}

.java-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
17

0 commit comments

Comments
 (0)