Skip to content

Commit d839f8e

Browse files
authored
ci: use VM with the installed tools and fallback otherwise (#274)
1 parent beeb312 commit d839f8e

File tree

5 files changed

+65
-24
lines changed

5 files changed

+65
-24
lines changed

.buildkite/hooks/pre-command

+34-16
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,42 @@ echo "--- Configure git context :git:"
7070
git config --global user.email "infra-root+apmmachine@elastic.co"
7171
git config --global user.name "apmmachine"
7272

73-
echo "--- Install JDK11"
74-
JAVA_URL=https://jvm-catalog.elastic.co/jdk
75-
JAVA_HOME=$(pwd)/.openjdk11
76-
JAVA_PKG="$JAVA_URL/latest_openjdk_11_linux.tar.gz"
77-
curl -L --output /tmp/jdk.tar.gz "$JAVA_PKG"; \
78-
mkdir -p "$JAVA_HOME"; \
79-
tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1
73+
# Configure the java version
74+
JAVA_VERSION=$(cat .java-version | xargs | tr -dc '[:print:]')
75+
JAVA_HOME="${HOME}/.java/openjdk${JAVA_VERSION}"
8076
export JAVA_HOME
81-
export PATH=$JAVA_HOME/bin:$PATH
77+
PATH="${JAVA_HOME}/bin:$PATH"
78+
export PATH
8279

83-
echo "--- Install Android SDK"
84-
# Configure Android SDK using the script
85-
./install-android-sdk.sh
86-
export PATH=${PATH}:$PWD/.android-sdk/tools/bin/
87-
export ANDROID_HOME=$PWD/.android-sdk
80+
# Fallback to install at runtime
81+
if [ ! -d "${JAVA_HOME}" ] ; then
82+
# This should not be the case normally untless the .java-version file has been changed
83+
# and the VM Image is not yet available with the latest version.
84+
echo "--- Install JDK${JAVA_VERSION} :java:"
85+
JAVA_URL=https://jvm-catalog.elastic.co/jdk
86+
JAVA_PKG="${JAVA_URL}/latest_openjdk_${JAVA_VERSION}_linux.tar.gz"
87+
curl -L --output /tmp/jdk.tar.gz "${JAVA_PKG}"
88+
mkdir -p "${JAVA_HOME}"
89+
tar --extract --file /tmp/jdk.tar.gz --directory "${JAVA_HOME}" --strip-components 1
90+
fi
8891

89-
export JAVA_HOME
90-
PATH=$JAVA_HOME/bin:$PATH
92+
# Configure the Android SDK
93+
ANDROID_HOME="${PWD}/.android-sdk"
94+
PATH="${PATH}:${ANDROID_HOME}/tools/bin"
95+
export ANDROID_HOME
9196
export PATH
9297

93-
java -version || true
98+
# Fallback to install at runtime
99+
if [ ! -d "${ANDROID_HOME}" ] ; then
100+
# This should not be the case normally.
101+
echo "--- Install Android SDK"
102+
./install-android-sdk.sh
103+
fi
104+
105+
# Validate java is installed
106+
echo "--- Validate java is installed :java:"
107+
java -version
108+
109+
# Validate Android SDK is installed
110+
echo "--- Validate Android SDK :android:"
111+
sdkmanager --list

.buildkite/release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
agents:
22
provider: "gcp"
3+
image: "family/apm-agent-android-ubuntu-2204"
34

45
steps:
56
- label: "Run the release"

.ci/release.sh

+10-8
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,22 @@ set +x
2020
export COMMON_GRADLE_DEPLOY_PARAMS="-Prelease=true -Pversion_override=${version_override_specifier} --stacktrace"
2121

2222
if [[ "$target_specifier" == "all" || "$target_specifier" == "mavenCentral" ]]; then
23-
echo "--- Release the binaries to Maven Central"
24-
if [[ "$dry_run" == "true" ]] ; then
25-
echo './gradlew publishElasticPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository'
26-
else
23+
if [[ "$dry_run" == "false" ]] ; then
24+
echo "--- Release the binaries to Maven Central"
2725
./gradlew publishElasticPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository $COMMON_GRADLE_DEPLOY_PARAMS
26+
else
27+
echo "--- Release the binaries to Maven Central :package: (dry-run)"
28+
./gradlew tasks
2829
fi
2930
fi
3031

3132
if [[ "$target_specifier" == "all" || "$target_specifier" == "pluginPortal" ]]; then
32-
echo "--- Release the binaries to the Gradle Plugin portal"
33-
if [[ "$dry_run" == "true" ]] ; then
34-
echo './gradlew publishPlugins'
35-
else
33+
if [[ "$dry_run" == "false" ]] ; then
34+
echo "--- Release the binaries to the Gradle Plugin portal"
3635
./gradlew publishPlugins -Pgradle.publish.key=$PLUGIN_PORTAL_KEY -Pgradle.publish.secret=$PLUGIN_PORTAL_SECRET $COMMON_GRADLE_DEPLOY_PARAMS
36+
else
37+
echo "--- Release the binaries to Gradle Plugin portal :package: (dry-run)"
38+
./gradlew tasks
3739
fi
3840
fi
3941
set -x

.github/workflows/ci.yml

+19
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,22 @@ jobs:
5858
with:
5959
needs: ${{ toJSON(needs) }}
6060
- run: ${{ steps.check.outputs.isSuccess }}
61+
62+
test-release:
63+
runs-on: ubuntu-latest
64+
if: github.event_name != 'pull_request'
65+
steps:
66+
- id: buildkite
67+
name: Run Release dry-run
68+
uses: elastic/apm-pipeline-library/.github/actions/buildkite@current
69+
with:
70+
vaultUrl: ${{ secrets.VAULT_ADDR }}
71+
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }}
72+
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }}
73+
pipeline: apm-agent-android-release
74+
waitFor: true
75+
printBuildLogs: false
76+
buildEnvVars: |
77+
branch_specifier=main
78+
target_specifier=all
79+
dry_run=true

.java-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11

0 commit comments

Comments
 (0)