-
Notifications
You must be signed in to change notification settings - Fork 327
ci: use .java-version and prepare to use VM with installed tools in BK #3554
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
Changes from all commits
aac5630
4ca2767
c37a155
3f3f2e7
ed83ffa
c0a9a18
0663807
02a306f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,17 +1,23 @@ | ||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||
| set -euo pipefail | ||||||||||||||
|
|
||||||||||||||
| echo "--- Install JDK17 :java:" | ||||||||||||||
| # JDK version is defined in two different locations, here and .github/workflows/maven-goal/action.yml | ||||||||||||||
| 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" | ||||||||||||||
| 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" | ||||||||||||||
| mkdir -p "$JAVA_HOME" | ||||||||||||||
| tar --extract --file /tmp/jdk.tar.gz --directory "$JAVA_HOME" --strip-components 1 | ||||||||||||||
|
Comment on lines
+18
to
+20
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| java -version | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| agents: | ||
| provider: "gcp" | ||
| #image: "family/apm-agent-java-ubuntu-2204" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Follow-up |
||
|
|
||
| steps: | ||
| - label: "Run the snapshot" | ||
|
|
@@ -11,4 +12,5 @@ steps: | |
|
|
||
| notify: | ||
| - slack: "#apm-agent-java" | ||
| if: 'build.state != "passed"' | ||
| # skip slack messages if no failures and dry-run mode | ||
| if: 'build.state != "passed" && build.env("dry_run") == "false"' | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,5 +21,14 @@ echo $PATH | |||||||||
| java -version | ||||||||||
|
|
||||||||||
| set +x | ||||||||||
| echo "--- Deploy the release :package:" | ||||||||||
| ./mvnw -V -s .ci/settings.xml -Pgpg clean deploy -DskipTests --batch-mode | tee release.txt | ||||||||||
| # Default in dry-run mode | ||||||||||
| GOAL="install" | ||||||||||
| DRY_RUN_MSG="(dry-run)" | ||||||||||
| # Otherwise, a RELEASE | ||||||||||
| if [[ "$dry_run" == "false" ]] ; then | ||||||||||
| GOAL="deploy" | ||||||||||
| DRY_RUN_MSG="" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| echo "--- Deploy the release :package: [./mvnw $GOAL)] $DRY_RUN_MSG" | ||||||||||
| ./mvnw -V -s .ci/settings.xml -Pgpg clean $GOAL -DskipTests --batch-mode | tee release.txt | ||||||||||
|
Comment on lines
+33
to
+34
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,9 +23,14 @@ echo $PATH | |||||||||
| java -version | ||||||||||
|
|
||||||||||
| set +x | ||||||||||
| echo "--- Deploy the snapshot :package:" | ||||||||||
| if [[ "$dry_run" == "true" ]] ; then | ||||||||||
| echo './mvnw -V -s .ci/settings.xml -Pgpg clean deploy -DskipTests --batch-mode' | ||||||||||
| else | ||||||||||
| ./mvnw -V -s .ci/settings.xml -Pgpg clean deploy -DskipTests --batch-mode | tee snapshot.txt | ||||||||||
| # Default in dry-run mode | ||||||||||
| GOAL="install" | ||||||||||
| DRY_RUN_MSG="(dry-run)" | ||||||||||
| # Otherwise, a snapshot | ||||||||||
| if [[ "$dry_run" == "false" ]] ; then | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| 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 snapshot.txt | ||||||||||
|
Comment on lines
+35
to
+36
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
|
|
||
| name: common build tasks | ||
| description: Install specific JDK and run a command | ||
|
|
||
| inputs: | ||
| test-java-version: | ||
| description: 'Testing Java version' | ||
| required: true | ||
| default: '17' | ||
| test-java-distribution: | ||
| description: 'Testing Java distribution' | ||
| required: true | ||
| default: 'temurin' | ||
| command: | ||
| description: 'Command to execute' | ||
| required: true | ||
| shell: | ||
| description: 'Default shell' | ||
| default: 'bash' | ||
| required: false | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Set up testing JDK | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: ${{ inputs.test-java-version}} | ||
| distribution: ${{ inputs.test-java-distribution}} | ||
|
|
||
| - name: Set up TEST_JAVA_BINARY environment variable | ||
| shell: bash | ||
| run: | | ||
| major_version="$(echo '${{ inputs.test-java-version }}' | sed 's/\([0-9]*\).*/\1/')" | ||
| java_home_var=JAVA_HOME_${major_version}_${{ runner.arch }} | ||
| echo "TEST_JAVA_BINARY=${!java_home_var}/bin/java" >> $GITHUB_ENV | ||
|
|
||
| - uses: ./.github/workflows/maven-goal | ||
| with: | ||
| command: ${{ inputs.command }} | ||
| shell: ${{ inputs.shell }} | ||
| env: | ||
| TEST_JAVA_BINARY: ${{ env.TEST_JAVA_BINARY }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 17 |
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.