setup-java icon indicating copy to clipboard operation
setup-java copied to clipboard

Add Support for JetBrains Runtime

Open gmitch215 opened this issue 1 year ago • 20 comments

Current Workaround

- name: Setup JBR 21
  uses: gmitch215/setup-java@cba808d047291bcc112e7af979a7622d2cd18ff0
  with:
    distribution: 'jetbrains'
    java-version: 21
    cache: 'gradle'
  # For GitHub API (use if you believe you'd run into rate limits)
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Description: This PR adds support for the JetBrains Runtime, which is required in dependencies like jewel and useful for Compose Multiplatform.

The PR uses the binaries listed in Binaries for Developers , using the JBRSDK with JCEF flavor as shown in the releases page. It uses the GitHub API to find and parse versions, then calculates the URL using cache-redirector.jetbrains.com with the parsed SemVer, OS, Arch, and build number, which all output a .tar.gz file. Left a few comments in there for maintainability.

Since this uses the GitHub API, you can optionally specify a GITHUB_TOKEN environmental variable to increase your rate limit.

Related issue:

  • Closes #399
  • Closes #585 (Duplicate)

Check list:

  • [ ] Mark if documentation changes are required.
  • [x] Mark if tests were added or updated to cover the changes.

Notes Tested using jetbrains-installer.test.ts. Most of the tests were copied from other installers, but some I couldn't figure out how to bring over, so additional work may be required. I also copied downloadTool from the Temurin installer.

I also executed npm run build for dist/setup/index.js. I think something else was also thrown because I was on TypeScript 5.3, so I'm not sure how that will affect ncc.

gmitch215 avatar Jun 05 '24 20:06 gmitch215

I'm using your branch as a workaround

  # TODO: replace this once https://github.com/actions/setup-java/pull/637 gets merged.
  - uses: gmitch215/setup-java@07ea605e4b1f0f8b0621155fb1722d6094c3e183
    with:
      distribution: 'jetbrains'
      java-version: 17

with an error:

Installed distributions
  Error: No supported distribution was found for input jetbrains

is there anything I can do?

See:

  • https://github.com/Goooler/kotlin-explorer/actions/runs/9574788494/job/26398609733
  • https://github.com/Goooler/kotlin-explorer/commit/abfa1e3d127d3c8c3edfbf5c57d70068845f9773

Goooler avatar Jun 19 '24 01:06 Goooler

Hmm, I'll debug and get back here later.

gmitch215 avatar Jun 19 '24 03:06 gmitch215

Seems I just forgot to add it to the map of recognized runtimes to their IDs. Update your commit hash and it should succeed.

My project passed with the following configuration:

      - name: Setup JBR 17
        uses: gmitch215/setup-java@7f3ab2648f3d20faa20c4fe6e52a455757e0f38a
        with:
          distribution: 'jetbrains'
          java-version: 17
          cache: 'gradle'

Output: image

gmitch215 avatar Jun 19 '24 03:06 gmitch215

It could be picked correctly now!

But seems some libs are missing in this JDK installed.

Execution failed for task ':checkRuntime'.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
> Failed to check JDK distribution: 'jlink', 'jpackage' are missing

  JDK distribution path: /Users/runner/hostedtoolcache/Java_JetBrains_jdk/17.0.11-1312.2/arm64/Contents/Home

See https://github.com/Goooler/kotlin-explorer/actions/runs/9575738587/job/26401058613.

Goooler avatar Jun 19 '24 03:06 Goooler

The JDK installed by Gradle toolchain worked fine.

Invalid Java installation found at '/Users/runner/.gradle/jdks/jetbrains_s_r_o_-17-aarch64-os_x/jbrsdk_jcef-17.0.11-osx-aarch64-b1207.24/Contents/Home' (Auto-provisioned by Gradle). It will be re-checked in the next build. This might have performance impact if it keeps failing. Run the 'javaToolchains' task for more details.

Seems we need Binaries for developers instead of Binaries for launching IntelliJ IDEA, which is installed by your action. Check https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-17.0.11b1312.2.

Goooler avatar Jun 19 '24 03:06 Goooler

I switched the URL to the ones listed in the Binaries for Developers section, still getting the same errors. Going to do some more research.

gmitch215 avatar Jun 19 '24 04:06 gmitch215

I guessed correctly! :checkRuntime seems to pass.

      - name: Setup JBR 17
        uses: gmitch215/setup-java@99fc2135f7f7b08068e180cb5f29340f9de70720
        with:
          distribution: 'jetbrains'
          java-version: 17
          cache: 'gradle'

(This action failed due to below)

image

Note: Running on windows-latest seems to fail, so I'll fix that too.

gmitch215 avatar Jun 19 '24 04:06 gmitch215

99fc2135f7f7b08068e180cb5f29340f9de70720 works for me now, someone who needs this can ref https://github.com/romainguy/kotlin-explorer/pull/62.

Thanks for your quick response!

Goooler avatar Jun 19 '24 04:06 Goooler

Got windows-latest to build now. Everything else works fine too.

      - name: Setup JBR 17
        uses: gmitch215/setup-java@e1f4c15facc0cf68c0e764340e374be034e4a859
        with:
          distribution: 'jetbrains'
          java-version: 17
          cache: 'gradle'

gmitch215 avatar Jun 19 '24 04:06 gmitch215

Thank you @gmitch215, I'm using your branch as a workaround too and can confirm it works fine! It would be great if this contribution could be accepted.

eskatos avatar Jul 06 '24 11:07 eskatos

On a relatively complex workflow with a fan-out setup and composite actions that parallelize builds I get rate limit failures from time to time:

Run gmitch215/setup-java@36531813787dd0ff3269feeb1144b35b3d68f927
  with:
    java-version: 21
    java-package: jdk
    distribution: jetbrains
    check-latest: false
    server-id: github
    server-username: GITHUB_ACTOR
    server-password: GITHUB_TOKEN
    overwrite-settings: true
    job-status: success
    token: ***
Installed distributions
  Trying to resolve the latest version from remote
  Error: API rate limit exceeded for 52.159.14[7](https://github.com/eskatos/private-repository/actions/runs/1234567890/job/1234567890#step:3:8).63. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)

Is there something that can be done in this action's implementation or on my side?

eskatos avatar Jul 08 '24 22:07 eskatos

@eskatos The JetBrains cache-redirector server does rate limit by IP. To my knowledge, there isn't a way to change the rate limit. The root URL's info page is internal as well, and only accessible by employees.

Your best bet is to do something that changes the IP (not sure if re-running it manually does this, but worth a shot). Unless someone knows how the runner could provide authentication.

Edit: This error page is about the GitHub API, which is something I need to add. However, the above is still true.

Edit 2: Done.

- name: Setup JBR 21
  uses: gmitch215/setup-java@b4d76a354bef7187244f74eea4e80e674a7b4b55
  with:
    distribution: 'jetbrains'
    java-version: 21
    cache: 'gradle'

gmitch215 avatar Jul 09 '24 01:07 gmitch215

Re-running did make the job pass indeed.

This error page is about the GitHub API, which is something I need to add.

Thank you for fixing this!

eskatos avatar Jul 09 '24 06:07 eskatos

With b4d76a354bef7187244f74eea4e80e674a7b4b55 I'm getting this:

  Trying to resolve the latest version from remote
  Error: Bad credentials

eskatos avatar Jul 09 '24 07:07 eskatos

@eskatos I forgot GitHub doesn't automatically inject the GITHUB_TOKEN environment variable on action workflows.

The action should now check if it is provided. Update to this:

- name: Setup JBR 21
  uses: gmitch215/setup-java@6d2c5e1f82f180ae79f799f0ed6e3e5efb4e664d
  with:
    distribution: 'jetbrains'
    java-version: 21
    cache: 'gradle'
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

gmitch215 avatar Jul 09 '24 15:07 gmitch215

Thanks, works for me!

eskatos avatar Jul 10 '24 05:07 eskatos

Hi @HarithaVattikuti,

Sorry about this unsollicited direct ping. I noticed that you recently merged several PRs around JDK support in action/setup-java. I would like to bring your attention to this PR that adds support for the JetBrains Runtime JDK.

It is very useful to anyone doing Compose Multiplatform development. Some folks, including me, are already using it with success.

Would it be possible to give this PR some love?

eskatos avatar Sep 09 '24 08:09 eskatos

+1. Will try to resolve the merge conflicts at some point.

gmitch215 avatar Sep 09 '24 12:09 gmitch215

Conflicts have been resolved.

@HarithaVattikuti would love to see this PR get merged.

gmitch215 avatar Sep 11 '24 14:09 gmitch215

Hello @gmitch215 , We are working to prioritize this feature. We will update you once we have some feedback.

HarithaVattikuti avatar Sep 23 '24 14:09 HarithaVattikuti

Hi, @gmitch215 - thanks for your work!!! Small question: for now, we should keep using

uses: gmitch215/setup-java@6d2c5e1f82f180ae79f799f0ed6e3e5efb4e664d

Till this is merged?

Thanks again

Jonatha1983 avatar Sep 29 '24 05:09 Jonatha1983

Hi, @gmitch215 - thanks for your work!!!

Small question: for now, we should keep using


uses: gmitch215/setup-java@6d2c5e1f82f180ae79f799f0ed6e3e5efb4e664d

Till this is merged?

Thanks again

Sure. The most recent commit for the workaround is available in the top message of this PR.

gmitch215 avatar Sep 29 '24 17:09 gmitch215

@HarithaVattikuti been 2 weeks since we last spoke, any updates?

gmitch215 avatar Oct 04 '24 13:10 gmitch215

Hi @gmitch215, a few checks are failing in the PR:

Build the project using Prettier: Ensure that you run Prettier to format the code properly.

JDK 11 Naming Convention Issue: When using JDK 11, the system expects the version to be in the format 11_0_16b2043.64 instead of 11.0.16-b2043.64. This discrepancy is causing the current failure.

Please update the PR once these issues are resolved.

mahabaleshwars avatar Oct 09 '24 14:10 mahabaleshwars

@mahabaleshwars Issues fixed. I also added a test suite that checks if the URLs return 403 (access denied, meaning not found) instead of 200/302.

gmitch215 avatar Oct 14 '24 01:10 gmitch215

Hello @gmitch215,

Many of the checks are still failing, including those for JDK 11. Additionally, some links requested for JDK 11 are not available. For example, when tried on a Windows runner, the following URL was requested from the workflow: https://cache-redirector.jetbrains.com/intellij-jbr/jbrsdk_jcef-11.0.13-windows-x64-b1504.49.tar.gz, but it is not available at the source. Could you please rectify these issues and update the PR?

Before committing, please run the following commands in your project to ensure proper formatting and build success:

npm run format npm run build npm run test These commands will handle Prettier formatting and verify the distribution (Dist).

Thank you!

mahabaleshwars avatar Oct 17 '24 04:10 mahabaleshwars

Switched to plain JBRSDK and fixed the URL.

gmitch215 avatar Oct 19 '24 20:10 gmitch215

Hello @gmitch215, Many of the checks are still failing, including those for JDK 11. Please review the changes on your end and address these issues. Once updated, kindly update the PR.

aparnajyothi-y avatar Oct 25 '24 13:10 aparnajyothi-y

Hello @gmitch215,

Could you please confirm if the issues have been resolved and the PR has been updated? We would like to proceed with testing and approval once it's ready.

mahabaleshwars avatar Nov 05 '24 08:11 mahabaleshwars

The issues haven't been resolved yet - I'm still working on trying to figure out what the issues are with JDK 11 specifically. I'll get back to you once I've completed it.

gmitch215 avatar Nov 05 '24 16:11 gmitch215