Skip to content

Commit c2f3ca9

Browse files
committed
Turn build-graalvm action into reusable workflow.
This workflow can also be triggered manually to build GraalVM from source.
1 parent f84aa4e commit c2f3ca9

File tree

7 files changed

+206
-140
lines changed

7 files changed

+206
-140
lines changed

.github/actions/build-graalvm/action.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
#
2+
# Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved.
3+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
#
5+
# The Universal Permissive License (UPL), Version 1.0
6+
#
7+
# Subject to the condition set forth below, permission is hereby granted to any
8+
# person obtaining a copy of this software, associated documentation and/or
9+
# data (collectively the "Software"), free of charge and under any and all
10+
# copyright rights in the Software, and any and all patent rights owned or
11+
# freely licensable by each licensor hereunder covering either (i) the
12+
# unmodified Software as contributed to or provided by such licensor, or (ii)
13+
# the Larger Works (as defined below), to deal in both
14+
#
15+
# (a) the Software, and
16+
#
17+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
# one is included with the Software each a "Larger Work" to which the Software
19+
# is contributed by such licensors),
20+
#
21+
# without restriction, including without limitation the rights to copy, create
22+
# derivative works of, display, perform, and distribute the Software and make,
23+
# use, sell, offer for sale, import, export, have made, and have sold the
24+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
# either these or other terms.
26+
#
27+
# This license is subject to the following condition:
28+
#
29+
# The above copyright notice and either this complete permission notice or at a
30+
# minimum a reference to the UPL must be included in all copies or substantial
31+
# portions of the Software.
32+
#
33+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
# SOFTWARE.
40+
#
41+
42+
name: Build GraalVM JDK
43+
description: 'Build GraalVM JDK and set up environment for testing'
44+
45+
on:
46+
workflow_call:
47+
inputs:
48+
env:
49+
description: 'Internal env name for build'
50+
required: false
51+
type: string
52+
dynamic-imports:
53+
default: '/substratevm'
54+
description: 'Internal dynamic imports for build'
55+
required: false
56+
type: string
57+
native-images:
58+
default: 'native-image'
59+
description: 'Internal GraalVM native images to build'
60+
required: false
61+
type: string
62+
components:
63+
default: 'Native Image'
64+
description: 'Internal GraalVM components to build'
65+
required: false
66+
type: string
67+
java-version:
68+
default: ''
69+
description: 'Java version to use'
70+
required: false
71+
type: string
72+
# Enable manual dispatch of the workflow
73+
# see https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
74+
workflow_dispatch:
75+
76+
jobs:
77+
build_from_source:
78+
runs-on: ubuntu-22.04
79+
steps:
80+
- name: Set up environment variables
81+
shell: bash
82+
run: |
83+
echo "GRAALVM_HOME=${{ github.workspace }}/graalvm" >> ${GITHUB_ENV}
84+
echo "JAVA_HOME=${{ github.workspace }}/labsjdk" >> ${GITHUB_ENV}
85+
echo "MX_GIT_CACHE=refcache" >> ${GITHUB_ENV}
86+
echo "MX_PATH=${{ github.workspace }}/mx" >> ${GITHUB_ENV}
87+
echo "MX_PYTHON=python3.8" >> ${GITHUB_ENV}
88+
echo "MX_VERSION=$(jq -r '.mx_version' common.json)" >> ${GITHUB_ENV}
89+
# Workaround testsuite locale issue
90+
echo "LANG=en_US.UTF-8" >> ${GITHUB_ENV}
91+
- name: Checkout graalvm/mx
92+
uses: actions/checkout@v6
93+
with:
94+
repository: graalvm/mx
95+
ref: ${{ env.MX_VERSION }}
96+
path: ${{ env.MX_PATH }}
97+
- name: Set up Python
98+
uses: actions/setup-python@v6
99+
with:
100+
python-version: '3.8'
101+
- name: Fetch LabsJDK
102+
shell: bash
103+
run: |
104+
mkdir jdk-dl
105+
${MX_PATH}/mx --java-home= fetch-jdk --jdk-id labsjdk-ce-latest --to jdk-dl --alias ${JAVA_HOME}
106+
- name: Build GraalVM JDK
107+
shell: bash
108+
run: |
109+
cd vm
110+
if [ -n "${{ inputs.env }}" ]; then
111+
MX_ARGS='--java-home="${JAVA_HOME}" --env="${{ inputs.env }}"'
112+
else
113+
MX_ARGS='--java-home="${JAVA_HOME}" --dy="${{ inputs.dynamic-imports }}" --native-images="${{ inputs.native-images }}" --components="${{ inputs.components }}"'
114+
fi
115+
${MX_PATH}/mx $MX_ARGS build
116+
ln -s $(${MX_PATH}/mx $MX_ARGS graalvm-home) ${GRAALVM_HOME}
117+
- name: Show GraalVM JDK version info
118+
shell: bash
119+
run: |
120+
echo "= 'java --version' ============"
121+
${GRAALVM_HOME}/bin/java --version
122+
echo "==============================="
123+
124+
if [ -f "${GRAALVM_HOME}/bin/native-image" ]; then
125+
echo "= 'native-image --version' ===="
126+
${GRAALVM_HOME}/bin/native-image --version
127+
echo "==============================="
128+
fi
129+
- name: Tar GraalVM JDK
130+
shell: bash
131+
run: tar -czvhf graalvm-jdk.tgz -C $(dirname ${GRAALVM_HOME}) $(basename ${GRAALVM_HOME})
132+
- name: Upload GraalVM JDK build as artifact
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: graalvm-jdk
136+
path: graalvm-jdk.tgz
137+

.github/workflows/micronaut-template.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# The Universal Permissive License (UPL), Version 1.0
@@ -48,8 +48,9 @@ on:
4848
type: string
4949

5050
env:
51+
GRAALVM_HOME: ${{ github.workspace }}/graalvm-jdk # identical to the one in ./.github/workflows/build-graalvm
5152
MICRONAUT_CORE_PATH: ${{ github.workspace }}/micronaut-core
52-
MICRONAUT_JAVA_VERSION: 21
53+
MICRONAUT_JAVA_VERSION: 25
5354
# Enforce experimental option checking in CI (GR-47922)
5455
NATIVE_IMAGE_EXPERIMENTAL_OPTIONS_ARE_FATAL: 'true'
5556
NATIVE_IMAGE_OPTIONS: ${{ inputs.NATIVE_IMAGE_OPTIONS }}
@@ -58,17 +59,23 @@ permissions:
5859
contents: read # to fetch code (actions/checkout)
5960

6061
jobs:
61-
build-graalvm-and-micronaut:
62+
build-graalvm:
63+
uses: ./.github/workflows/build-graalvm.yml
64+
with:
65+
java-version: ${{ env.MICRONAUT_JAVA_VERSION }}
66+
build-and-test-micronaut:
6267
name: Native Tests
6368
runs-on: ubuntu-22.04
6469
if: (github.event_name == 'schedule' && github.repository == 'oracle/graal') || (github.event_name != 'schedule')
6570
steps:
6671
- name: Checkout oracle/graal
6772
uses: actions/checkout@v4
68-
- name: Build GraalVM JDK
69-
uses: ./.github/actions/build-graalvm
73+
- name: Download GraalVM JDK build
74+
uses: actions/download-artifact@v5
7075
with:
71-
java-version: ${{ env.MICRONAUT_JAVA_VERSION }}
76+
name: 'graalvm-jdk'
77+
- name: Extract GraalVM JDK build
78+
run: tar -xzvf graalvm-jdk.tgz -C $(dirname ${GRAALVM_HOME})
7279
- name: Run nativeTest in Micronaut launch project
7380
run: |
7481
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_JAVA_VERSION }}'

.github/workflows/ni-layers.yml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# The Universal Permissive License (UPL), Version 1.0
@@ -55,29 +55,22 @@ env:
5555
PYTHON_VERSION: 3.12.3
5656

5757
jobs:
58-
build-graalvm-and-populate-matrix:
59-
name: Build GraalVM and populate matrix
58+
build-graalvm:
59+
uses: ./.github/workflows/build-graalvm.yml
60+
if: (github.repository=='oracle/graal')
61+
with:
62+
native-images: 'native-image,native-image-configure,lib:native-image-agent'
63+
components: 'Native Image,Native Image Configure Tool'
64+
java-version: ${{ env.JAVA_VERSION }}
65+
populate-matrix:
66+
name: Populate matrix
6067
runs-on: ubuntu-latest
6168
if: (github.repository=='oracle/graal')
6269
outputs:
6370
matrix: ${{ steps.set-matrix.outputs.matrix }}
6471
steps:
6572
- name: Checkout oracle/graal
6673
uses: actions/checkout@v4
67-
- name: Build GraalVM JDK
68-
uses: ./.github/actions/build-graalvm
69-
with:
70-
native-images: 'native-image,native-image-configure,lib:native-image-agent'
71-
components: 'Native Image,Native Image Configure Tool'
72-
java-version: ${{ env.JAVA_VERSION }}
73-
- name: Tar GraalVM JDK
74-
shell: bash
75-
run: tar -czvhf graalvm.tgz -C $(dirname ${GRAALVM_HOME}) $(basename ${GRAALVM_HOME})
76-
- name: Persist GraalVM JDK build
77-
uses: actions/upload-artifact@v4
78-
with:
79-
name: graalvm
80-
path: graalvm.tgz
8174
- name: Setup python
8275
uses: actions/setup-python@v5
8376
with:
@@ -90,13 +83,13 @@ jobs:
9083
name: ${{ matrix.coordinates }}
9184
runs-on: ubuntu-latest
9285
env:
93-
GRAALVM_HOME: ${{ github.workspace }}/graalvm
86+
GRAALVM_HOME: ${{ github.workspace }}/graalvm-jdk # identical to the one in ./.github/workflows/build-graalvm
9487
timeout-minutes: 30
95-
needs: build-graalvm-and-populate-matrix
88+
needs: [build-graalvm, populate-matrix]
9689
strategy:
9790
fail-fast: false
9891
matrix:
99-
coordinates: ${{ fromJson(needs. build-graalvm-and-populate-matrix.outputs.matrix).coordinates }}
92+
coordinates: ${{ fromJson(needs.populate-matrix.outputs.matrix).coordinates }}
10093
steps:
10194
- name: Checkout oracle/graal
10295
uses: actions/checkout@v4

.github/workflows/quarkus-template.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# The Universal Permissive License (UPL), Version 1.0
@@ -59,22 +59,22 @@ name: Weekly Quarkus Tests
5959

6060
permissions: {}
6161
jobs:
62-
build-quarkus-and-graalvm:
62+
build-graalvm:
63+
uses: ./.github/workflows/build-graalvm.yml
64+
with:
65+
java-version: ${{ env.QUARKUS_JAVA_VERSION }}
66+
build-and-test-quarkus:
6367
permissions:
6468
contents: read # to fetch code (actions/checkout)
6569

66-
name: Nightly Quarkus and GraalVM build
70+
name: Nightly Quarkus build
6771
runs-on: ubuntu-22.04
6872
if: (github.event_name == 'schedule' && github.repository == 'oracle/graal') || (github.event_name != 'schedule')
6973
outputs:
7074
matrix: ${{ steps.read.outputs.matrix }}
7175
steps:
7276
- name: Checkout oracle/graal
7377
uses: actions/checkout@v4
74-
- name: Build GraalVM JDK
75-
uses: ./.github/actions/build-graalvm
76-
with:
77-
java-version: ${{ env.QUARKUS_JAVA_VERSION }}
7878
- name: Get latest Quarkus release
7979
run: |
8080
export QUARKUS_VERSION=main #$(curl https://repo1.maven.org/maven2/io/quarkus/quarkus-bom/maven-metadata.xml | awk -F"[<>]" '/latest/ {print $3}')
@@ -88,14 +88,6 @@ jobs:
8888
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
8989
restore-keys: |
9090
${{ runner.os }}-maven-
91-
- name: Tar GraalVM JDK
92-
shell: bash
93-
run: tar -czvhf graalvm.tgz -C $(dirname ${GRAALVM_HOME}) $(basename ${GRAALVM_HOME})
94-
- name: Persist GraalVM JDK build
95-
uses: actions/upload-artifact@v4
96-
with:
97-
name: graalvm
98-
path: graalvm.tgz
9991
- name: Build Quarkus
10092
run: |
10193
cd ${QUARKUS_PATH}
@@ -117,27 +109,26 @@ jobs:
117109

118110
native-tests:
119111
name: Native Tests - ${{matrix.category}}${{ inputs.NATIVE_IMAGE_OPTIONS && format(' with ''{0}''', inputs.NATIVE_IMAGE_OPTIONS) || '' }}
120-
needs: build-quarkus-and-graalvm
112+
needs: [build-graalvm, build-and-test-quarkus]
121113
runs-on: ubuntu-latest
122114
env:
123-
GRAALVM_HOME: ${{ github.workspace }}/graalvm # identical to the one in ./.github/actions/build-graalvm
115+
GRAALVM_HOME: ${{ github.workspace }}/graalvm-jdk # identical to the one in ./.github/workflows/build-graalvm
124116
# Ignore the following YAML Schema error
125117
timeout-minutes: ${{matrix.timeout}}
126118
strategy:
127119
max-parallel: 8
128120
fail-fast: false
129-
matrix: ${{ fromJson(needs.build-quarkus-and-graalvm.outputs.matrix) }}
121+
matrix: ${{ fromJson(needs.build-and-test-quarkus.outputs.matrix) }}
130122
steps:
131123
- name: Download GraalVM JDK build
132124
if: startsWith(matrix.os-name, 'ubuntu')
133125
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
134126
with:
135-
name: graalvm
136-
path: .
127+
name: graalvm-jdk
137128
- name: Extract GraalVM JDK build
138129
if: startsWith(matrix.os-name, 'ubuntu')
139130
shell: bash
140-
run: tar -xzvf graalvm.tgz -C $(dirname ${GRAALVM_HOME})
131+
run: tar -xzvf graalvm-jdk.tgz -C $(dirname ${GRAALVM_HOME})
141132
- name: Get latest Quarkus release
142133
if: startsWith(matrix.os-name, 'ubuntu')
143134
run: |

0 commit comments

Comments
 (0)