Skip to content

Commit 38635ff

Browse files
jerboaazakkak
authored andcommitted
[CI] Add support for JDK pinning
Sometimes it's useful to pin CI to an *older* JDK build. This patch adds this by allowing to set an ENV variable to the proper GH release to pin to.
1 parent 249879a commit 38635ff

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

.github/workflows/buildJDK.yml

+41-8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ env:
1919
MANDREL_VERSION: 10.9.8.7-dev
2020
MX_PYTHON: python3
2121
PYTHONIOENCODING: utf-8
22+
TEMURIN_API_URL_LATEST: https://api.adoptium.net/v3/binary/latest/25/ea
23+
# Use this to 'pin' to a specific JDK build. The respective
24+
# release needs to exist.
25+
#TEMURIN_PINNED_RELEASE: jdk-25%2B9-ea-beta
2226

2327
# The following aims to reduce CI CPU cycles by:
2428
# 1. Cancelling any previous builds of this PR when pushing new changes to it
@@ -34,9 +38,29 @@ concurrency:
3438
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'graalvm/mandrel-packaging' }}
3539

3640
jobs:
41+
setup-env:
42+
name: Set Temurin API URL
43+
runs-on: ubuntu-latest
44+
outputs:
45+
api-url: ${{ steps.set-env.outputs.TEMURIN_API_URL }}
46+
steps:
47+
- name: Prepare
48+
id: set-env
49+
run: |
50+
if [ "${TEMURIN_PINNED_RELEASE}_" == "_" ]; then
51+
TEMURIN_API_URL="${TEMURIN_API_URL_LATEST}"
52+
else
53+
TEMURIN_API_URL="https://api.adoptium.net/v3/binary/version/${TEMURIN_PINNED_RELEASE}"
54+
fi
55+
echo "Setting TEMURIN_API_URL=${TEMURIN_API_URL}"
56+
echo "TEMURIN_API_URL=${TEMURIN_API_URL}" >> "$GITHUB_OUTPUT"
57+
3758
build-and-test:
3859
name: Linux Build and test ${{ matrix.mandrel-ref }} branch/tag
3960
runs-on: ubuntu-latest
61+
needs: setup-env
62+
env:
63+
TEMURIN_API_URL: ${{ needs.setup-env.outputs.api-url }}
4064
strategy:
4165
fail-fast: false
4266
matrix:
@@ -68,8 +92,8 @@ jobs:
6892
${{ runner.os }}-${{ matrix.quarkus-name }}-maven-
6993
- name: Get latest OpenJDK 25 with static libs
7094
run: |
71-
curl -sL https://api.adoptium.net/v3/binary/latest/25/ea/linux/x64/jdk/hotspot/normal/eclipse -o jdk.tar.gz
72-
curl -sL https://api.adoptium.net/v3/binary/latest/25/ea/linux/x64/staticlibs/hotspot/normal/eclipse -o jdk-static-libs.tar.gz
95+
curl -sL ${TEMURIN_API_URL}/linux/x64/jdk/hotspot/normal/eclipse -o jdk.tar.gz
96+
curl -sL ${TEMURIN_API_URL}/linux/x64/staticlibs/hotspot/normal/eclipse -o jdk-static-libs.tar.gz
7397
mkdir -p ${JAVA_HOME}
7498
tar xf jdk.tar.gz -C ${JAVA_HOME} --strip-components=1
7599
tar xf jdk-static-libs.tar.gz -C ${JAVA_HOME} --strip-components=1
@@ -142,6 +166,9 @@ jobs:
142166
build-and-test-on-mac:
143167
name: ${{ matrix.os }} Build and test ${{ matrix.mandrel-ref }} branch/tag
144168
runs-on: ${{ matrix.os }}
169+
needs: setup-env
170+
env:
171+
TEMURIN_API_URL: ${{ needs.setup-env.outputs.api-url }}
145172
strategy:
146173
fail-fast: false
147174
matrix:
@@ -183,8 +210,8 @@ jobs:
183210
env:
184211
ARCH: ${{ steps.arch.outputs.ARCH }}
185212
run: |
186-
curl -sL https://api.adoptium.net/v3/binary/latest/25/ea/mac/${ARCH}/jdk/hotspot/normal/eclipse -o jdk.tar.gz
187-
curl -sL https://api.adoptium.net/v3/binary/latest/25/ea/mac/${ARCH}/staticlibs/hotspot/normal/eclipse -o jdk-static-libs.tar.gz
213+
curl -sL ${TEMURIN_API_URL}/mac/${ARCH}/jdk/hotspot/normal/eclipse -o jdk.tar.gz
214+
curl -sL ${TEMURIN_API_URL}/mac/${ARCH}/staticlibs/hotspot/normal/eclipse -o jdk-static-libs.tar.gz
188215
mkdir -p ${JAVA_HOME}
189216
tar xf jdk.tar.gz -C ${JAVA_HOME} --strip-components=1
190217
tar xf jdk-static-libs.tar.gz -C ${JAVA_HOME} --strip-components=1
@@ -265,6 +292,9 @@ jobs:
265292
build-and-test-on-windows:
266293
name: Windows Build and test ${{ matrix.mandrel-ref }} branch/tag
267294
runs-on: windows-2022
295+
needs: setup-env
296+
env:
297+
TEMURIN_API_URL: ${{ needs.setup-env.outputs.api-url }}
268298
strategy:
269299
fail-fast: false
270300
matrix:
@@ -298,10 +328,10 @@ jobs:
298328
- name: Get latest OpenJDK 25 with static libs
299329
run: |
300330
$wc = New-Object System.Net.WebClient
301-
$wc.DownloadFile("https://api.adoptium.net/v3/binary/latest/25/ea/windows/x64/jdk/hotspot/normal/eclipse", "$Env:temp\jdk.zip")
331+
$wc.DownloadFile("$Env:TEMURIN_API_URL\/windows/x64/jdk/hotspot/normal/eclipse", "$Env:temp\jdk.zip")
302332
Expand-Archive "$Env:temp\jdk.zip" -DestinationPath "$Env:temp"
303333
Move-Item -Path "$Env:temp\jdk-*" -Destination $Env:JAVA_HOME
304-
$wc.DownloadFile("https://api.adoptium.net/v3/binary/latest/25/ea/windows/x64/staticlibs/hotspot/normal/eclipse", "$Env:temp\jdk-staticlibs.zip")
334+
$wc.DownloadFile("$Env:TEMURIN_API_URL\/windows/x64/staticlibs/hotspot/normal/eclipse", "$Env:temp\jdk-staticlibs.zip")
305335
Expand-Archive "$Env:temp\jdk-staticlibs.zip" -DestinationPath "$Env:temp"
306336
Move-Item -Path "$Env:temp\jdk-*\lib\static" -Destination $Env:JAVA_HOME\lib\
307337
Remove-Item -Recurse "$Env:temp\jdk-*"
@@ -392,6 +422,9 @@ jobs:
392422
build-and-test-2-step:
393423
name: 2-step Linux Build and test ${{ matrix.mandrel-ref }} branch/tag
394424
runs-on: ubuntu-latest
425+
needs: setup-env
426+
env:
427+
TEMURIN_API_URL: ${{ needs.setup-env.outputs.api-url }}
395428
strategy:
396429
fail-fast: false
397430
matrix:
@@ -423,8 +456,8 @@ jobs:
423456
${{ runner.os }}-${{ matrix.quarkus-name }}-maven-
424457
- name: Get latest OpenJDK 25 with static libs
425458
run: |
426-
curl -sL https://api.adoptium.net/v3/binary/latest/25/ea/linux/x64/jdk/hotspot/normal/eclipse -o jdk.tar.gz
427-
curl -sL https://api.adoptium.net/v3/binary/latest/25/ea/linux/x64/staticlibs/hotspot/normal/eclipse -o jdk-static-libs.tar.gz
459+
curl -sL ${TEMURIN_API_URL}/linux/x64/jdk/hotspot/normal/eclipse -o jdk.tar.gz
460+
curl -sL ${TEMURIN_API_URL}/linux/x64/staticlibs/hotspot/normal/eclipse -o jdk-static-libs.tar.gz
428461
mkdir -p ${JAVA_HOME}
429462
tar xf jdk.tar.gz -C ${JAVA_HOME} --strip-components=1
430463
tar xf jdk-static-libs.tar.gz -C ${JAVA_HOME} --strip-components=1

0 commit comments

Comments
 (0)