Skip to content

changes: add additional information to properties in GitHubPullrequestPoller#3074

Merged
tardyp merged 4 commits intobuildbot:masterfrom
noc0lour:extent_gh_information
Apr 12, 2017
Merged

changes: add additional information to properties in GitHubPullrequestPoller#3074
tardyp merged 4 commits intobuildbot:masterfrom
noc0lour:extent_gh_information

Conversation

@noc0lour
Copy link
Copy Markdown
Contributor

I want to checkout if this would have chances to get included into the main tree once I'm done refining it.
Basically I'd like to extract more information from the PR and add it to the properties which then can be used in the builders.

Yes, no? Or in a different way?

@mention-bot
Copy link
Copy Markdown

@noc0lour, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DaulPavid to be a potential reviewer.

@noc0lour
Copy link
Copy Markdown
Contributor Author

@tardyp this is more a "design" question I guess, if we allow additional special properties to propagate from different source steps.

@tardyp
Copy link
Copy Markdown
Member

tardyp commented Mar 25, 2017

You can look at the gerrit change source source code, it has similar code.
It does create one property per event attribute (recursively e.g
{
author: {'email': 'foo@bar'}
}
will create a property 'gerrit_event.author.email'

@noc0lour
Copy link
Copy Markdown
Contributor Author

noc0lour commented Mar 25, 2017

A cool, I'll have a look, probably I want to flatten them as well. For the GH PR information I don't want to create the properties automatically as this would pollute them with too much stuff.

@tardyp
Copy link
Copy Markdown
Member

tardyp commented Mar 25, 2017

indeed, this is a mistake that I made for gerrit design, we should have a whitelist configuration in the changesource (maybe fnmatch based).

@noc0lour noc0lour force-pushed the extent_gh_information branch from 26cf8e5 to ee917a1 Compare March 26, 2017 03:38
@noc0lour noc0lour changed the title feedback: Extent gh information changes: add additional information to properties in GitHubPullrequestPoller Mar 26, 2017
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2017

Codecov Report

Merging #3074 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3074      +/-   ##
=========================================
+ Coverage   88.29%   88.3%   +0.01%     
=========================================
  Files         314     314              
  Lines       32926   32959      +33     
=========================================
+ Hits        29071   29104      +33     
  Misses       3855    3855
Impacted Files Coverage Δ
master/buildbot/changes/github.py 100% <100%> (ø) ⬆️
master/buildbot/www/hooks/github.py 92.85% <100%> (+0.48%) ⬆️
master/buildbot/www/authz/endpointmatchers.py 93.79% <0%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 673afe8...bb728e1. Read the comment docs.

@noc0lour noc0lour force-pushed the extent_gh_information branch 4 times, most recently from cd47fc1 to f13056f Compare March 26, 2017 06:45
@noc0lour
Copy link
Copy Markdown
Contributor Author

I'd like to have the parsing of PRs in the webhook the same as it is in this PR poller. (e.g. add these changes there as well :) ). Should I just copy & paste ?

@seankelly
Copy link
Copy Markdown
Member

Yes. The poller and webhook should stay in sync for what features they support.

@noc0lour noc0lour force-pushed the extent_gh_information branch 3 times, most recently from 57d6210 to a28783c Compare March 27, 2017 03:19
"github.mergeable",
"github.mergeable_state",
"github.merged_by",
]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a lot of properties for the defaults.
This should be configurable

if not any([
prop.startswith(name)
for prop in self.GH_PROPERTY_WHITELIST
]):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would profer is you used fnmatch https://docs.python.org/2/library/fnmatch.html

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into fnmatch but it didn't seem to provide a lot of flexibility if I use a preconfigured list. I'll look into making the list of properties configurable.

return payload

def _get_PR_information(self, pr_info):
def flatten(properties, base, info_dict):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont like to copy the exact same code in two different places. maybe we should have it in a changes/github.py mixin class

@tardyp
Copy link
Copy Markdown
Member

tardyp commented Mar 27, 2017 via email

@noc0lour
Copy link
Copy Markdown
Contributor Author

I think the drawback of having a fnmatch expression is the whole tree has to be flattened first before it can be applied. Otherwise it couldn't match subtrees like github.base. or we match backwards (e.g. fnmatch.match(desired_key, key+"*") but then we don't have any advantages over using startswith.
if you are ok with first flatten the whole file and then matching desired entries (I'd prefer re over fnmatch anytime).

@noc0lour noc0lour force-pushed the extent_gh_information branch from a28783c to 4515672 Compare April 5, 2017 06:24
@noc0lour noc0lour force-pushed the extent_gh_information branch from 4515672 to fc07f35 Compare April 5, 2017 06:34
@noc0lour noc0lour force-pushed the extent_gh_information branch from fc07f35 to e908d9d Compare April 5, 2017 06:54
@noc0lour
Copy link
Copy Markdown
Contributor Author

noc0lour commented Apr 6, 2017

I have no idea why the coverage suddenly drops in files I did not even touch? And random things fail in the CI tests? @tardyp ? All files I touched have the same or better coverage.

@tardyp
Copy link
Copy Markdown
Member

tardyp commented Apr 6, 2017

@noc0lour its because py3.5 tests fail, thus the coverage of py3 is not taken in account

Copy link
Copy Markdown
Member

@tardyp tardyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! need to fix the py3 tests though

self.assertEqual(change['repository'],
'https://github.com/defunkt/buildbot.git')
self.assertEqual(change['files'], ['README.md'])
self.assertDictContainsSubset(_GH_PARSED_PROPS, change['properties'])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is deprecated in py3.2 (and we dont allow warnings)

https://docs.python.org/3/whatsnew/3.2.html?highlight=assertdictcontainssubset

you probably will need to replace that with a for k,v in _GH_PARSED_PROPS.items()

self.assertEqual(change['repository'],
'https://github.com/defunkt/buildbot.git')
self.assertEqual(change['files'], ['README.md'])
self.assertDictContainsSubset(_GH_PARSED_PROPS, change['properties'])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

name = ".".join([base, k])
if isinstance(v, dict):
flatten(properties, name, v)
elif any([fnmatch(name, expr)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@noc0lour
Copy link
Copy Markdown
Contributor Author

noc0lour commented Apr 6, 2017

Yay, codecov is happy again :)

@noc0lour
Copy link
Copy Markdown
Contributor Author

anything left :) ?

@tardyp tardyp merged commit 0334b20 into buildbot:master Apr 12, 2017
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.

4 participants