Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,27 @@ jobs:
java --version
native-image.cmd --version
if: runner.os == 'Windows'
test-native-image-musl:
name: native-image-musl on ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run setup-graalvm action
uses: ./
with:
version: 'latest'
java-version: '17'
components: 'native-image'
native-image-musl: 'true'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build static HelloWorld image with Native Image and musl
run: |
echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java
javac HelloWorld.java
native-image --static --libc=musl HelloWorld
./helloworld
test-additional:
name: Extensive tests on ubuntu-latest
name: extensive tests on ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ jobs:
| `components` | `''` | Comma-spearated list of GraalVM components (e.g., `native-image` or `ruby,nodejs`) that will be installed by the [GraalVM Updater][gu]. |
| `github-token` | `''` | Token for communication with the GitHub API. Please set to `${{ secrets.GITHUB_TOKEN }}` (see [templates](#templates)) to allow the action to authenticate with the GitHub API, which helps to reduce rate limiting issues. |
| `set-java-home` | `'true'` | If set to `'true'`, instructs the action to set `$JAVA_HOME` to the path of the GraalVM installation. |
| `native-image-musl` | `'false'` | If set to `'true'`, sets up [musl] for building [static images][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`). |


## Contributing

Expand All @@ -108,7 +110,10 @@ Only pull requests from committers that can be verified as having signed the OCA
[mandrel]: https://github.com/graalvm/mandrel
[mandrel-releases]: https://github.com/graalvm/mandrel/releases
[mandrel-stable]: https://github.com/graalvm/mandrel/releases/latest
[musl]: https://musl.libc.org/
[native-image]: https://www.graalvm.org/native-image/
[native-image-musl-build]: https://github.com/graalvm/setup-graalvm/blob/778131f1d6837ccd4b2e91382c31830896a2d56e/.github/workflows/test.yml#L74-L92
[native-image-static]: https://github.com/oracle/graal/blob/fa6f4a974dedacf4688dcc430dd100849d9882f2/docs/reference-manual/native-image/StaticImages.md
[oca]: https://oca.opensource.oracle.com
[releases]: https://github.com/graalvm/graalvm-ce-builds/releases
[repo]: https://github.com/oracle/graal
Expand Down
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ inputs:
description: 'Java version (11 or 17, 8 or 16 for older releases).'
components:
required: false
description: 'Comma-separated list of GraalVM components to be installed'
description: 'Comma-separated list of GraalVM components to be installed.'
default: ''
github-token:
required: false
description: 'Set it to secrets.GITHUB_TOKEN to increase rate limits when accessing the GitHub API'
description: 'Set it to secrets.GITHUB_TOKEN to increase rate limits when accessing the GitHub API.'
default: ''
set-java-home:
required: false
description: 'Set $JAVA_HOME to the GraalVM installation. Default: true'
description: 'Set $JAVA_HOME to the GraalVM installation. Default: true.'
default: 'true'
native-image-musl:
required: false
description: 'Set up musl for static image building with GraalVM Native Image.'
default: 'false'
runs:
using: 'node12'
main: 'dist/index.js'
85 changes: 83 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as otypes from '@octokit/types'
import {homedir} from 'os'
import {join} from 'path'

export const IS_LINUX = process.platform === 'linux'
export const IS_MACOS = process.platform === 'darwin'
export const IS_WINDOWS = process.platform === 'win32'

Expand Down
47 changes: 47 additions & 0 deletions src/features.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import {IS_LINUX} from './constants'
import {exec} from '@actions/exec'
import {homedir} from 'os'
import {join} from 'path'
import {mkdirP} from '@actions/io'

export async function setUpNativeImageMusl(): Promise<void> {
if (!IS_LINUX) {
core.warning('musl is only supported on Linux')
return
}
core.startGroup(`Setting up musl for GraalVM Native Image...`)
const basePath = join(homedir(), '.musl_feature')
await mkdirP(basePath)

const muslName = 'x86_64-linux-musl-native'
const muslDownloadPath = await tc.downloadTool(
`http://more.musl.cc/10/x86_64-linux-musl/${muslName}.tgz`
)
await tc.extractTar(muslDownloadPath, basePath)
const muslPath = join(basePath, muslName)
core.addPath(join(muslPath, 'bin'))

const zlibVersion = '1.2.11'
const zlibDownloadPath = await tc.downloadTool(
`https://zlib.net/zlib-${zlibVersion}.tar.gz`
)
await tc.extractTar(zlibDownloadPath, basePath)
const zlibPath = join(basePath, `zlib-${zlibVersion}`)
const zlibBuildOptions = {
cwd: zlibPath,
env: {
...process.env,
CC: join(muslPath, 'bin', 'gcc')
}
}
await exec(
'./configure',
[`--prefix=${muslPath}`, '--static'],
zlibBuildOptions
)
await exec('make', [], zlibBuildOptions)
await exec('make', ['install'], {cwd: zlibPath})
core.endGroup()
}
11 changes: 8 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@ import {mkdirP} from '@actions/io'
import {setUpDependencies} from './dependencies'
import {setUpGUComponents} from './gu'
import {setUpMandrel} from './mandrel'
import {setUpNativeImageMusl} from './features'
import {setUpWindowsEnvironment} from './msvc'

async function run(): Promise<void> {
try {
const graalvmVersion: string = core.getInput('version', {required: true})
const javaVersion: string = core.getInput('java-version', {required: true})
const graalvmVersion = core.getInput('version', {required: true})
const javaVersion = core.getInput('java-version', {required: true})
const componentsString: string = core.getInput('components')
const components: string[] =
componentsString.length > 0 ? componentsString.split(',') : []
const setJavaHome = core.getInput('set-java-home') === 'true'
const enableNativeImageMusl = core.getInput('native-image-musl') === 'true'

if (c.IS_WINDOWS) {
setUpWindowsEnvironment()
}
setUpDependencies(components)
await setUpDependencies(components)
if (enableNativeImageMusl) {
await setUpNativeImageMusl()
}

await mkdirP(c.GRAALVM_BASE)

Expand Down