Skip to content

Commit

Permalink
Bump to Octokit 10.0.0 to fix Int32 overflow issue and add disaster r…
Browse files Browse the repository at this point in the history
…ecovery docs (#75)

Bump to Octokit 10.0.0 to fix Int32 overflow issue and add disaster recovery docs
  • Loading branch information
jeffhandley authored Feb 23, 2024
2 parents f1dfd83 + 39eb4a2 commit 0571c52
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 19 deletions.
54 changes: 54 additions & 0 deletions Documentation/Disaster-Recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Issue Labeler Disaster Recovery Instructions

In events where all service instances need to be re-deployed, the following steps will guide you through the process.

1. Open and build the `issue-labeler.sln` solution to ensure a baseline build
- There will be build messages and warnings, but there should be no errors
2. Make the changes necessary
- If any package versions need to be bumped, the `eng\Versions.props` file controls all package versions
3. Rebuild the solution
4. Publish the `IssueLabelerService` project to the `dispatcher-app` service instance
- Right click on the `IssueLabelerService` project and choose **Publish...**
- If you don't yet have a publish profile saved, you will be guided through creating one
- Target: **Azure**
- Specific Target: **Azure App Service (Windows)**
- Subscription Name: **DDFun IaaS Dev Shared Public**
- Choose the `dispatcher-app` App Service instance from the `GitHubIssueLabeller` folder
![Choose the App Service](img/publish1.png)
- **Check the 'Deploy as ZIP package' box**
- Deployment type: **Publish (generates pubxml file)**
- Click Finish and close the window when it's complete
- In the Settings screen click one of the pencil icons to edit the Settings and make sure the following are set:
![Publish Configuration](img/publish2.png)
- **Configuration**: Release
- **Target framework**: net7.0
- **Deployment mode**: Self-contained
- **Target Runtime**: win-x64
- Click **Save**
- Click **Publish** (this will build the app and upload to Azure, and can take a few minutes)
5. Publish the `PredictionService` project to all of the other service instances
- Right click on the `PredictionService` project and choose **Publish...**
- If you don't yet have a publish profile saved, you will be guided through creating one
- Target: **Azure**
- Specific Target: **Azure App Service (Windows)**
- Subscription Name: **DDFun IaaS Dev Shared Public**
- Choose the App Service instance from the `GitHubIssueLabeller` folder, e.g. `nuget-home-labeler`
![Choose the App Service](img/publish1.png)
- **Check the 'Deploy as ZIP package' box**
- Deployment type: **Publish (generates pubxml file)**
- Click Finish and close the window when it's complete
- In the Settings screen click one of the pencil icons to edit the Settings and make sure the following are set:
![Publish Configuration](img/publish2.png)
- **Configuration**: Release
- **Target framework**: net7.0
- **Deployment mode**: Self-contained
- **Target Runtime**: win-x64
- Click **Save**
- Click **Publish** (this will build the app and upload to Azure, and can take a few minutes)
- Once finished, a browser window will open for the App Service instance,
- Repeat these steps of publishing the `PredictionService` to each of the remaining App Service instances by clicking **+ New profile**
- Be careful not to deploy the `PredictionService` to the `dispatcher-app` instance
- Be sure to edit the publish configuration for each profile created
6. Test the deployments
- Right-click on the `test/IssueLabelerService.DeploymentTests` project and **Run Tests**
- The `IssueLabelingTests.cs` file includes detailed notes for how to get full application logs should any tests fail
14 changes: 7 additions & 7 deletions Documentation/Implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ We use GraphQL and [Octokit](https://www.nuget.org/packages/Octokit/) to downloa

## ModelCreator

The [ModelCreator](https://github.com/dotnet/issue-labeler/tree/master/src/ModelCreator) project is responsible for:
The [ModelCreator](https://github.com/dotnet/issue-labeler/tree/main/src/ModelCreator) project is responsible for:

1. Downloading GitHub issues and pull requests
2. Specifying which data to download (title, description, labels, author, mentions, PR file names, optionally PR diff etc.)
Expand All @@ -33,17 +33,17 @@ This console application consumes the ZIP files produced by `ModelCreator` and u

After uploading new models to Azure and configuring the `PredictionService` to use the new models, the `ModelWarmup` console application can be used to load and warm up the models by issuing requests to the `PredictionService` for all of the repositories' models hosted by that service.

## PredictionService
## PredictionService (Deployed as several instances)

The [PredictionService](https://github.com/dotnet/issue-labeler/tree/master/src/PredictionService) project is the web application that uses ML models created using `ModelCreator` to predict area labels. Given repository owner/name/number combination, the `PredictionService` app provides an API returning top three predictions along with their confidence score. This information is computed using the ML models loaded in memory uploaded from Azure Blob Storage, which we produced in `ModelCreator` project.
The [PredictionService](https://github.com/dotnet/issue-labeler/tree/main/src/PredictionService) project is the web application that uses ML models created using `ModelCreator` to predict area labels. Given repository owner/name/number combination, the `PredictionService` app provides an API returning top three predictions along with their confidence score. This information is computed using the ML models loaded in memory uploaded from Azure Blob Storage, which we produced in `ModelCreator` project.

Since dotnet/runtime has a big set of area owners and contributors, we decided to use an automatic assignment for issues and PRs. In order to achieve automatic label assignments, a GitHub app listens to all issue and PR creations via a webhook setting and gets the top three predictions from the `PredictionService` and only when the top prediction score has above 40% confidence, then this labeler app is allowed to automatically add that area label name to the newly created issue or PR.

For dotnet/aspnetcore however, this webhook is not active and instead, the aspnetcore repository uses the https://hubbup.io web app to allow for manual area label assignment. Rather than doing automatic assignments, the hubbup app provides a nice UI for the prediction results it receives from [PredictionService](https://github.com/dotnet/issue-labeler/tree/master/src/PredictionService).
For dotnet/aspnetcore however, this webhook is not active and instead, the aspnetcore repository uses the https://hubbup.io web app to allow for manual area label assignment. Rather than doing automatic assignments, the hubbup app provides a nice UI for the prediction results it receives from [PredictionService](https://github.com/dotnet/issue-labeler/tree/main/src/PredictionService).

## IssueLabelerService
## IssueLabelerService (Deployed as a single `dispatcher-app` instance)

The [IssueLabelerService](https://github.com/dotnet/issue-labeler/tree/master/src/IssueLabelerService) project is the GitHub app that gets installed into repositories that opt into automatic issue labeling.
The [IssueLabelerService](https://github.com/dotnet/issue-labeler/tree/main/src/IssueLabelerService) project is the GitHub app that gets installed into repositories that opt into automatic issue labeling.

The GitHub app receives webhoook events for issue and pull request events, queries the top three predictions in a distributed way from the various `PredictionService` deployments (with routing based on org and repo), and updates the issues and pull requests with labels and comments per each repo's configuration.

Expand All @@ -55,4 +55,4 @@ The GitHub App is configured as the [dotnet-issue-labeler](https://github.com/ap

## IssueLabelerService.DeploymentTests

The [IssueLabelerService.DeploymentTests](https://github.com/dotnet/issue-labeler/tree/master/test/IssueLabelerService.DeploymentTests) test project will make requests to the production deployment of the `IssueLabelerService` (`dispatcher-app`) to verify that the service is responding to simulated webhook events.
The [IssueLabelerService.DeploymentTests](https://github.com/dotnet/issue-labeler/tree/main/test/IssueLabelerService.DeploymentTests) test project will make requests to the production deployment of the `IssueLabelerService` (`dispatcher-app`) to verify that the service is responding to simulated webhook events.
21 changes: 12 additions & 9 deletions Documentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,18 @@ Follow these steps to create a new labeler app:
1. Publish the labeler app from Visual Studio
- Clone the https://github.com/dotnet/issue-labeler repo
- Open the **issue-labeler.sln** solution in Visual Studio
- Check that you can build the **Microsoft.DotNet.Github.IssueLabeler** project
- Right-click on the **PredictionService** project and select **Publish...**
- Create a new Publish Profile and select **Azure** as the target, then pick **Azure App Service (Windows)** as the specific target
- Select the **DDFun IaaS Dev Shared Public** subscription (formerly known as **DDITPublic**)
- Select the App Service instance that you created earlier (for example, `nuget-home-labeler` or `dispatcher-app`), check the "Deploy as ZIP package" box, and click **Next**<br/>
![keyvault configration](img/publish1.png)
- Deployment type: Publish
- Click **Finish**, then **Close**
- Check that you can build the solution (there will be build warnings, but there should be no errors)
- Right-click on the **PredictionService** project and select **Publish...** to create a publish profile
- Target: **Azure**
- Specific Target: **Azure App Service (Windows)**
- Subscription Name: **DDFun IaaS Dev Shared Public**
- Choose the App Service instance from the `GitHubIssueLabeller` folder, e.g. `nuget-home-labeler`
![Choose the App Service](img/publish1.png)
- **Check the 'Deploy as ZIP package' box**
- Deployment type: **Publish (generates pubxml file)**
- Click Finish and close the window when it's complete
- In the Settings screen click one of the pencil icons to edit the Settings and make sure the following are set:<br/>
![keyvault configration](img/publish2.png)
![Publish Configuration](img/publish2.png)
- **Configuration**: Release
- **Target framework**: net7.0
- **Deployment mode**: Self-contained
Expand Down Expand Up @@ -248,3 +250,4 @@ With the new configuration settings in place, the `dotnet-issue-labeler` app als
## Further reading

* [Implementation details](./Implementation.md) - more details on how certain projects in this repo work
* [Disaster Recovery](./Disaster-Recovery.md) - how to perform a full deployment of services
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!-- GitHub Packages -->
<GitHubJwtVersion>0.0.6</GitHubJwtVersion>
<GraphQLClientVersion>6.0.0</GraphQLClientVersion>
<OctokitVersion>6.0.0</OctokitVersion>
<OctokitVersion>10.0.0</OctokitVersion>
<OctokitGraphQLVersion>0.2.0-beta</OctokitGraphQLVersion>

<!-- ML.NET Packages -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<UserSecretsId>dotnet-issue-labeler</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand All @@ -23,4 +25,8 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\GitHubHelpers\GitHubHelpers.csproj" />
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions test/IssueLabelerService.DeploymentTests/IssueLabelingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using GitHubHelpers;
using Microsoft.Extensions.Configuration;
using System.Text;

namespace IssueLabelerService.DeploymentTests;
Expand Down Expand Up @@ -178,4 +180,17 @@ public async Task POST_webhook_endpoint(string org, string repo, IssueOrPullRequ

Assert.True(response.IsSuccessStatusCode);
}

[Fact]
public async Task CanHandleIssuesBeyondInt32InternalGitHubId()
{
// This test requires the GitHubAccessToken user secret to be set.
// Instructions for setting it can be found in /Documentation/README.md
var config = new ConfigurationBuilder()
.AddUserSecrets("dotnet-issue-labeler")
.Build();

var gitHubClientWrapper = new GitHubClientWrapper(new OAuthGitHubClientFactory(config));
var issue = await gitHubClientWrapper.GetIssue("dotnet", "runtime", 98782);
}
}

0 comments on commit 0571c52

Please sign in to comment.