-
Notifications
You must be signed in to change notification settings - Fork 369
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
[JENKINS-61290] hard to see why a branch was not inspected - log them #284
base: master
Are you sure you want to change the base?
Conversation
Solution: log the intentional ignoring of a branch Notes: I did not find an easy way in the web of calls between GitHubSCMSource.java#L987 where code begins "Checking branch" and BranchDiscoveryTrait.java#L230 where it decides the branch is not good by current strategy, so could not hook into the TaskListener and log right into the branch indexing run console. But at least seeing messages in common jenkins.log can help. Signed-off-by: Jim Klimov <[email protected]>
src/main/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTrait.java
Outdated
Show resolved
Hide resolved
I like this idea, but it might need some tweaking. |
Yes, as commented in the top post and in Jira, I unfortunately could not pick a way through all the Java magic to make these messages appear in the indexing/scan log where everyone with access to the job can see them. And which is the first place troubleshooters would look at. If someone knows how to make that happen - feel free to replace this PR by that better solution :) |
@jimklimov |
…he indexing console and not the server log (thanks @bitwiseman)
Thanks for the suggestion, the code is at least buildable :) I'd need to schedule a restart of my instance to test this build in practice. As for tests, the idea is along the lines of setting up a mock github repo with a master branch and at least two other branches, one of which has a PR to master; and somehow invoke the branch-indexing runs with the different strategies (three of them?) and check that the expected amount of branches were discovered, and that the indexing log contains expected lines from I assumed that except the last "indexing log" part, a test setup like this should already exist, but did not find one to extend. Logically BranchDiscoveryTraitTest.java looks like the place, but it seems to only care that expected Java classes for filtering get assigned to the call stack for different setups - and does not actually mock/run the indexing. |
I have prepared the mock data for some branches and PRs based on sanitized values from our repos that had the original problem (PR made from a branch in the repo and so hid it from indexing with our settings). But I just can't conjure up a way to have these files used by a test - whatever I do, the original mocks are used giving my test experiments completely different data to look at and fail on :( The "whatever I have before going to sleep" snapshot of that attempt is in https://github.com/jimklimov/github-branch-source-plugin/tree/log-ignored-branches-selftest if you'd care to propose what's wrong in that wild copypasta of things I do not understand :) |
As for logging - it does land into branch indexing console now, great thanks!
Beside a cosmetic nit of a missing blank line, that makes this message a bit less visible, all looks great :) |
…ranch, so the text line is not unreadably glued to next inspected branch
Newline added, nit resolved :)
|
Sorry for slow response, I was on on vacation. Yeah, the testing framework for this plugin really needs work. Can you add the code for your test (even though it fails) and I'll see if I can debug it? |
Thanks! As mentioned above, the experiments about testing were in https://github.com/jimklimov/github-branch-source-plugin/tree/log-ignored-branches-selftest branch and I did not progress much after that, had a lot of dayjob work to do. I think the relatively valuable commits there, compared to this PR, are files with (sanitized) saved responses for the GitHub REST API requests that happened for the original problem. The code to get them tested was more of a failed proof of concept and commented illustration of logic of the test I wanted to achieve. That said, I am not in favor of corrupting the buildability and practical usability of this PR by adding broken tests right into it (we run the HPI built from this, it works for us) :) |
…hes as of 2020-06-04
BranchDiscoveryTrait.java : report into scan log if a branch is ignored (because it is or is-not a source of PR, based on user choice of settings) similarly as proposed and refined for github-branch-source-plugin in jenkinsci/github-branch-source-plugin#284
This is a very much needed feature :) |
Per https://bugs.java.com/bugdatabase/view_bug.do;jsessionid=d014dfa686594180be40ca5872f5?bug_id=4907024 When the contents of an @see tag begins with a '<', the tag must be of the form: @see <a href="URL#value">label</a> So we need to either not start with "<" or drop trailing text...
782a55e
to
eecfdf2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all of these new test resource files actually used? I do not see any new (Java) test code. Perhaps these are left over from some commits years earlier, or does some existing test actually fail without them?
isExcluded()
hits into global jenkins log. Alas, I did not find a way to log it into the indexing run's log itself where it would be more appropriate.