hub4j / github-api

Java API for GitHub
https://github-api.kohsuke.org/
MIT License
1.14k stars 727 forks source link

Support state reason for issues #1793

Closed stianst closed 7 months ago

stianst commented 7 months ago

Hi, first of thanks for providing this library. I'm using it quite a lot, but finding a few things that are missing for my needs, and trying to contribute those, with the first one being supporting closing issues as not planned.

Trying to figure out how to work with the testsuite, but having a few issues.

When running mvn install -Dtest.github.org=false -Dtest=GHIssueTest I'm getting the following exception:

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.String java.net.HttpURLConnection.method accessible: module java.base does not "opens java.net" to unnamed module @551bca18

Another thing is the test is hardwired to hub4j-test-org which I don't have access to, so guess I need to use my own repository somehow.

Closes #1792

gsmet commented 7 months ago

Hey @stianst ,

Yeah, you usually need access to the test org when recording testing as it's easier for them to be reproduced by others when something needs a change.

You need @bitwiseman for that.

As for the error you have when running the tests, the test runs by default with an HTTP Client that is not compatible with Java 17+. Run them with Java 11 and things should work better.

gsmet commented 7 months ago

Ah, actually, good news, I forgot I had the permission to do that.

I added you to the test org. You should have received an invite.

@bitwiseman Stian is a colleague from Red Hat leading the Keycloak project.

gsmet commented 7 months ago

Ah also, do not record things for all the tests, doing:

rm -rf src/test/resources/org/kohsuke/github/GHIssueTest/wiremock/closeIssue/
mvn install -Dtest.github.takeSnapshot -Dtest=GHIssueTest#closeIssue
rm -rf src/test/resources/org/kohsuke/github/GHIssueTest/wiremock/closeIssueNotPlanned/
mvn install -Dtest.github.takeSnapshot -Dtest=GHIssueTest#closeIssueNotPlanned

will be better.

Then you should add the new snapshots to your commit.

stianst commented 7 months ago

Got the test working eventually (well, okay I only spent 30 min, so this wasn't too bad ;)), but used an org I created for the purpose. Will try with the official org and update the data.

stianst commented 7 months ago

@gsmet @bitwiseman would it be okay to enable fine-grained personal access tokens for the org (https://github.com/organizations/hub4j-test-org/settings/personal-access-tokens-onboarding). They are a bit nicer than the legacy tokens as you can limit to a specific org/repo.

stianst commented 7 months ago

Should be ready to go now

bitwiseman commented 7 months ago

@gsmet @bitwiseman would it be okay to enable fine-grained personal access tokens for the org (https://github.com/organizations/hub4j-test-org/settings/personal-access-tokens-onboarding). They are a bit nicer than the legacy tokens as you can limit to a specific org/repo.

Enabled the fine-grained PATs.

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (be00e51) 80.64% compared to head (ddaec5f) 80.69%. Report is 4 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1793 +/- ## ============================================ + Coverage 80.64% 80.69% +0.04% - Complexity 2322 2328 +6 ============================================ Files 219 220 +1 Lines 7027 7043 +16 Branches 371 371 ============================================ + Hits 5667 5683 +16 Misses 1128 1128 Partials 232 232 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

stianst commented 7 months ago

Fixed the last issue with using EnumUtils.getNullableEnumOrDefault and added Javadocs to GHIssueStateReason since the site job complained about that.

stianst commented 7 months ago

@bitwiseman hi, sorry to ping you on this as I'm sure you're busy with other stuff. Just wondering a bit on when/if this could be merged and what the plans are for a new release? I'm a bit blocked on this for some automation for the Keycloak project.