Skip to content

Commit

Permalink
Share steps to build GraalVM JDK.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Mar 4, 2024
1 parent c425360 commit 19b3c6b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 87 deletions.
62 changes: 62 additions & 0 deletions .github/actions/build-graalvm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build GraalVM JDK
description: 'Build GraalVM JDK and set up environment for testing'

inputs:
java-version:
description: 'Java version to use'
required: false
default: ''

runs:
using: 'composite'
steps:
- name: Checkout oracle/graal
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up environment variables
run: |
echo "GRAALVM_HOME=${{ github.workspace }}/graalvm" >> ${GITHUB_ENV}
echo "LABSJDK_HOME=${{ github.workspace }}/labsjdk" >> ${GITHUB_ENV}
echo "MX_GIT_CACHE=refcache" >> ${GITHUB_ENV}
echo "MX_PATH=${{ github.workspace }}/mx" >> ${GITHUB_ENV}
echo "MX_PYTHON=python3.8" >> ${GITHUB_ENV}
echo "MX_VERSION=$(jq -r '.mx_version' common.json)" >> ${GITHUB_ENV}
# Workaround testsuite locale issue
echo "LANG=en_US.UTF-8" >> ${GITHUB_ENV}
# Enforce experimental option checking in CI (GR-47922)
echo "NATIVE_IMAGE_EXPERIMENTAL_OPTIONS_ARE_FATAL=true" >> ${GITHUB_ENV}
- name: Checkout graalvm/mx
uses: actions/checkout@v4
with:
repository: graalvm/mx
fetch-depth: 1
ref: ${{ env.MX_VERSION }}
path: ${{ env.MX_PATH }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Update mx cache
uses: actions/cache@v4
with:
path: ~/.mx
key: ${{ runner.os }}-mx-${{ hashFiles('**/suite.py') }}
restore-keys: ${{ runner.os }}-mx-
- name: Fetch LabsJDK
run: |
mkdir jdk-dl
${MX_PATH}/mx --java-home= fetch-jdk --jdk-id labsjdk-ce-latest --to jdk-dl --alias ${LABSJDK_HOME}
- name: Build GraalVM JDK
run: |
cd substratevm
${MX_PATH}/mx --java-home=${LABSJDK_HOME} --native=native-image --components="Native Image" build
ln -s $(${MX_PATH}/mx --java-home=${LABSJDK_HOME} --native=native-image --components="Native Image" graalvm-home) ${GRAALVM_HOME}
${GRAALVM_HOME}/bin/native-image --version
- name: Set up JAVA_HOME
if: ${{ inputs.java-version }} != ''
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: '${{ inputs.java-version }}'

48 changes: 3 additions & 45 deletions .github/workflows/micronaut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,8 @@ on:
workflow_dispatch:

env:
GRAALVM_HOME: ${{ github.workspace }}/graalvm
JAVA_HOME: ${{ github.workspace }}/labsjdk
LANG: en_US.UTF-8
MICRONAUT_CORE_PATH: ${{ github.workspace }}/micronaut-core
MICRONAUT_JDK_VERSION: 21
MX_GIT_CACHE: refcache
MX_PATH: ${{ github.workspace }}/mx
MX_PYTHON: python3.8
# Enforce experimental option checking in CI (GR-47922)
NATIVE_IMAGE_EXPERIMENTAL_OPTIONS_ARE_FATAL: "true"
MICRONAUT_JAVA_VERSION: 21

permissions:
contents: read # to fetch code (actions/checkout)
Expand All @@ -72,44 +64,10 @@ jobs:
runs-on: ubuntu-20.04
if: (github.event_name == 'schedule' && github.repository == 'oracle/graal') || (github.event_name != 'schedule')
steps:
- name: Checkout oracle/graal
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Determine mx version
run: echo "MX_VERSION=$(jq -r '.mx_version' common.json)" >> ${GITHUB_ENV}
- name: Checkout graalvm/mx
uses: actions/checkout@v4
with:
repository: graalvm/mx
fetch-depth: 1
ref: ${{ env.MX_VERSION }}
path: ${{ env.MX_PATH }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Update mx cache
uses: actions/cache@v4
with:
path: ~/.mx
key: ${{ runner.os }}-mx-${{ hashFiles('**/suite.py') }}
restore-keys: ${{ runner.os }}-mx-
- name: Fetch LabsJDK
run: |
mkdir jdk-dl
${MX_PATH}/mx --java-home= fetch-jdk --jdk-id labsjdk-ce-latest --to jdk-dl --alias ${JAVA_HOME}
- name: Build GraalVM JDK
run: |
cd substratevm
${MX_PATH}/mx --native=native-image --components="Native Image" build
ln -s $(${MX_PATH}/mx --native=native-image --components="Native Image" graalvm-home) ${GRAALVM_HOME}
${GRAALVM_HOME}/bin/native-image --version
- name: Reconfigure JAVA_HOME for Micronaut
uses: actions/setup-java@v4
uses: ./.github/actions/build-graalvm
with:
distribution: 'oracle'
java-version: '${{ env.MICRONAUT_JDK_VERSION }}'
java-version: ${{ env.MICRONAUT_JAVA_VERSION }}
- name: Run nativeTest in Micronaut launch project
run: |
curl --fail --silent --location --retry 3 --max-time 10 --output demo.zip --request GET 'https://launch.micronaut.io/create/default/com.example.demo?lang=JAVA&build=GRADLE&test=JUNIT&javaVersion=JDK_${{ env.MICRONAUT_JDK_VERSION }}'
Expand Down
46 changes: 4 additions & 42 deletions .github/workflows/quarkus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,8 @@ env:
DB_NAME: hibernate_orm_test
DB_PASSWORD: hibernate_orm_test
DB_USER: hibernate_orm_test
GRAALVM_HOME: ${{ github.workspace }}/graalvm
LABSJDK_HOME: ${{ github.workspace }}/jdk
LANG: en_US.UTF-8 # Workaround testsuite locale issue
MX_GIT_CACHE: refcache
MX_PATH: ${{ github.workspace }}/mx
MX_PYTHON: python3.8
NATIVE_TEST_MAVEN_ARGS: "-Dtest-containers -Dstart-containers -Dquarkus.native.native-image-xmx=5g -Dnative -Dnative.surefire.skip -Dformat.skip -Dno-descriptor-tests install -DskipDocs -Dquarkus.native.container-build=false"
QUARKUS_JAVA_VERSION: 17 # Use Java 17 to build Quarkus as that's the lowest supported JDK version currently
QUARKUS_PATH: ${{ github.workspace }}/quarkus

permissions: {}
Expand All @@ -77,21 +72,10 @@ jobs:
outputs:
matrix: ${{ steps.read.outputs.matrix }}
steps:
- name: Checkout oracle/graal
uses: actions/checkout@v4
- name: Build GraalVM JDK
uses: ./.github/actions/build-graalvm
with:
fetch-depth: 1
- name: Checkout graalvm/mx
uses: actions/checkout@v4
with:
repository: graalvm/mx.git
fetch-depth: 1
ref: master
path: ${{ env.MX_PATH }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8'
java-version: ${{ env.QUARKUS_JAVA_VERSION }}
- name: Get latest Quarkus release
run: |
export QUARKUS_VERSION=main #$(curl https://repo1.maven.org/maven2/io/quarkus/quarkus-bom/maven-metadata.xml | awk -F"[<>]" '/latest/ {print $3}')
Expand All @@ -105,23 +89,6 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/cache@v4
with:
path: ~/.mx
key: ${{ runner.os }}-mx-${{ hashFiles('**/suite.py') }}
restore-keys: |
${{ runner.os }}-mx-
- name: Fetch LabsJDK
run: |
mkdir jdk-dl
${MX_PATH}/mx --java-home= fetch-jdk --jdk-id labsjdk-ce-latest --to jdk-dl --alias ${LABSJDK_HOME}
- name: Build graalvm native-image
run: |
export JAVA_HOME=${LABSJDK_HOME}
cd substratevm
${MX_PATH}/mx --native=native-image,lib:jvmcicompiler --components="Native Image,LibGraal" build
ln -s $(${MX_PATH}/mx --native=native-image,lib:jvmcicompiler --components="Native Image,LibGraal" graalvm-home) ${GRAALVM_HOME}
${GRAALVM_HOME}/bin/native-image --version
- name: Tar GraalVM
shell: bash
run: tar -czvf graalvm.tgz -C $(dirname ${GRAALVM_HOME}) $(basename ${GRAALVM_HOME})
Expand All @@ -130,11 +97,6 @@ jobs:
with:
name: graalvm
path: graalvm.tgz
# Use Java 17 to build Quarkus as that's the lowest supported JDK version currently
- uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: '17'
- name: Build Quarkus
run: |
cd ${QUARKUS_PATH}
Expand Down

0 comments on commit 19b3c6b

Please sign in to comment.