github-api icon indicating copy to clipboard operation
github-api copied to clipboard

Adds methods to GHRepository to get the top ten referral paths and referrers via the API

Open ihrigb opened this issue 1 year ago • 7 comments

Description

Adds methods to GHRepository to get the top ten referral paths and referrers via the API.

References:

  • https://docs.github.com/en/rest/metrics/traffic?apiVersion=2022-11-28#get-top-referral-paths
  • https://docs.github.com/en/rest/metrics/traffic?apiVersion=2022-11-28#get-top-referral-sources

Before submitting a PR:

  • [x] Changes must not break binary backwards compatibility. If you are unclear on how to make the change you think is needed while maintaining backward compatibility, CONTRIBUTING.md for details.
  • [x] Add JavaDocs and other comments explaining the behavior.
  • [x] When adding or updating methods that fetch entities, add @link JavaDoc entries to the relevant documentation on https://docs.github.com/en/rest .
  • [ ] Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See CONTRIBUTING.md for details.
  • [x] Run mvn -D enable-ci clean install site locally. If this command doesn't succeed, your change will not pass CI.
  • [x] Push your changes to a branch other than main. You will create your PR from that branch.

When creating a PR:

  • [x] Fill in the "Description" above with clear summary of the changes. This includes:
    • [x] If this PR fixes one or more issues, include "Fixes #" lines for each issue.
    • [x] Provide links to relevant documentation on https://docs.github.com/en/rest where possible. If not including links, explain why not.
  • [ ] All lines of new code should be covered by tests as reported by code coverage. Any lines that are not covered must have PR comments explaining why they cannot be covered. For example, "Reaching this particular exception is hard and is not a particular common scenario."
  • [x] Enable "Allow edits from maintainers".

ihrigb avatar Dec 14 '23 14:12 ihrigb

Maybe someone could help with tests here. I get No response could be served as there are no stub mappings in this WireMock instance..

Plus running mvn -D enable-ci clean install site does fail for me, even on the current main branch without my changes.

ihrigb avatar Dec 14 '23 15:12 ihrigb

What failure are you getting on main?

bitwiseman avatar Jan 05 '24 00:01 bitwiseman

[INFO] Results:
[INFO]
[ERROR] Errors: 
[ERROR]   AppTest.notifications:1706 » GHIO Failed to set the custom verb
[ERROR]   AppTest.testCreateCommitComment:914 » GHIO Failed to set the custom verb
[ERROR]   AppTest.testCreateIssue:274 » GHIO Failed to set the custom verb
[ERROR]   AppTest.testPullRequestSearch:1451 » GHIO Failed to set the custom verb
[ERROR]   AppTest.testRepoCRUD:59 » GHIO Failed to set the custom verb
[ERROR]   AppTest.testRepoLabel:1582 » GHIO Failed to set the custom verb
[ERROR]   GHCheckRunBuilderTest.createCheckRunManyAnnotations:104 » GHIO Failed to set the custom verb
[ERROR]   GHCheckRunBuilderTest.updateCheckRun:192 » GHIO Failed to set the custom verb
[ERROR]   GHDiscussionTest.testGetAndEditDiscussion:119 » GHIO Failed to set the custom verb
[ERROR]   GHGistTest.lifecycleTest:54 » GHIO Failed to set the custom verb
[ERROR]   GHGistUpdaterTest.testGitUpdater:70 » GHIO Failed to set the custom verb
[ERROR]   GHIssueEventTest.testEventsForIssueRename:97 » GHIO Failed to set the custom verb
[ERROR]   GHIssueEventTest.testEventsForSingleIssue:33 » GHIO Failed to set the custom verb
[ERROR]   GHIssueEventTest.testIssueReviewRequestedEvent:80 » GHIO Failed to set the custom verb
[ERROR]   GHIssueTest.closeIssue:160 » GHIO Failed to set the custom verb
[ERROR]   GHIssueTest.removeLabels:260 » GHIO Failed to set the custom verb
[ERROR]   GHIssueTest.setAssignee:298 » GHIO Failed to set the custom verb
[ERROR]   GHIssueTest.setLabels:175 » GHIO Failed to set the custom verb
[ERROR]   GHMilestoneTest.testUnsetMilestone:91 » GHIO Failed to set the custom verb
[ERROR]   GHMilestoneTest.testUnsetMilestoneFromPullRequest:115 » GHIO Failed to set the custom verb
[ERROR]   GHMilestoneTest.testUpdateMilestone:59 » GHIO Failed to set the custom verb
[ERROR]   GHOrganizationTest.testEnableOrganizationProjects:495 » GHIO Failed to set the custom verb
[ERROR]   GHProjectCardTest.testArchiveCard:69 » GHIO Failed to set the custom verb
[ERROR]   GHProjectCardTest.testEditCardNote:55 » GHIO Failed to set the custom verb
[ERROR]   GHProjectColumnTest.testEditColumnName:51 » GHIO Failed to set the custom verb
[ERROR]   GHProjectTest.testEditProjectBody:71 » GHIO Failed to set the custom verb
[ERROR]   GHProjectTest.testEditProjectName:56 » GHIO Failed to set the custom verb
[ERROR]   GHProjectTest.testEditProjectState:86 » GHIO Failed to set the custom verb
[ERROR]   GHReleaseTest.testMakeLatestRelease:191 » GHIO Failed to set the custom verb
[ERROR]   GHReleaseTest.testUpdateRelease:130 » GHIO Failed to set the custom verb
[ERROR]   GHRepositoryTest.archive:124 » GHIO Failed to set the custom verb
[ERROR]   GHRepositoryTest.setDeleteBranchOnMerge:995 » GHIO Failed to set the custom verb
[ERROR]   GHRepositoryTest.setMergeOptions:951 » GHIO Failed to set the custom verb
[ERROR]   GHRepositoryTest.testGetRepositoryWithVisibility:432 » GHIO Failed to set the custom verb
[ERROR]   GHRepositoryTest.testSearchPullRequests:1745 » GHIO Failed to set the custom verb
[ERROR]   GHRepositoryTest.testSetPublic:303 » GHIO Failed to set the custom verb
[ERROR]   GHRepositoryTest.testUpdateRepoActionVariable:1676 » GHIO Failed to set the custom verb
[ERROR]   GHRepositoryTest.testUpdateRepository:390 » GHIO Failed to set the custom verb
[ERROR]   GHTeamTest.testSetDescription:39 » GHIO Failed to set the custom verb
[ERROR]   GHTeamTest.testSetPrivacy:147 » GHIO Failed to set the custom verb
[ERROR]   GHTreeBuilderTest.testAdd:125->updateTree:187 » GHIO Failed to set the custom verb
[ERROR]   GHTreeBuilderTest.testDelete:149->updateTree:187 » GHIO Failed to set the custom verb
[ERROR]   GHTreeBuilderTest.testShaEntry:106->updateTree:187 » GHIO Failed to set the custom verb
[INFO]
[ERROR] Tests run: 458, Failures: 0, Errors: 43, Skipped: 25
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:56 min
[INFO] Finished at: 2024-01-08T12:40:18+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.2.3:test (default-test) on project github-api:
[ERROR]
[ERROR] Please refer to C:\SAPDevelop\opensource\github-api\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

ihrigb avatar Jan 08 '24 11:01 ihrigb

@bitwiseman ?

ihrigb avatar Feb 06 '24 09:02 ihrigb

@bitwiseman ping again

ihrigb avatar Mar 04 '24 14:03 ihrigb

@ihrigb To make the tests run locally, run this:

mvn -B clean install -D enable-ci "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"

I understand this differs from what is in CONTRIBUTING.md. I'm working on updating the build and the instructions to remove the need for that extra argument.

bitwiseman avatar Mar 08 '24 00:03 bitwiseman

In that case, the build is fine.

ihrigb avatar Mar 08 '24 14:03 ihrigb

@ihrigb It looks like there are still some CI failures. Please update this PR.

bitwiseman avatar Jun 20 '24 03:06 bitwiseman

@bitwiseman should be good now...

ihrigb avatar Jun 21 '24 12:06 ihrigb

Codecov Report

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

Project coverage is 80.87%. Comparing base (e8c6beb) to head (a6decf5).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1770      +/-   ##
============================================
+ Coverage     80.79%   80.87%   +0.07%     
- Complexity     2417     2430      +13     
============================================
  Files           233      236       +3     
  Lines          7264     7294      +30     
  Branches        398      398              
============================================
+ Hits           5869     5899      +30     
  Misses         1148     1148              
  Partials        247      247              

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

codecov[bot] avatar Jun 23 '24 19:06 codecov[bot]

@ihrigb Sorry, code coverage reporting was broken for a bit. Now it is working, please address items in the report.

bitwiseman avatar Jun 23 '24 19:06 bitwiseman

@bitwiseman can you please grant me access to hub4j-test-org?

ihrigb avatar Jul 01 '24 08:07 ihrigb

@bitwiseman finally ready to merge.

ihrigb avatar Jul 01 '24 12:07 ihrigb

You got reasonable tests without needing test-org access. Thanks for sticking with this!

bitwiseman avatar Jul 01 '24 17:07 bitwiseman

You got reasonable tests without needing test-org access. Thanks for sticking with this!

Is that preferrable over using the test org?

ihrigb avatar Jul 01 '24 18:07 ihrigb

No, test org is generally better for future test support, but wanted to get your change into this release.

bitwiseman avatar Jul 02 '24 00:07 bitwiseman

@bitwiseman I did get the invitation mail for the test org, but seems like the invitation itself does no longer exist.

ihrigb avatar Jul 03 '24 16:07 ihrigb

@ihrigb Resent invitation, so you have it for what ever your next PR is.

bitwiseman avatar Jul 03 '24 16:07 bitwiseman

Rulesets (#1181) ;) Thanks!

ihrigb avatar Jul 03 '24 16:07 ihrigb