Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for JetBrains Runtime #637

Merged
merged 33 commits into from
Dec 12, 2024
Merged

Conversation

gmitch215
Copy link
Contributor

@gmitch215 gmitch215 commented Jun 5, 2024

Current Workaround

- name: Setup JBR 21
  uses: gmitch215/setup-java@4e56c31b28053b7081e102121153633227d6dd8e
  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 flavor as shown in the releases page for the default flavor jdk. Alternative flavors include jdk+jcef and jdk+ft with jre counterparts.

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. Some tags have inconsistent naming conventions, or have been removed from public view for various reasons, so it will filter out those versions.

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

Related issue:

Check list:

  • Mark if documentation changes are required.
  • 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.

- Add Installer, Models
- Includes Tests & Test Manifest Data
- Add to `e2e-versions.yml`
- Run `npm run build`
- Update README.md
@gmitch215 gmitch215 requested a review from a team as a code owner June 5, 2024 20:55
@Goooler
Copy link

Goooler commented Jun 19, 2024

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:

@gmitch215
Copy link
Contributor Author

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

@gmitch215
Copy link
Contributor Author

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

@Goooler
Copy link

Goooler commented Jun 19, 2024

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
Copy link

Goooler commented Jun 19, 2024

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.

@gmitch215
Copy link
Contributor Author

gmitch215 commented Jun 19, 2024

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
Copy link
Contributor Author

gmitch215 commented Jun 19, 2024

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.

@Goooler
Copy link

Goooler commented Jun 19, 2024

99fc213 works for me now, someone who needs this can ref romainguy/kotlin-explorer#62.

Thanks for your quick response!

@gmitch215
Copy link
Contributor Author

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'

@eskatos
Copy link

eskatos commented Jul 6, 2024

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
Copy link

eskatos commented Jul 8, 2024

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?

@gmitch215
Copy link
Contributor Author

gmitch215 commented Jul 9, 2024

@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'

@eskatos
Copy link

eskatos commented Jul 9, 2024

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
Copy link

eskatos commented Jul 9, 2024

With b4d76a3 I'm getting this:

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

@gmitch215
Copy link
Contributor Author

gmitch215 commented Jul 9, 2024

@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 }}

@aparnajyothi-y
Copy link
Contributor

Hi @gmitch215, could you please confirm if you are working on updating the documentation to include information about the valid input for JDK 11?

@gmitch215
Copy link
Contributor Author

Hi @gmitch215, could you please confirm if you are working on updating the documentation to include information about the valid input for JDK 11?

Yes, currently working on new fixes.

@crowforkotlin
Copy link

hello, I use jewel in my project, which requires jbrsdk+jcef but I see that jbr doesn't have jpackage, so when I use ./gradlew packageDmg, I get an error! Failed to check JDK distribution: 'jpackage' is missing
Is there a way around this?

@gmitch215
Copy link
Contributor Author

gmitch215 commented Nov 28, 2024

hello, I use jewel in my project, which requires jbrsdk+jcef but I see that jbr doesn't have jpackage, so when I use ./gradlew packageDmg, I get an error! Failed to check JDK distribution: 'jpackage' is missing Is there a way around this?

You can use jdk+jcef as the package-type parameter and it should install it. I'll update the documentation soon.

@gmitch215
Copy link
Contributor Author

@aparnajyothi-y @mahabaleshwars Documentation is updated and hidden versions were added.

@crowforkotlin
Copy link

hello, I use jewel in my project, which requires jbrsdk+jcef but I see that jbr doesn't have jpackage, so when I use ./gradlew packageDmg, I get an error! Failed to check JDK distribution: 'jpackage' is missing Is there a way around this?

You can use jdk+jcef as the package-type parameter and it should install it. I'll update the documentation soon.

how to configure this ‘package-type’

@crowforkotlin
Copy link

@aparnajyothi-y @mahabaleshwars Documentation is updated and hidden versions were added.

Maybe I didn't make my question clear to you, you can look here JetBrains/jewel#709

@gmitch215
Copy link
Contributor Author

gmitch215 commented Nov 29, 2024

@aparnajyothi-y @mahabaleshwars Documentation is updated and hidden versions were added.

Maybe I didn't make my question clear to you, you can look here JetBrains/jewel#709

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

@crowforkotlin
Copy link

@aparnajyothi-y @mahabaleshwars Documentation is updated and hidden versions were added.

Maybe I didn't make my question clear to you, you can look here JetBrains/jewel#709

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

ok, thank you

@Jonatha1983
Copy link

@gmitch215 its package-type or java-package?
I am getting this:

Unexpected input(s) 'package-type', valid inputs are ['java-version', 'java-version-file', 'distribution', 'java-package', 'architecture', 'jdkFile', 'check-latest', 'server-id', 'server-username', 'server-password', 'settings-path', 'overwrite-settings', 'gpg-private-key', 'gpg-passphrase', 'cache', 'cache-dependency-path', 'job-status', 'token', 'mvn-toolchain-id', 'mvn-toolchain-vendor']

@gmitch215
Copy link
Contributor Author

@gmitch215 its package-type or java-package? I am getting this:

Unexpected input(s) 'package-type', valid inputs are ['java-version', 'java-version-file', 'distribution', 'java-package', 'architecture', 'jdkFile', 'check-latest', 'server-id', 'server-username', 'server-password', 'settings-path', 'overwrite-settings', 'gpg-private-key', 'gpg-passphrase', 'cache', 'cache-dependency-path', 'job-status', 'token', 'mvn-toolchain-id', 'mvn-toolchain-vendor']

That's correct, my bad.

@mahabaleshwars
Copy link
Contributor

Hello @gmitch215,

Thanks again for the continuous improvements to the PR! The latest changes addressing the issue with JDK 11.0.10 and the documentation look great. However, I’ve noticed a couple of things that still need attention:

There are some CI failures that can be fixed by running the command:
npm audit fix

Regarding the JDK version input, the documentation mentions that versions are based on the GitHub tags on the JetBrains Runtime releases page, with both underscores (11_0_13) and dots (11.0.13) supported. While the dot format is encouraged for consistency, both are valid. That said, when the input for JDK 11 contains underscores, it is still failing. I see that you've already addressed this, but could you please take another look to see if there’s something we might have missed? I’ve attached a screenshot for reference.

Screenshot 2024-12-03 at 7 09 52 PM

Thanks again for your work on this!

@gmitch215
Copy link
Contributor Author

gmitch215 commented Dec 4, 2024

@mahabaleshwars Availability between using _ and . is usually inconsistent, especially on JDK 11. Sometimes it works and sometimes it doesn't.

That being said, I notice some tags do exist with underscore notation (_), so I'll take a look and update code/documentation.

Thank you all for moving this forward!

@gmitch215
Copy link
Contributor Author

@mahabaleshwars

Dot notation is enforced by the base installer, so underscore support is not possible. Updated the documentation to reflect this and fixed a typo.

Also ran npm audit fix.

@gmitch215
Copy link
Contributor Author

Once again, macos-latest issues are with GraalVM.

@mahabaleshwars
Copy link
Contributor

Hello @gmitch215, CI workflow issues are fixed now and this should address the issues in this PR. Please sync the main branch with setup-java.

@gmitch215
Copy link
Contributor Author

@mahabaleshwars Done.

@HarithaVattikuti HarithaVattikuti merged commit 7a6d8a8 into actions:main Dec 12, 2024
364 checks passed
roxterrr1 pushed a commit to roxterrr1/setup-java that referenced this pull request Dec 15, 2024
* Add Support for JetBrains Runtime

- Add Installer, Models
- Includes Tests & Test Manifest Data
- Add to `e2e-versions.yml`
- Run `npm run build`
- Update README.md

* Add Docs + Distro Factory

* Fix Runtime Unrecognizable

* `npm run build` (JBR)

* Fix Incorrect JBR Distribution

* Switch to `jbrsdk_jcef`

* Fix Incorrect File Extension

* `npm run build` (JBR)

* Fix Windows Support

* Add `GITHUB_TOKEN` Authentication

* Update Authorization, Add Documentation

* Fix PR Issues

- Fix JDK 11 URL Bug
- Add JDK URL Testing to ensure versions can be downloaded
- Run Prettier

* Change Distribution to \`jbrsdk\`

* Don't Replace Underscores

* Fix `semver` not resolving correctly

* Update e2e-versions.yml

- Add `GITHUB_TOKEN` environment variable for JetBrains requests
- Add `jetbrains` to other E2E tests

* `npm run format`

* Fix Format, Inaccessible URLs

* Update Tests

* Fix Broken URLs, Add Additional Package Types

* `npm run build`

* Fix JetBrains Tests, Issues in `e2e-versions.yml`

* Add Hidden JDK 11 Versions

* Update `jetbrains-installer` Tests

* Add Notices in Documentation

* Fix Documentation

* Run `npm audit fix`

* Fix Tests on Windows
mergify bot added a commit to ArcadeData/arcadedb that referenced this pull request Dec 23, 2024
build(deps): bump actions/setup-java from 4.5.0 to 4.6.0
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 4.5.0 to 4.6.0.
Release notes

*Sourced from [actions/setup-java's releases](https://github.com/actions/setup-java/releases).*

> v4.6.0
> ------
> 
> What's Changed
> --------------
> 
> **Add-ons:**
> 
> * Add Support for JetBrains Runtime by [`@​gmitch215`](https://github.com/gmitch215) in [actions/setup-java#637](https://redirect.github.com/actions/setup-java/pull/637)
> 
> ```
>  - name: Checkout
>    uses: actions/checkout@v4
>  - name: Setup-java
>    uses: actions/setup-java@v4
>    with:
>      distribution: ‘jetbrains’
>      java-version: '21'
> 
> ```
> 
> **Bug fixes:**
> 
> * Fix Ubuntu-latest CI failures by [`@​mahabaleshwars`](https://github.com/mahabaleshwars) in [actions/setup-java#693](https://redirect.github.com/actions/setup-java/pull/693)
> 
> New Contributors
> ----------------
> 
> * [`@​gmitch215`](https://github.com/gmitch215) made their first contribution in [actions/setup-java#637](https://redirect.github.com/actions/setup-java/pull/637)
> 
> **Full Changelog**: <actions/setup-java@v4...v4.6.0>


Commits

* [`7a6d8a8`](actions/setup-java@7a6d8a8) Add Support for JetBrains Runtime ([#637](https://redirect.github.com/actions/setup-java/issues/637))
* [`7136edc`](actions/setup-java@7136edc) Fix sbt and x86 CI failures on Ubuntu-24 ([#693](https://redirect.github.com/actions/setup-java/issues/693))
* See full diff in [compare view](actions/setup-java@8df1039...7a6d8a8)

  

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=actions/setup-java&package-manager=github\_actions&previous-version=4.5.0&new-version=4.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JDK support distribution JBR (jetbrains runtime version) Support JetBrainsRuntime distribution
9 participants