forked from Azure/iotedge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Devops Service: Auto assign bugs to owners (Azure#5334)
We have bug generation tooling for failing tests. The next step here is to assign them to the responsible party. This can be done by assigning a bug to the commit author of the failing build. If commits are batched, the assignee will be responsible for determining if any potential failures are caused by their changes and triaging if needed. In order to do this, the existing bug creation abstraction (`BugManagement`) has been modified via composition to contain two more abstractions. Specifically these steps were taken: 1. Parse the commit from from the devops api response and store in the VstsBuild datatype object. 2. Use new abstraction `CommitManagement` that can take a commit and return a full name. This full name is determined through the git config of the committer at commit time. Since microsoft open source guidelines specify to declare your full name on your account, this should be a safe assumption. 3. Use new abstraction `UserManagement` to take the committer full name and look up the email address for this microsoft identity. 4. Once we have the email address of the committer we can open a bug on them. Here is an example bug: https://msazure.visualstudio.com/One/_workitems/edit/10570189 Also I took this as an opportunity to add isa95 to the devops service.
- Loading branch information
1 parent
6f9816b
commit b3a61b1
Showing
19 changed files
with
252 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
namespace DevOpsLib | ||
{ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Flurl; | ||
using Flurl.Http; | ||
using Newtonsoft.Json.Linq; | ||
|
||
public class CommitManagement | ||
{ | ||
const string UserPathSegmentFormat = "https://api.github.com/repos/Azure/iotedge/commits/{0}"; | ||
|
||
public CommitManagement() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// This method is used to get a commit author's full name via the github rest api. | ||
/// Reference: https://docs.github.com/en/rest | ||
/// For an example response: https://api.github.com/repos/Azure/iotedge/commits/704250b | ||
/// </summary> | ||
/// <param name="commit">Commit for which to get the author's full name.</param> | ||
/// <returns>Full name of author.</returns> | ||
public async Task<string> GetAuthorFullNameFromCommitAsync(string commit) | ||
{ | ||
string requestPath = string.Format(UserPathSegmentFormat, commit); | ||
|
||
IFlurlRequest workItemQueryRequest = ((Url)requestPath) | ||
.WithHeader("Content-Type", "application/json") | ||
.WithHeader("User-Agent", "Azure/iotedge"); | ||
|
||
JObject result; | ||
try | ||
{ | ||
IFlurlResponse response = await workItemQueryRequest.GetAsync(); | ||
result = await response.GetJsonAsync<JObject>(); | ||
string fullName = result["commit"]["author"]["name"].ToString(); | ||
return fullName; | ||
} | ||
catch (FlurlHttpException e) | ||
{ | ||
string message = $"Failed making call to commit api: {e.Message}"; | ||
Console.WriteLine(message); | ||
Console.WriteLine(e.Call.RequestBody); | ||
Console.WriteLine(e.Call.Response.StatusCode); | ||
Console.WriteLine(e.Call.Response.ResponseMessage); | ||
|
||
throw new Exception(message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.