Skip to content

Commit 4873ae0

Browse files
committed
Add support for Oracle GraalVM via GDS.
1 parent c316394 commit 4873ae0

File tree

9 files changed

+263
-58
lines changed

9 files changed

+263
-58
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
macos-12, # macOS on Intel
3434
windows-latest
3535
]
36+
set-gds-token: [false]
3637
components: ['']
3738
include:
3839
- java-version: 'latest-ea'
@@ -54,6 +55,14 @@ jobs:
5455
- java-version: '21.0.0' # test for GA version (see #63)
5556
distribution: 'graalvm'
5657
os: ubuntu-latest
58+
- java-version: '17'
59+
distribution: 'graalvm'
60+
os: ubuntu-latest
61+
set-gds-token: true
62+
- java-version: '17.0.12' # Upgrade to '17.0.13' after Oct 2024
63+
distribution: 'graalvm'
64+
os: ubuntu-latest
65+
set-gds-token: true
5766
steps:
5867
- uses: actions/checkout@v4
5968
- name: Run setup-graalvm action
@@ -63,6 +72,7 @@ jobs:
6372
distribution: ${{ matrix.distribution }}
6473
github-token: ${{ secrets.GITHUB_TOKEN }}
6574
components: ${{ matrix.components }}
75+
gds-token: ${{ matrix.set-gds-token && secrets.GDS_TOKEN || '' }}
6676
- name: Check environment
6777
run: |
6878
echo "GRAALVM_HOME: $GRAALVM_HOME"

README.md

Lines changed: 65 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ jobs:
8080
path: helloworld*
8181
```
8282
83-
<details>
84-
<summary><h4>Template for Oracle GraalVM Early Access (EA) builds</h4></summary>
83+
### Template for Oracle GraalVM Early Access (EA) builds
8584
8685
```yml
8786
name: Oracle GraalVM Early Access build
@@ -93,18 +92,36 @@ jobs:
9392
- uses: actions/checkout@v4
9493
- uses: graalvm/setup-graalvm@v1
9594
with:
96-
java-version: '23-ea' # or 'latest-ea' for the latest Java version available
95+
java-version: '24-ea' # or 'latest-ea' for the latest Java version available
9796
distribution: 'graalvm'
9897
github-token: ${{ secrets.GITHUB_TOKEN }}
9998
```
10099
101-
</details>
102-
103100
<details>
104-
<summary><h4>Template for older GraalVM releases</h4></summary>
101+
<summary><h4>Template for Oracle GraalVM via GraalVM Download Service</h4></summary>
102+
103+
#### Prerequisites
104+
105+
1. Obtain a token for the GraalVM Download Service. For this, replace `[email protected]` with your email address and run the following `curl` command:
106+
107+
```bash
108+
curl -sS -X POST "https://gds.oracle.com/api/20220101/licenseAcceptance" \
109+
-H "Content-Type: application/json" \
110+
-d "{ \"email\": \"[email protected]\", \"licenseId\": \"D53FA58D12817B3CE0530F15000A74CA\", \"type\": \"GENERATE_TOKEN_AND_ACCEPT_LICENSE\"}"
111+
```
112+
113+
The response should look like this:
114+
115+
```json
116+
{"token":"<your-token>","status":"UNVERIFIED"}
117+
```
118+
119+
2. Store the value of `<your-token>` as a [GitHub Action secret][gha-secrets]. For the following template, we use the name `GDS_TOKEN`.
120+
3. Check your emails and accept the license to activate the token.
121+
4. Use `java-version: '17'` (or a specific version such as `17.0.13`) and provide the `GDS_TOKEN` as shown in the following template:
105122

106123
```yml
107-
name: GraalVM build
124+
name: Build with Oracle GraalVM for JDK 17 via GDS
108125
on: [push, pull_request]
109126
jobs:
110127
build:
@@ -113,10 +130,14 @@ jobs:
113130
- uses: actions/checkout@v4
114131
- uses: graalvm/setup-graalvm@v1
115132
with:
116-
version: '22.3.2' # GraalVM version
133+
distribution: 'graalvm'
117134
java-version: '17'
118-
components: 'native-image'
135+
gds-token: ${{ secrets.GDS_TOKEN }}
119136
github-token: ${{ secrets.GITHUB_TOKEN }}
137+
- name: Example step
138+
run: |
139+
java --version
140+
native-image --version
120141
```
121142

122143
</details>
@@ -129,7 +150,7 @@ jobs:
129150
1. Download the version of [GraalVM Enterprise Edition (EE)][graalvm-ee] you want to run on GitHub Actions.
130151
2. Use the [GraalVM Updater][gu] to install the GraalVM components you need on GitHub Actions and accept the corresponding licenses.
131152
3. Run `$GRAALVM_HOME/bin/gu --show-ee-token` to display your token for the GraalVM Download Service.
132-
4. Store this token as a [GitHub Action secret][gha-secrets]. For this template, we use the name `GDS_TOKEN`.
153+
4. Store this token as a [GitHub Action secret][gha-secrets]. In the following template, we use the name `GDS_TOKEN`.
133154

134155
```yml
135156
name: GraalVM Enterprise Edition build
@@ -155,6 +176,39 @@ jobs:
155176
</details>
156177

157178

179+
## Options
180+
181+
| Name | Default | Description |
182+
|-----------------|:--------:|-------------|
183+
| `java-version`<br>*(required)* | n/a | Java version <ul><li>major versions: `'21'`, `'17'`, `'11'`, `'8'`</li><li>specific versions: `'21.0.3'`, `'17.0.11'`</li><li>early access (EA) builds: `'23-ea'` *(requires `distribution: 'graalvm'`)*</li><li>latest EA build: `'latest-ea'` *(requires `distribution: 'graalvm'`)*</li><li>dev builds: `'dev'`</li></ul> |
184+
| `distribution` | `'graalvm'` | GraalVM distribution <ul><li>Oracle GraalVM: `'graalvm'`</li><li>GraalVM Community Edition: `'graalvm-community'`</li><li>Mandrel: `'mandrel'`</li><li>Liberica: `'liberica'`</li></ul> |
185+
| `java-package` | `'jdk'` | The package type (`'jdk'` or `'jdk+fx'`). Currently applies to Liberica only. |
186+
| `github-token` | `'${{ github.token }}'` | Token for communication with the GitHub API. Please set this to `${{ secrets.GITHUB_TOKEN }}` (see [templates](#templates)) to allow the action to authenticate with the GitHub API, which helps reduce rate-limiting issues. |
187+
| `set-java-home` | `'true'` | If set to `'true'`, instructs the action to set `$JAVA_HOME` to the path of the GraalVM installation. Overrides any previous action or command that sets `$JAVA_HOME`. |
188+
| `cache` | `''` | Name of the build platform to cache dependencies. Turned off by default (`''`). It can also be `'maven'`, `'gradle'`, or `'sbt'` and works the same way as described in [actions/setup-java][setup-java-caching]. |
189+
| `check-for-updates` | `'true'` | [Annotate jobs][gha-annotations] with update notifications, for example when a new GraalVM release is available. |
190+
| `native-image-musl` | `'false'` | If set to `'true'`, sets up [musl] to build [static binaries][native-image-static] with GraalVM Native Image *(Linux only)*. [Example usage][native-image-musl-build] (be sure to replace `uses: ./` with `uses: graalvm/setup-graalvm@v1`). |
191+
| `native-image-job-reports` *) | `'false'` | If set to `'true'`, post a job summary containing a Native Image build report. |
192+
| `native-image-pr-reports` *) | `'false'` | If set to `'true'`, post a comment containing a Native Image build report on pull requests. Requires `write` permissions for the [`pull-requests` scope][gha-permissions]. |
193+
| `native-image-pr-reports-update-existing` *) | `'false'` | Instead of posting another comment, update an existing PR comment with the latest Native Image build report. Requires `native-image-pr-reports` to be `true`. |
194+
| `components` | `''` | Comma-separated list of GraalVM components (e.g., `native-image` or `ruby,nodejs`) that will be installed by the [GraalVM Updater][gu]. |
195+
| `version` | `''` | `X.Y.Z` (e.g., `22.3.0`) for a specific [GraalVM release][releases] up to `22.3.2`<br>`mandrel-X.Y.Z.W` or `X.Y.Z.W-Final` (e.g., `mandrel-21.3.0.0-Final` or `21.3.0.0-Final`) for a specific [Mandrel release][mandrel-releases],<br>`mandrel-latest` or `latest` for the latest Mandrel stable release. |
196+
| `gds-token` | `''` | Download token for the GraalVM Download Service. at <> Store this token as a [GitHub Action secret][gha-secrets]. For thie followingtemplate, we use the name `GDS_TOKEN`.. If a non-empty token is provided, the action will set up GraalVM Enterprise Edition (see [GraalVM EE template](#template-for-graalvm-enterprise-edition)). |
197+
**) Make sure that Native Image is used only once per build job. Otherwise, the report is only generated for the last Native Image build.*
198+
199+
200+
## Notes on Oracle GraalVM for JDK 17
201+
202+
GraalVM for JDK 17.0.12 is the [last release of Oracle GraalVM for JDK 17 under the GFTC](https://blogs.oracle.com/java/post/jdk-17-approaches-endofpermissive-license).
203+
Updates after September 2024 will be licensed under the [GraalVM OTN License Including License for Early Adopter Versions](https://www.oracle.com/downloads/licenses/graalvm-otn-license.html) (GOTN) and production use beyond the limited free grants of the GraalVM OTN license will require a fee.
204+
205+
As a user of `setup-graalvm`, you have the following options:
206+
207+
- *Recommended*: Upgrade to Oracle GraalVM for JDK 21 or later to receive new updates.
208+
- *Not recommended*: Instead of `java-version: '17'`, use `java-version: '17.0.12'` in your workflow to keep using the last release under GFTC. This will also disable the warning. Note that switching to GraalVM Community Edition or other GraalVM distributions might provide you with even older releases of GraalVM.
209+
- Provide a `gds-token` to access Oracle GraalVM for JDK 17 under GOTN (see [Oracle GraalVM via GDS template](#template-for-oracle-graalvm-via-graalvm-download-service)).
210+
211+
158212
## Migrating from GraalVM 22.3 or Earlier to the New GraalVM for JDK 17 and Later
159213

160214
The [GraalVM for JDK 17 and JDK 20 release](https://medium.com/graalvm/a-new-graalvm-release-and-new-free-license-4aab483692f5) aligns the GraalVM version scheme with OpenJDK.
@@ -183,28 +237,6 @@ can be replaced with:
183237
```
184238

185239

186-
## Options
187-
188-
| Name | Default | Description |
189-
|-----------------|:--------:|-------------|
190-
| `java-version`<br>*(required)* | n/a | Java version <ul><li>major versions: `'21'`, `'17'`, `'11'`, `'8'`</li><li>specific versions: `'21.0.3'`, `'17.0.11'`</li><li>early access (EA) builds: `'23-ea'` *(requires `distribution: 'graalvm'`)*</li><li>latest EA build: `'latest-ea'` *(requires `distribution: 'graalvm'`)*</li><li>dev builds: `'dev'`</li></ul> |
191-
| `distribution` | `'graalvm'` | GraalVM distribution <ul><li>Oracle GraalVM: `'graalvm'`</li><li>GraalVM Community Edition: `'graalvm-community'`</li><li>Mandrel: `'mandrel'`</li><li>Liberica: `'liberica'`</li></ul> |
192-
| `java-package` | `'jdk'` | The package type (`'jdk'` or `'jdk+fx'`). Currently applies to Liberica only. |
193-
| `github-token` | `'${{ github.token }}'` | Token for communication with the GitHub API. Please set this to `${{ secrets.GITHUB_TOKEN }}` (see [templates](#templates)) to allow the action to authenticate with the GitHub API, which helps reduce rate-limiting issues. |
194-
| `set-java-home` | `'true'` | If set to `'true'`, instructs the action to set `$JAVA_HOME` to the path of the GraalVM installation. Overrides any previous action or command that sets `$JAVA_HOME`. |
195-
| `cache` | `''` | Name of the build platform to cache dependencies. Turned off by default (`''`). It can also be `'maven'`, `'gradle'`, or `'sbt'` and works the same way as described in [actions/setup-java][setup-java-caching]. |
196-
| `check-for-updates` | `'true'` | [Annotate jobs][gha-annotations] with update notifications, for example when a new GraalVM release is available. |
197-
| `native-image-musl` | `'false'` | If set to `'true'`, sets up [musl] to build [static binaries][native-image-static] with GraalVM Native Image *(Linux only)*. [Example usage][native-image-musl-build] (be sure to replace `uses: ./` with `uses: graalvm/setup-graalvm@v1`). |
198-
| `native-image-job-reports` *) | `'false'` | If set to `'true'`, post a job summary containing a Native Image build report. |
199-
| `native-image-pr-reports` *) | `'false'` | If set to `'true'`, post a comment containing a Native Image build report on pull requests. Requires `write` permissions for the [`pull-requests` scope][gha-permissions]. |
200-
| `native-image-pr-reports-update-existing` *) | `'false'` | Instead of posting another comment, update an existing PR comment with the latest Native Image build report. Requires `native-image-pr-reports` to be `true`. |
201-
| `components` | `''` | Comma-separated list of GraalVM components (e.g., `native-image` or `ruby,nodejs`) that will be installed by the [GraalVM Updater][gu]. |
202-
| `version` | `''` | `X.Y.Z` (e.g., `22.3.0`) for a specific [GraalVM release][releases] up to `22.3.2`<br>`mandrel-X.Y.Z.W` or `X.Y.Z.W-Final` (e.g., `mandrel-21.3.0.0-Final` or `21.3.0.0-Final`) for a specific [Mandrel release][mandrel-releases],<br>`mandrel-latest` or `latest` for the latest Mandrel stable release. |
203-
| `gds-token` | `''` | Download token for the GraalVM Download Service. If a non-empty token is provided, the action will set up GraalVM Enterprise Edition (see [GraalVM EE template](#template-for-graalvm-enterprise-edition)). |
204-
205-
**) Make sure that Native Image is used only once per build job. Otherwise, the report is only generated for the last Native Image build.*
206-
207-
208240
## Contributing
209241

210242
We welcome code contributions. To get started, you will need to sign the [Oracle Contributor Agreement][oca] (OCA).
@@ -215,6 +247,7 @@ Only pull requests from committers that can be verified as having signed the OCA
215247
[dev-build]: https://github.com/graalvm/graalvm-ce-dev-builds/releases/latest
216248
[dev-builds]: https://github.com/graalvm/graalvm-ce-dev-builds
217249
[ea-builds]: https://github.com/graalvm/oracle-graalvm-ea-builds
250+
[gftc]: https://www.oracle.com/downloads/licenses/graal-free-license.html
218251
[gha-annotations]: https://github.com/actions/toolkit/tree/main/packages/core#annotations
219252
[gha-permissions]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
220253
[gha-secrets]: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository

__tests__/gds.test.ts

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,39 @@
11
import * as path from 'path'
2-
import {downloadGraalVMEELegacy, fetchArtifact} from '../src/gds'
2+
import {
3+
downloadGraalVM,
4+
downloadGraalVMEELegacy,
5+
fetchArtifact,
6+
fetchArtifactEE
7+
} from '../src/gds'
38
import {expect, test} from '@jest/globals'
49

510
const TEST_USER_AGENT = 'GraalVMGitHubActionTest/1.0.4'
611

712
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')
813

914
test('fetch artifacts', async () => {
10-
let artifact = await fetchArtifact(
15+
let artifact = await fetchArtifact(TEST_USER_AGENT, 'isBase:True', '17.0.12')
16+
expect(artifact.id).toBe('1C351E8F41BB8E9EE0631518000AE5F2')
17+
expect(artifact.checksum).toBe(
18+
'b6f3dace24cf1960ec790216f4c86f00d4f43df64e4e8b548f6382f04894713f'
19+
)
20+
artifact = await fetchArtifact(TEST_USER_AGENT, 'isBase:True', '17')
21+
expect(artifact.checksum).toHaveLength(
22+
'b6f3dace24cf1960ec790216f4c86f00d4f43df64e4e8b548f6382f04894713f'.length
23+
)
24+
})
25+
26+
test('errors when downloading artifacts', async () => {
27+
await expect(downloadGraalVM('invalid', '17')).rejects.toThrow(
28+
'The provided "gds-token" was rejected (reason: "Invalid download token", opc-request-id: '
29+
)
30+
await expect(downloadGraalVM('invalid', '1')).rejects.toThrow(
31+
'Unable to find GraalVM for JDK 1'
32+
)
33+
})
34+
35+
test('fetch legacy artifacts', async () => {
36+
let artifact = await fetchArtifactEE(
1137
TEST_USER_AGENT,
1238
'isBase:True',
1339
'22.1.0',
@@ -17,21 +43,26 @@ test('fetch artifacts', async () => {
1743
expect(artifact.checksum).toBe(
1844
'4280782f6c7fcabe0ba707e8389cbfaf7bbe6b0cf634d309e6efcd1b172e3ce6'
1945
)
20-
artifact = await fetchArtifact(TEST_USER_AGENT, 'isBase:True', '22.1.0', '17')
46+
artifact = await fetchArtifactEE(
47+
TEST_USER_AGENT,
48+
'isBase:True',
49+
'22.1.0',
50+
'17'
51+
)
2152
expect(artifact.id).toBe('DCECD2068882A0E9E0536E16000A9504')
2253
expect(artifact.checksum).toBe(
2354
'e897add7d94bc456a61e6f927e831dff759efa3392a4b69c720dd3debc8f947d'
2455
)
2556

2657
await expect(
27-
fetchArtifact(TEST_USER_AGENT, 'isBase:False', '22.1.0', '11')
58+
fetchArtifactEE(TEST_USER_AGENT, 'isBase:False', '22.1.0', '11')
2859
).rejects.toThrow('Found more than one GDS artifact')
2960
await expect(
30-
fetchArtifact(TEST_USER_AGENT, 'isBase:True', '1.0.0', '11')
61+
fetchArtifactEE(TEST_USER_AGENT, 'isBase:True', '1.0.0', '11')
3162
).rejects.toThrow('Unable to find JDK11-based GraalVM EE 1.0.0')
3263
})
3364

34-
test('errors when downloading artifacts', async () => {
65+
test('errors when downloading legacy artifacts', async () => {
3566
await expect(
3667
downloadGraalVMEELegacy('invalid', '22.1.0', '11')
3768
).rejects.toThrow(

dist/cleanup/index.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)