graalvm / setup-graalvm

GitHub Action for setting up GraalVM distributions.
https://www.graalvm.org
Universal Permissive License v1.0
192 stars 27 forks source link

GraalVM CE is 20.0.1 but Quarkus currently supports 22.2.0. #49

Closed chainhead closed 1 year ago

chainhead commented 1 year ago

Hi, The following is a snippet of my GH action where, I am downloading the GraalVM CE and building the image for a native micro Quarkus application with maven.

    steps:
      - id: checkout
        name: Checkout repository
        uses: actions/checkout@v3

      - id: setup
        name: Set-up GraalVM
        uses: graalvm/setup-graalvm@v1
        with:
          distribution: 'graalvm-community'
          version: "20.0.1"
          java-version: '20'
          components: 'native-image'
          cache: 'maven'
          github-token: ${{ secrets.GITHUB_TOKEN }}

      - id: commit
        name: Get commit hash
        uses: pr-mpt/actions-commit-hash@v2

      - id: build
        name: Build with Maven
        run: > 
          mvn versions:set -DnewVersion=${{ github.ref_name}}-${{ steps.commit.outputs.short }} && 
          mvn package -Pnative

The build keeps failing as shown below.

Error:  Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.13.3.Final:build (default) on project streamer: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
Error: [ERROR]  [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.IllegalStateException: Out of date version of GraalVM detected: native-image 20.0.1 2023-04-18. Quarkus currently supports 22.2.0. Please upgrade GraalVM to this version.

I did try with graalvm and mandrel distribution (this issue #48 ) notwithstanding). I get the same error.

Why does this happen and what is the workaround?

fniephaus commented 1 year ago

Why does this happen and what is the workaround?

It seems you're using an older Quarkus release that is unable to detect the new GraalVM version scheme (Java version 20.X.Y instead of GraalVM version 23.X.Y). The best way to fix this is to upgrade to the latest version of Quarkus.

Having said that, the following no longer makes sense in the context of the graalvm-community and graalvm distributions:

          version: "20.0.1"
          java-version: '20'
          components: 'native-image'

You can set a specific java-version (e.g., 20.0.1), or major version (e.g., 20), version is no longer needed. Since native-image is now included by default, you also no longer need components: 'native-image'.

Hope this helps!

chainhead commented 1 year ago

This means, there are two fixes I need to do - Quarkus update and GH Action update for GraalVM set-up. Can you please guide me?

Quarkus update

  1. Do I just update the pom.xml and let mvn do its magic?
 <properties>
    <compiler-plugin.version>3.8.1</compiler-plugin.version>
    <maven.compiler.release>17</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
    <quarkus.platform.version>2.12.2.Final</quarkus.platform.version> <!-- change this? -->
    <skipITs>true</skipITs>
    <surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
  </properties>
  1. Should I also change the Dockerfile? I see there is a 2.0 available.
# Change base image to 2.0 tag
FROM quay.io/quarkus/quarkus-micro-image:1.0
WORKDIR /work/
RUN chown 1001 /work \
    && chmod "g+rwX" /work \
    && chown 1001:root /work
COPY --chown=1001:root target/*-runner /work/application

EXPOSE 8080
USER 1001

CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

GH Action update

  1. Looking at the documentation, this should do. BTW, java-version seems to be required - anyway, I can get the Action to use the 'latest'?
- id: setup
        name: Set-up GraalVM
        uses: graalvm/setup-graalvm@v1
        with:
          distribution: 'graalvm-community'
          java-version: '20'
          cache: 'maven'
          github-token: ${{ secrets.GITHUB_TOKEN }}
chainhead commented 1 year ago

So, the following worked.

pom.xml

  <properties>
    <compiler-plugin.version>3.11.0</compiler-plugin.version> <!-- changed this -->
    <maven.compiler.release>17</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
    <quarkus.platform.version>3.2.0.Final</quarkus.platform.version> <!-- changed this -->
    <skipITs>true</skipITs>
    <surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
  </properties>

publish.yaml

      - id: setup
        name: Set-up GraalVM
        uses: graalvm/setup-graalvm@v1
        with:
          distribution: 'graalvm-community'
          java-version: '20'
          cache: 'maven'
          github-token: ${{ secrets.GITHUB_TOKEN }}

Further, I will experiment the latest Quarkus base image.

Thanks.

fniephaus commented 1 year ago

anyway, I can get the Action to use the 'latest'?

You mean the latest Java version? You can use java-version: 'dev', which gives you a GraalVM dev build, which in turn are moved to the latest Java version whenever GraalVM is ready.

chainhead commented 1 year ago

I meant, current LTS version that is automatically referred to.

fniephaus commented 1 year ago

Ah ok, no, we don't have that. Given that there are years in between LTS releases, I'm not sure how useful an latest-lts label would be.

chainhead commented 1 year ago

1 pipeline less to manage. :)

fniephaus commented 1 year ago

It may cause more harm than it is useful. Also, it's not something setup-java supports, so I'm not sure we want to support it here. Maybe file a feature request and collect some upvotes? :)