-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathFlatFlowTestOperation.cs
68 lines (55 loc) · 2.72 KB
/
FlatFlowTestOperation.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// 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,
DarcProcessManager darcProcessManager,
IBarApiClient prodBarClient,
[FromKeyedServices("local")] IProductConstructionServiceApi localPcsApi) : Operation(logger, ghClient, 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");
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.DefaultRemote.Split('/', StringSplitOptions.RemoveEmptyEntries).Last()}";
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);
}
}
}