Code Monkey home page Code Monkey logo

setup-graalvm's Introduction

GitHub Action for GraalVM build-test

This GitHub action sets up GraalVM Community Edition (CE) or Enterprise Edition (EE) as well as GraalVM components such as Native Image and Truffle languages.

Key Features

This action:

  • supports GraalVM Community Edition (CE) releases, dev builds, GraalVM Enterprise Edition (EE) releases (set gds-token) 22.1.0 and later, and Mandrel (see options)
  • has built-in support for GraalVM components and the GraalVM Updater
  • exports a $GRAALVM_HOME environment variable
  • adds $GRAALVM_HOME/bin to the $PATH environment variable
    (Truffle languages and tools can be invoked directly)
  • sets $JAVA_HOME to $GRAALVM_HOME by default
    (can be disabled via set-java-home: 'false', see options)
  • supports amd64 and aarch64 (selected automatically, aarch64 requires a self-hosted runner)
  • sets up Windows environments with build tools using vcvarsall.bat
  • supports dependency caching for Apache Maven, Gradle, and sbt (see cache option)

Templates

Quickstart Template

name: GraalVM Community Edition build
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: graalvm/setup-graalvm@v1
        with:
          version: 'latest'
          java-version: '17'
          components: 'native-image'
          github-token: ${{ secrets.GITHUB_TOKEN }}
      - name: Example step
        run: |
          echo "GRAALVM_HOME: $GRAALVM_HOME"
          echo "JAVA_HOME: $JAVA_HOME"
          java --version
          gu --version
          native-image --version

Building a HelloWorld with GraalVM Native Image on Different Platforms

name: GraalVM Native Image builds
on: [push, pull_request]
jobs:
  build:
    name: HelloWorld on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]
    steps:
      - uses: actions/checkout@v2

      - uses: graalvm/setup-graalvm@v1
        with:
          version: '22.1.0'
          java-version: '11'
          components: 'native-image'
          github-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and run HelloWorld.java
        run: |
          echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }' > HelloWorld.java
          javac HelloWorld.java
          native-image HelloWorld
          ./helloworld
      
      - name: Upload binary
        uses: actions/upload-artifact@v2
        with:
          name: helloworld-${{ matrix.os }}
          path: helloworld*

Basic GraalVM Enterprise Edition Template

Prerequisites

  1. Download the version of GraalVM Enterprise Edition (EE) you want to run on GitHub Actions.
  2. Use the GraalVM Updater to install the GraalVM components you need on GitHub Actions and accept the corresponding licenses.
  3. Run $GRAALVM_HOME/bin/gu --show-ee-token to display your token for the GraalVM Download Service.
  4. Store this token as a GitHub Action secret. For this template, we use the name GDS_TOKEN.
name: GraalVM Enterprise Edition build
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: graalvm/setup-graalvm@v1
        with:
          version: '22.1.0'
          gds-token: ${{ secrets.GDS_TOKEN }}
          java-version: '11'
          components: 'native-image'
          github-token: ${{ secrets.GITHUB_TOKEN }}
      - name: Example step
        run: |
          java --version
          native-image --version

Options

Name Default Description
version
(required)
n/a X.Y.Z (e.g., 21.3.0) for a specific GraalVM release
latest for latest stable release,
dev for latest dev build,
mandrel-X.Y.Z (e.g., mandrel-21.3.0.0-Final) for a specific Mandrel release,
mandrel-latest for latest Mandrel stable release.
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).
java-version
(required)
n/a '11' or '17' for a specific Java version.
('8' and '16' are supported for GraalVM 21.2 and earlier.)
components '' Comma-spearated list of GraalVM components (e.g., native-image or ruby,nodejs) that will be installed by the GraalVM Updater.
github-token '' Token for communication with the GitHub API. Please set to ${{ secrets.GITHUB_TOKEN }} (see 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.
cache '' Name of the build platform to cache dependencies. It can be 'maven', 'gradle', or 'sbt' and works the same way it does in actions/setup-java.
native-image-musl 'false' If set to 'true', sets up musl for building static images with GraalVM Native Image (Linux only). Example usage (be sure to replace uses: ./ with uses: graalvm/setup-graalvm@v1).

Contributing

We welcome code contributions. To get started, you will need to sign the Oracle Contributor Agreement (OCA).

Only pull requests from committers that can be verified as having signed the OCA can be accepted.

setup-graalvm's People

Contributors

fniephaus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.