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

allow github reporter to work with git@ urls #3148

Merged
merged 1 commit into from Aug 8, 2017

Conversation

dragon512
Copy link
Contributor

@dragon512 dragon512 commented Apr 25, 2017

Allow GitHub to parse https:// and git@github.com:xxx style repository URLS correctly
Add some verbose messages that can be useful.

Contributor Checklist:

  • I have updated the unit tests
  • I have created a file in the master/buildbot/newsfragment directory (and read the README.txt in that directory)
  • I have updated the appropriate documentation

@mention-bot
Copy link

@dragon512, thanks for your PR! By analyzing the history of the files in this pull request, we identified @hcwiley, @tardyp and @anish to be potential reviewers.

@codecov
Copy link

codecov bot commented Apr 25, 2017

Codecov Report

Merging #3148 into master will increase coverage by <.01%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3148      +/-   ##
==========================================
+ Coverage   88.25%   88.26%   +<.01%     
==========================================
  Files         323      323              
  Lines       33712    33715       +3     
==========================================
+ Hits        29753    29758       +5     
+ Misses       3959     3957       -2
Impacted Files Coverage Δ
master/buildbot/reporters/github.py 93.81% <85.71%> (+2.32%) ⬆️

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 a3c6532...bf6f0fc. Read the comment docs.

repoOwner, repoName = project.split('/')
else:
# Given we have a repository define try to get the owner and name
elif sourcestamps[0]['repository']:
Copy link
Member

Choose a reason for hiding this comment

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

Please install codecov chrome extension or look at the report.
We require that those kind of changes are unit tested before they can be included in the code

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe using the project property is safe since github changes coming in via the www hook or PullrequestPoller have the project property set to the correct value only timed/force schedulers would have to set that property.

@@ -94,10 +95,16 @@ def createStatus(self,
if context is not None:
payload['context'] = context

return self._http.post(
if self.verbose:
Copy link
Member

Choose a reason for hiding this comment

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

I guess this is a separate feature which belongs to a separate PR. I think this would be better to put it in HttpBase reporter

repoOwner = repo[0]
repoName = '.'.join(repo[1].split('.')[:-1])
# if this repo is in the form of git@ not http://
if sourcestamps[0]['repository'].startswith("git@"):
Copy link
Member

Choose a reason for hiding this comment

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

I think this algorithm is useful not only for github, but also for bitbucket, gitlab, and all github clones.

We should factorize it in an utility function in (create new buildbot.util.repository_urls module)

def getUserAndProjectFromRepoUrl(repoUrl):
     [...]

@Frodox
Copy link
Member

Frodox commented Jun 9, 2017

Looks like it should fix #3215
Ping @dragon512 @samvasko

P.s. take a look #3305

@dragon512
Copy link
Contributor Author

Cool, I should pull this change in and redo the fix with this new util.

@tardyp
Copy link
Member

tardyp commented Jun 9, 2017

@dragon512 please do.

@dragon512 dragon512 force-pushed the github-reporter-fix branch 3 times, most recently from 3b7d6b0 to 580eeb8 Compare June 14, 2017 18:52
@@ -205,5 +216,6 @@ def createStatus(self,
payload = {'body': description}

return self._http.post(
'/'.join(['/repos', repo_user, repo_name, 'issues', issue, 'comments']),
'/'.join(['/repos', repo_user, repo_name,
Copy link
Member

Choose a reason for hiding this comment

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

What is the goal of such wrapping here, and leave this one as is? (Since it is less 80 characters anyway)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I formatted with autopep8. It seems to want to do this. I don't know why. I switch it back and did the format again .. this went back to the two line statement.

I can see about making the line length longer and seeing it this will go away

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya I just tried again with --max-line-length 132
It was still reformatting this line. I can manually set it back

@dragon512 dragon512 force-pushed the github-reporter-fix branch 2 times, most recently from fae5711 to 60967c3 Compare July 26, 2017 21:17
@dragon512
Copy link
Contributor Author

@tardyp I am unclear how this is failing worse. I rebased. I have a new test added to cover the basic three lines that had not been covered before. How is this reporting even worse coverage than before?

repoName = giturl.repo

if self.verbose:
log.msg("Updating github status: repoOwner={repoOwner}, repoName={repoName}".format(
Copy link
Member

Choose a reason for hiding this comment

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

codecov says this line is not covered. that's fine to me. just fix the doc issue.

@dragon512
Copy link
Contributor Author

there is no real doc change, as this fixes the reporter to correct consume json data with git@ formatted URLs. this is more of a bug fix, vs a API change

@Frodox
Copy link
Member

Frodox commented Jul 27, 2017

@dragon512 @tardyp means doc issue, i.e. it doesn't build because of spelling. Take a look test

relnotes/index.rst:33:RepoName:["Forename", "Repairmen", "Namedrop", "Reamonn", "Repentance", "Repiner"]
relnotes/index.rst:62:RepoName:["Forename", "Repairmen", "Namedrop", "Reamonn", "Repentance", "Repiner"]

@@ -0,0 +1 @@
GitHubStatusPush now support reporting to ssh style URLs, ie git@github.com:Owner/RepoName.git
Copy link
Member

@Frodox Frodox Jul 27, 2017

Choose a reason for hiding this comment

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

Could you please add link on GitHubStatusPush, format it with backtricks, and backtricks for git@github... (mark it as code). And looks like spell check doesn't like this RepoName. Or maybe later one. Anyway, you can add it to ignore list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I think I corrected it properly

@@ -136,12 +137,16 @@ def send(self, build):
else:
issue = None

if project:
if "/" in project:
Copy link
Member

Choose a reason for hiding this comment

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

what is it for? who can set project to smth like repoOwner/repoName ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was for when I set project to "foobar" not "owner/repo" This protects the code and allow the code to use the meta data that was really sent to get the data. There is no documentation other than that the project is a meta value. there is nothing saying that it can have magic values. I been burned by this a few times.

Add some verbose messages that can be useful
add a release note fragment
add test code
@dragon512
Copy link
Contributor Author

@tardyp I think I have it. Sorry for the delay on finishing this.

@dragon512
Copy link
Contributor Author

@tardyp Just a friendly ping. Is there anything holding back this PR from being merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants