Zomis / Duga

Stack Exchange Chat bot
18 stars 6 forks source link

Link to PR on AppVeyor build message #98

Closed Vannevelj closed 9 years ago

Vannevelj commented 9 years ago

When a PR builds on AppVeyor, the message shown in chat will contain a link to

  1. AppVeyor
  2. Commit
  3. Branch

Would it be possible to also link to the exact PR?

Zomis commented 9 years ago

Could you show an example of the JSON data that is sent to Duga? If the JSON contains the required information, the answer is yes. Otherwise no.

Vannevelj commented 9 years ago

Hmm. I don't immediately see anything that points towards it which is strange because the UI in AppVeyor itself indicates that it knows it's working on a PR.

{
"id": 287881646,
"sha": "783d44335558f8d0eff587281bdd60aa9632d2a8",
"name": "Vannevelj/VSDiagnostics",
"target_url": "https://ci.appveyor.com/project/Vannevelj/vsdiagnostics/build/1.8.134",
"context": "continuous-integration/appveyor",
"description": "AppVeyor build failed",
"state": "failure",
"commit": {
    "sha": "783d44335558f8d0eff587281bdd60aa9632d2a8",
    "commit": {
    "author": {
        "name": "Jeroen Vannevel",
        "email": "jer_vannevel@outlook.com",
        "date": "2015-08-18T17:14:08Z"
    },
    "committer": {
        "name": "Jeroen Vannevel",
        "email": "jer_vannevel@outlook.com",
        "date": "2015-08-18T17:14:08Z"
    },
    "message": "Merge pull request #179 from Vannevelj/issue174\n\nCloses #174",
    "tree": {
        "sha": "8768f2ae7f235dcad1a304ef56e896a59074ed98",
        "url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/git/trees/8768f2ae7f235dcad1a304ef56e896a59074ed98"
    },
    "url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/git/commits/783d44335558f8d0eff587281bdd60aa9632d2a8",
    "comment_count": 0
    },
    "url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/commits/783d44335558f8d0eff587281bdd60aa9632d2a8",
    "html_url": "https://github.com/Vannevelj/VSDiagnostics/commit/783d44335558f8d0eff587281bdd60aa9632d2a8",
    "comments_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/commits/783d44335558f8d0eff587281bdd60aa9632d2a8/comments",
    "author": {
    "login": "Vannevelj",
    "id": 2777107,
    "avatar_url": "https://avatars.githubusercontent.com/u/2777107?v=3",
    "gravatar_id": "",
    "url": "https://api.github.com/users/Vannevelj",
    "html_url": "https://github.com/Vannevelj",
    "followers_url": "https://api.github.com/users/Vannevelj/followers",
    "following_url": "https://api.github.com/users/Vannevelj/following{/other_user}",
    "gists_url": "https://api.github.com/users/Vannevelj/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/Vannevelj/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/Vannevelj/subscriptions",
    "organizations_url": "https://api.github.com/users/Vannevelj/orgs",
    "repos_url": "https://api.github.com/users/Vannevelj/repos",
    "events_url": "https://api.github.com/users/Vannevelj/events{/privacy}",
    "received_events_url": "https://api.github.com/users/Vannevelj/received_events",
    "type": "User",
    "site_admin": false
    },
    "committer": {
    "login": "Vannevelj",
    "id": 2777107,
    "avatar_url": "https://avatars.githubusercontent.com/u/2777107?v=3",
    "gravatar_id": "",
    "url": "https://api.github.com/users/Vannevelj",
    "html_url": "https://github.com/Vannevelj",
    "followers_url": "https://api.github.com/users/Vannevelj/followers",
    "following_url": "https://api.github.com/users/Vannevelj/following{/other_user}",
    "gists_url": "https://api.github.com/users/Vannevelj/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/Vannevelj/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/Vannevelj/subscriptions",
    "organizations_url": "https://api.github.com/users/Vannevelj/orgs",
    "repos_url": "https://api.github.com/users/Vannevelj/repos",
    "events_url": "https://api.github.com/users/Vannevelj/events{/privacy}",
    "received_events_url": "https://api.github.com/users/Vannevelj/received_events",
    "type": "User",
    "site_admin": false
    },
    "parents": [
    {
        "sha": "3c88877322f18cac0a9e99839529c4a59f19aece",
        "url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/commits/3c88877322f18cac0a9e99839529c4a59f19aece",
        "html_url": "https://github.com/Vannevelj/VSDiagnostics/commit/3c88877322f18cac0a9e99839529c4a59f19aece"
    },
    {
        "sha": "1550187c72e832a617c1964d713e4bc1a586d3d2",
        "url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/commits/1550187c72e832a617c1964d713e4bc1a586d3d2",
        "html_url": "https://github.com/Vannevelj/VSDiagnostics/commit/1550187c72e832a617c1964d713e4bc1a586d3d2"
    }
    ]
},
"branches": [
    {
    "name": "develop",
    "commit": {
        "sha": "d9b1248b0128cf69a01ee2c21a7b218c251d7554",
        "url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/commits/d9b1248b0128cf69a01ee2c21a7b218c251d7554"
    }
    }
],
"created_at": "2015-08-18T18:13:43Z",
"updated_at": "2015-08-18T18:13:43Z",
"repository": {
    "id": 34992631,
    "name": "VSDiagnostics",
    "full_name": "Vannevelj/VSDiagnostics",
    "owner": {
    "login": "Vannevelj",
    "id": 2777107,
    "avatar_url": "https://avatars.githubusercontent.com/u/2777107?v=3",
    "gravatar_id": "",
    "url": "https://api.github.com/users/Vannevelj",
    "html_url": "https://github.com/Vannevelj",
    "followers_url": "https://api.github.com/users/Vannevelj/followers",
    "following_url": "https://api.github.com/users/Vannevelj/following{/other_user}",
    "gists_url": "https://api.github.com/users/Vannevelj/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/Vannevelj/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/Vannevelj/subscriptions",
    "organizations_url": "https://api.github.com/users/Vannevelj/orgs",
    "repos_url": "https://api.github.com/users/Vannevelj/repos",
    "events_url": "https://api.github.com/users/Vannevelj/events{/privacy}",
    "received_events_url": "https://api.github.com/users/Vannevelj/received_events",
    "type": "User",
    "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/Vannevelj/VSDiagnostics",
    "description": "A collection of code-quality analyzers",
    "fork": false,
    "url": "https://api.github.com/repos/Vannevelj/VSDiagnostics",
    "forks_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/forks",
    "keys_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/teams",
    "hooks_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/hooks",
    "issue_events_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/issues/events{/number}",
    "events_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/events",
    "assignees_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/assignees{/user}",
    "branches_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/branches{/branch}",
    "tags_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/tags",
    "blobs_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/languages",
    "stargazers_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/stargazers",
    "contributors_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/contributors",
    "subscribers_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/subscribers",
    "subscription_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/subscription",
    "commits_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/contents/{+path}",
    "compare_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/merges",
    "archive_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/downloads",
    "issues_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/issues{/number}",
    "pulls_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/labels{/name}",
    "releases_url": "https://api.github.com/repos/Vannevelj/VSDiagnostics/releases{/id}",
    "created_at": "2015-05-03T16:33:02Z",
    "updated_at": "2015-07-17T21:31:08Z",
    "pushed_at": "2015-08-18T18:07:57Z",
    "git_url": "git://github.com/Vannevelj/VSDiagnostics.git",
    "ssh_url": "git@github.com:Vannevelj/VSDiagnostics.git",
    "clone_url": "https://github.com/Vannevelj/VSDiagnostics.git",
    "svn_url": "https://github.com/Vannevelj/VSDiagnostics",
    "homepage": null,
    "size": 1492,
    "stargazers_count": 20,
    "watchers_count": 20,
    "language": "C#",
    "has_issues": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "forks_count": 7,
    "mirror_url": null,
    "open_issues_count": 39,
    "forks": 7,
    "open_issues": 39,
    "watchers": 20,
    "default_branch": "master"
},
"sender": {
    "login": "Vannevelj",
    "id": 2777107,
    "avatar_url": "https://avatars.githubusercontent.com/u/2777107?v=3",
    "gravatar_id": "",
    "url": "https://api.github.com/users/Vannevelj",
    "html_url": "https://github.com/Vannevelj",
    "followers_url": "https://api.github.com/users/Vannevelj/followers",
    "following_url": "https://api.github.com/users/Vannevelj/following{/other_user}",
    "gists_url": "https://api.github.com/users/Vannevelj/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/Vannevelj/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/Vannevelj/subscriptions",
    "organizations_url": "https://api.github.com/users/Vannevelj/orgs",
    "repos_url": "https://api.github.com/users/Vannevelj/repos",
    "events_url": "https://api.github.com/users/Vannevelj/events{/privacy}",
    "received_events_url": "https://api.github.com/users/Vannevelj/received_events",
    "type": "User",
    "site_admin": false
}
}
Zomis commented 9 years ago

seems like the only thing that references the PR is the commit message,

"message": "Merge pull request #179 from Vannevelj/issue174\n\nCloses #174",

Don't think that is a good option to use though.

Zomis commented 9 years ago

I see no way to fix this, closing it. Might re-open if someone suggests a reasonable solution.

Vannevelj commented 9 years ago

You could check whether the commit contains #<number> and if it does, display a link to that github issue (github.com/user/repo/issues/<number>). Many PR messages contain something like that to reference the PR and the issue automatically on github. If you can't find it, you just don't add it.

Zomis commented 9 years ago

That's not something I consider a good solution. Not worth it IMO. [tag:status-declined]

Vogel612 commented 9 years ago

The JSON posted here looks like coming from a merge-commit, which usually is not part (and especially not tip) of a PR. @Vannevelj are you dead sure this is a PullRequest build?

Vannevelj commented 9 years ago

@Vogel612 good point. I just checked some recent logs and I found this hook:

{
  "ref": "refs/tags/v1.6.0",
  "before": "0000000000000000000000000000000000000000",
  "after": "c85c1511d900d6f86c5802ee8982e3fbf16d4821",
  "created": true,
  "deleted": false,
  "forced": true,
  "base_ref": "refs/heads/master",
  "compare": "https://github.com/Vannevelj/RoslynTester/compare/v1.6.0",
  "commits": [

  ],
  "head_commit": {
    "id": "c85c1511d900d6f86c5802ee8982e3fbf16d4821",
    "distinct": true,
    "message": "Merge pull request #18 from Vannevelj/VBBugFixes\n\nVb bug fixes",
    "timestamp": "2015-09-18T04:44:53+02:00",
    "url": "https://github.com/Vannevelj/RoslynTester/commit/c85c1511d900d6f86c5802ee8982e3fbf16d4821",
    "author": {
        "name": "Jeroen Vannevel",
      "email": "jer_vannevel@outlook.com",
      "username": "Vannevelj"
    },
    "committer": {
        "name": "Jeroen Vannevel",
      "email": "jer_vannevel@outlook.com",
      "username": "Vannevelj"
    },
    "added": [
      "RoslynTester/RoslynTester/Helpers/Testing/InvalidCodeException.cs",
      "RoslynTester/Tests/SampleAnalyzerWithErrorSeverity/TestAnalyzerWithErrorSeverity.cs",
      "RoslynTester/Tests/SampleAnalyzerWithErrorSeverity/TestCodeFixWithErrorSeverity.cs",
      "RoslynTester/Tests/Tests/SampleAnalyzerWithErrorSeverityTests.cs",
      "RoslynTester/Tests/Tests/SampleAnalyzer_VBAndCSharp_CSharpTests.cs",
      "RoslynTester/Tests/Tests/SampleAnalyzer_VBAndCSharp_VisualBasicTests.cs"
    ],
    "removed": [
      "RoslynTester/Tests/Tests/EnumCanHaveFlagsAttributeCSharpTests.cs",
      "RoslynTester/Tests/Tests/EnumCanHaveFlagsAttributeVisualBasicTests.cs"
    ],
    "modified": [
      "RoslynTester/RoslynTester/Helpers/DiagnosticVerifier.cs",
      "RoslynTester/RoslynTester/RoslynTester.csproj",
      "RoslynTester/Tests/SampleAnalyzer_FixIntroducesNewDiagnostic/SampleAnalyzer_FixIntroducesNewDiagnosticCodeFix.cs",
      "RoslynTester/Tests/Tests.csproj",
      "RoslynTester/Tests/Tests/SampleAnalyzerTests.cs",
      "RoslynTester/Tests/Tests/SampleVBAnalyzerTests.cs"
    ]
  },
  "repository": {
    "id": 36010519,
    "name": "RoslynTester",
    "full_name": "Vannevelj/RoslynTester",
    "owner": {
        "name": "Vannevelj",
      "email": "jer_vannevel@outlook.com"
    },
    "private": false,
    "html_url": "https://github.com/Vannevelj/RoslynTester",
    "description": "A library that will help you unit test your Roslyn analyzers",
    "fork": false,
    "url": "https://github.com/Vannevelj/RoslynTester",
    "forks_url": "https://api.github.com/repos/Vannevelj/RoslynTester/forks",
    "keys_url": "https://api.github.com/repos/Vannevelj/RoslynTester/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/Vannevelj/RoslynTester/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/Vannevelj/RoslynTester/teams",
    "hooks_url": "https://api.github.com/repos/Vannevelj/RoslynTester/hooks",
    "issue_events_url": "https://api.github.com/repos/Vannevelj/RoslynTester/issues/events{/number}",
    "events_url": "https://api.github.com/repos/Vannevelj/RoslynTester/events",
    "assignees_url": "https://api.github.com/repos/Vannevelj/RoslynTester/assignees{/user}",
    "branches_url": "https://api.github.com/repos/Vannevelj/RoslynTester/branches{/branch}",
    "tags_url": "https://api.github.com/repos/Vannevelj/RoslynTester/tags",
    "blobs_url": "https://api.github.com/repos/Vannevelj/RoslynTester/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/Vannevelj/RoslynTester/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/Vannevelj/RoslynTester/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/Vannevelj/RoslynTester/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/Vannevelj/RoslynTester/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/Vannevelj/RoslynTester/languages",
    "stargazers_url": "https://api.github.com/repos/Vannevelj/RoslynTester/stargazers",
    "contributors_url": "https://api.github.com/repos/Vannevelj/RoslynTester/contributors",
    "subscribers_url": "https://api.github.com/repos/Vannevelj/RoslynTester/subscribers",
    "subscription_url": "https://api.github.com/repos/Vannevelj/RoslynTester/subscription",
    "commits_url": "https://api.github.com/repos/Vannevelj/RoslynTester/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/Vannevelj/RoslynTester/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/Vannevelj/RoslynTester/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/Vannevelj/RoslynTester/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/Vannevelj/RoslynTester/contents/{+path}",
    "compare_url": "https://api.github.com/repos/Vannevelj/RoslynTester/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/Vannevelj/RoslynTester/merges",
    "archive_url": "https://api.github.com/repos/Vannevelj/RoslynTester/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/Vannevelj/RoslynTester/downloads",
    "issues_url": "https://api.github.com/repos/Vannevelj/RoslynTester/issues{/number}",
    "pulls_url": "https://api.github.com/repos/Vannevelj/RoslynTester/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/Vannevelj/RoslynTester/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/Vannevelj/RoslynTester/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/Vannevelj/RoslynTester/labels{/name}",
    "releases_url": "https://api.github.com/repos/Vannevelj/RoslynTester/releases{/id}",
    "created_at": 1432210029,
    "updated_at": "2015-08-04T20:46:45Z",
    "pushed_at": 1443041575,
    "git_url": "git://github.com/Vannevelj/RoslynTester.git",
    "ssh_url": "git@github.com:Vannevelj/RoslynTester.git",
    "clone_url": "https://github.com/Vannevelj/RoslynTester.git",
    "svn_url": "https://github.com/Vannevelj/RoslynTester",
    "homepage": null,
    "size": 634,
    "stargazers_count": 2,
    "watchers_count": 2,
    "language": "C#",
    "has_issues": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "forks_count": 2,
    "mirror_url": null,
    "open_issues_count": 1,
    "forks": 2,
    "open_issues": 1,
    "watchers": 2,
    "default_branch": "master",
    "stargazers": 2,
    "master_branch": "master"
  },
  "pusher": {
    "name": "Vannevelj",
    "email": "jer_vannevel@outlook.com"
  },
  "sender": {
    "login": "Vannevelj",
    "id": 2777107,
    "avatar_url": "https://avatars.githubusercontent.com/u/2777107?v=3",
    "gravatar_id": "",
    "url": "https://api.github.com/users/Vannevelj",
    "html_url": "https://github.com/Vannevelj",
    "followers_url": "https://api.github.com/users/Vannevelj/followers",
    "following_url": "https://api.github.com/users/Vannevelj/following{/other_user}",
    "gists_url": "https://api.github.com/users/Vannevelj/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/Vannevelj/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/Vannevelj/subscriptions",
    "organizations_url": "https://api.github.com/users/Vannevelj/orgs",
    "repos_url": "https://api.github.com/users/Vannevelj/repos",
    "events_url": "https://api.github.com/users/Vannevelj/events{/privacy}",
    "received_events_url": "https://api.github.com/users/Vannevelj/received_events",
    "type": "User",
    "site_admin": false
  }
}

This seems like a different merge commit though I'm sure at least one of them must've been done through a proper PR, if not both. I looked at other deliveries and these seem most relevant -- yet, no link to the PR.