-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add flat flow test functionality to the ReproTool #4559
base: main
Are you sure you want to change the base?
Changes from all commits
816c23a
b4e962e
eb4d650
d886ae0
cecf943
28eb736
24cd5b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Maestro.Data; | ||
using Microsoft.DotNet.DarcLib; | ||
using Microsoft.DotNet.ProductConstructionService.Client; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using Tools.Common; | ||
using GitHubClient = Octokit.GitHubClient; | ||
|
||
namespace ProductConstructionService.ReproTool.Operations; | ||
|
||
internal class FlatFlowTestOperation( | ||
VmrDependencyResolver vmrDependencyResolver, | ||
ILogger<FlatFlowTestOperation> logger, | ||
GitHubClient ghClient, | ||
BuildAssetRegistryContext context, | ||
DarcProcessManager darcProcessManager, | ||
IBarApiClient prodBarClient, | ||
[FromKeyedServices("local")] IProductConstructionServiceApi localPcsApi) : Operation(logger, ghClient, context, localPcsApi) | ||
{ | ||
internal override async Task RunAsync() | ||
{ | ||
await darcProcessManager.InitializeAsync(); | ||
|
||
var vmrRepos = await vmrDependencyResolver.GetVmrRepositoriesAsync( | ||
"https://github.com/dotnet/dotnet", | ||
"https://github.com/dotnet/sdk", | ||
"main"); | ||
|
||
vmrRepos = vmrRepos.Where(d => d.Mapping.Name == "runtime").ToList(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably stayed behind |
||
|
||
var vmrTestBranch = await PrepareVmrForkAsync("main", skipCleanup: true); | ||
|
||
var channelName = $"repro-{Guid.NewGuid()}"; | ||
await using var channel = await darcProcessManager.CreateTestChannelAsync(channelName, true); | ||
|
||
foreach (var vmrRepo in vmrRepos) | ||
{ | ||
var productRepoForkUri = $"{ProductRepoFormat}{vmrRepo.Mapping.Name}"; | ||
if (vmrRepo.Mapping.Name == "nuget-client") | ||
{ | ||
productRepoForkUri = $"{ProductRepoFormat}nuget.client"; | ||
} | ||
Comment on lines
+41
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The URI is in |
||
var latestBuild = await prodBarClient.GetLatestBuildAsync(vmrRepo.Mapping.DefaultRemote, vmrRepo.Channel.Channel.Id); | ||
|
||
var productRepoTmpBranch = await PrepareProductRepoForkAsync(vmrRepo.Mapping.DefaultRemote, productRepoForkUri, latestBuild.GetBranch(), false); | ||
|
||
var testBuild = await CreateBuildAsync( | ||
productRepoForkUri, | ||
productRepoTmpBranch.Value, | ||
latestBuild.Commit, | ||
[]); | ||
|
||
await UpdateVmrSourceFiles( | ||
vmrTestBranch.Value, | ||
vmrRepo.Mapping.DefaultRemote, | ||
productRepoForkUri); | ||
|
||
await using var testSubscription = await darcProcessManager.CreateSubscriptionAsync( | ||
channel: channelName, | ||
sourceRepo: productRepoForkUri, | ||
targetRepo: VmrForkUri, | ||
targetBranch: vmrTestBranch.Value, | ||
sourceDirectory: null, | ||
targetDirectory: vmrRepo.Mapping.Name, | ||
skipCleanup: true); | ||
|
||
await darcProcessManager.AddBuildToChannelAsync(testBuild.Id, channelName, skipCleanup: true); | ||
|
||
await TriggerSubscriptionAsync(testSubscription.Value); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Maestro.Data; | ||
using Microsoft.DotNet.DarcLib; | ||
using Microsoft.DotNet.ProductConstructionService.Client; | ||
using Microsoft.DotNet.ProductConstructionService.Client.Models; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using ProductConstructionService.ReproTool.Options; | ||
using Tools.Common; | ||
using GitHubClient = Octokit.GitHubClient; | ||
|
||
namespace ProductConstructionService.ReproTool.Operations; | ||
internal class FullBackflowTestOperation : Operation | ||
{ | ||
private readonly IBarApiClient _prodBarClient; | ||
private readonly FullBackflowTestOptions _options; | ||
private readonly DarcProcessManager _darcProcessManager; | ||
private readonly VmrDependencyResolver _vmrDependencyResolver; | ||
|
||
public FullBackflowTestOperation( | ||
ILogger<Operation> logger, | ||
GitHubClient ghClient, | ||
BuildAssetRegistryContext context, | ||
[FromKeyedServices("local")] IProductConstructionServiceApi localPcsApi, | ||
IBarApiClient prodBarClient, | ||
FullBackflowTestOptions options, | ||
DarcProcessManager darcProcessManager, | ||
VmrDependencyResolver vmrDependencyResolver) | ||
: base(logger, ghClient, context, localPcsApi) | ||
{ | ||
_prodBarClient = prodBarClient; | ||
_options = options; | ||
_darcProcessManager = darcProcessManager; | ||
_vmrDependencyResolver = vmrDependencyResolver; | ||
} | ||
|
||
internal override async Task RunAsync() | ||
{ | ||
await _darcProcessManager.InitializeAsync(); | ||
Build vmrBuild = await _prodBarClient.GetBuildAsync(_options.BuildId); | ||
|
||
Build testBuild = await CreateBuildAsync( | ||
VmrForkUri, | ||
_options.VmrBranch, | ||
_options.Commit, | ||
[ ..CreateAssetDataFromBuild(vmrBuild).Take(1000)]); | ||
|
||
var channelName = $"repro-{Guid.NewGuid()}"; | ||
await using var channel = await _darcProcessManager.CreateTestChannelAsync(channelName, skipCleanup: true); | ||
await _darcProcessManager.AddBuildToChannelAsync(testBuild.Id, channelName, skipCleanup: true); | ||
|
||
var vmrRepos = (await _vmrDependencyResolver.GetVmrRepositoriesAsync( | ||
"https://github.com/dotnet/dotnet", | ||
"https://github.com/dotnet/sdk", | ||
"main")); | ||
|
||
foreach (var vmrRepo in vmrRepos) | ||
{ | ||
var productRepoForkUri = $"{ProductRepoFormat}{vmrRepo.Mapping.Name}"; | ||
if (vmrRepo.Mapping.Name == "nuget-client") | ||
{ | ||
productRepoForkUri = $"{ProductRepoFormat}nuget.client"; | ||
} | ||
Comment on lines
+61
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as before |
||
|
||
var subscription = await _darcProcessManager.CreateSubscriptionAsync( | ||
channel: channelName, | ||
sourceRepo: VmrForkUri, | ||
targetRepo: productRepoForkUri, | ||
targetBranch: _options.TargetBranch, | ||
sourceDirectory: vmrRepo.Mapping.Name, | ||
targetDirectory: null, | ||
skipCleanup: true); | ||
|
||
await _darcProcessManager.TriggerSubscriptionAsync(subscription.Value); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably come from the
Options.VmrBranch
?