diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 76c258146e..5aeeab1ae6 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "microsoft.dnceng.secretmanager": { - "version": "1.1.0-beta.24562.1", + "version": "1.1.0-beta.24605.8", "commands": [ "secret-manager" ] @@ -15,7 +15,7 @@ ] }, "microsoft.dnceng.configuration.bootstrap": { - "version": "1.1.0-beta.24562.1", + "version": "1.1.0-beta.24605.8", "commands": [ "bootstrap-dnceng-configuration" ] diff --git a/Directory.Packages.props b/Directory.Packages.props index 5e2dc4038f..64c507e795 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -97,6 +97,7 @@ + @@ -155,6 +156,7 @@ https://dnceng.visualstudio.com/internal/_workitems/edit/5117 --> + diff --git a/arcade-services.sln b/arcade-services.sln index 03f9ccf517..63a2a68817 100644 --- a/arcade-services.sln +++ b/arcade-services.sln @@ -88,8 +88,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProductConstructionService. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Maestro.Authentication", "src\Maestro\Maestro.Authentication\Maestro.Authentication.csproj", "{70D48B7A-DBFE-4762-A83F-4617ECF80838}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProductConstructionService.Client", "src\ProductConstructionService\ProductConstructionService.Client\ProductConstructionService.Client.csproj", "{964FA796-358E-48AE-B75C-E42132600BCC}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Maestro.Common", "src\Maestro\Maestro.Common\Maestro.Common.csproj", "{16F086DD-8387-44BB-87D5-CD804355A110}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProductConstructionService.SubscriptionTriggerer", "src\ProductConstructionService\ProductConstructionService.SubscriptionTriggerer\ProductConstructionService.SubscriptionTriggerer.csproj", "{C70CD49F-052C-472B-A420-4215B708C478}" @@ -122,6 +120,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductConstructionService. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductConstructionService.BarViz", "src\ProductConstructionService\ProductConstructionService.BarViz\ProductConstructionService.BarViz.csproj", "{B993607A-BD63-47A8-AF5D-7B49ACF0AF21}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DotNet.ProductConstructionService.Client", "src\ProductConstructionService\Microsoft.DotNet.ProductConstructionService.Client\Microsoft.DotNet.ProductConstructionService.Client.csproj", "{0F27CF0C-4C95-DB17-AF84-78197F32FEBE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -505,18 +505,6 @@ Global {70D48B7A-DBFE-4762-A83F-4617ECF80838}.Release|x64.Build.0 = Release|Any CPU {70D48B7A-DBFE-4762-A83F-4617ECF80838}.Release|x86.ActiveCfg = Release|Any CPU {70D48B7A-DBFE-4762-A83F-4617ECF80838}.Release|x86.Build.0 = Release|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Debug|x64.ActiveCfg = Debug|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Debug|x64.Build.0 = Debug|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Debug|x86.ActiveCfg = Debug|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Debug|x86.Build.0 = Debug|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Release|Any CPU.Build.0 = Release|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Release|x64.ActiveCfg = Release|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Release|x64.Build.0 = Release|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Release|x86.ActiveCfg = Release|Any CPU - {964FA796-358E-48AE-B75C-E42132600BCC}.Release|x86.Build.0 = Release|Any CPU {16F086DD-8387-44BB-87D5-CD804355A110}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {16F086DD-8387-44BB-87D5-CD804355A110}.Debug|Any CPU.Build.0 = Debug|Any CPU {16F086DD-8387-44BB-87D5-CD804355A110}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -709,6 +697,18 @@ Global {B993607A-BD63-47A8-AF5D-7B49ACF0AF21}.Release|x64.Build.0 = Release|Any CPU {B993607A-BD63-47A8-AF5D-7B49ACF0AF21}.Release|x86.ActiveCfg = Release|Any CPU {B993607A-BD63-47A8-AF5D-7B49ACF0AF21}.Release|x86.Build.0 = Release|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Debug|x64.ActiveCfg = Debug|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Debug|x64.Build.0 = Debug|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Debug|x86.ActiveCfg = Debug|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Debug|x86.Build.0 = Debug|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Release|Any CPU.Build.0 = Release|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Release|x64.ActiveCfg = Release|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Release|x64.Build.0 = Release|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Release|x86.ActiveCfg = Release|Any CPU + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -748,7 +748,6 @@ Global {243A4561-BF35-405A-AF12-AC57BB27796D} = {D4718FE8-B3EA-4543-A424-315E649A4F70} {BB8CC065-79D6-48CE-AD96-32EDDDC4D404} = {1A456CF0-C09A-4DE6-89CE-1110EED31180} {70D48B7A-DBFE-4762-A83F-4617ECF80838} = {AE791E26-78E1-4936-BCF4-1BF5152CBBD6} - {964FA796-358E-48AE-B75C-E42132600BCC} = {243A4561-BF35-405A-AF12-AC57BB27796D} {16F086DD-8387-44BB-87D5-CD804355A110} = {AE791E26-78E1-4936-BCF4-1BF5152CBBD6} {C70CD49F-052C-472B-A420-4215B708C478} = {243A4561-BF35-405A-AF12-AC57BB27796D} {CAB42DEB-5D9D-42D6-BF4E-DAAD9C7B5C66} = {AE791E26-78E1-4936-BCF4-1BF5152CBBD6} @@ -765,6 +764,7 @@ Global {12D91D30-EC50-4D2B-8D67-0C19FCD2303F} = {1A456CF0-C09A-4DE6-89CE-1110EED31180} {A4125B78-593D-4659-AA28-0E176D4644E5} = {243A4561-BF35-405A-AF12-AC57BB27796D} {B993607A-BD63-47A8-AF5D-7B49ACF0AF21} = {243A4561-BF35-405A-AF12-AC57BB27796D} + {0F27CF0C-4C95-DB17-AF84-78197F32FEBE} = {243A4561-BF35-405A-AF12-AC57BB27796D} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {32B9C883-432E-4FC8-A1BF-090EB033DD5B} diff --git a/azure-pipelines-product-construction-service.yml b/azure-pipelines-product-construction-service.yml index 919def75d1..afc790ad54 100644 --- a/azure-pipelines-product-construction-service.yml +++ b/azure-pipelines-product-construction-service.yml @@ -154,10 +154,23 @@ stages: devBranchSuffix: $(devBranchSuffix) dockerImageName: $(dockerRegistryUrl)/$(containerName) -- ${{ if notin(variables['Build.Reason'], 'PullRequest') }}: +- ${{ if and(notin(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal')) }}: + - stage: Approval + dependsOn: + - Build + jobs: + - deployment: approval + displayName: Deployment approval + ${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/production') }}: + environment: Production + ${{ else }}: + environment: Staging + pool: server + - stage: DeployPCS dependsOn: - Build + - Approval displayName: Deploy Product Construction Service jobs: diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index d149100d4c..9c7d78a24d 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -115,13 +115,13 @@ https://github.com/dotnet/arcade 3c7e11bf80279cde53a6251c4d0fa10e613fc739 - + https://github.com/dotnet/dnceng - b61ece47324607e2ab69de0b6e8cf2d19cef2570 + 54066b7abcc2b7ec05ade63be8d91c44fcfc1c9d - + https://github.com/dotnet/dnceng - b61ece47324607e2ab69de0b6e8cf2d19cef2570 + 54066b7abcc2b7ec05ade63be8d91c44fcfc1c9d diff --git a/eng/Versions.props b/eng/Versions.props index bcf24f1e85..12396dbabf 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -37,8 +37,8 @@ 1.1.0-beta.24606.1 1.1.0-beta.24606.1 1.1.0-beta.24606.1 - 1.1.0-beta.24562.1 - 1.1.0-beta.24562.1 + 1.1.0-beta.24605.8 + 1.1.0-beta.24605.8 diff --git a/eng/templates/jobs/e2e-pcs-tests.yml b/eng/templates/jobs/e2e-pcs-tests.yml index 7319270766..7248cedb84 100644 --- a/eng/templates/jobs/e2e-pcs-tests.yml +++ b/eng/templates/jobs/e2e-pcs-tests.yml @@ -22,7 +22,7 @@ jobs: - group: Arcade-Services-Scenario-Tests - ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/heads/production'), startsWith(variables['Build.SourceBranch'], 'refs/heads/production-'), eq(variables['Build.SourceBranch'], 'refs/heads/production'))) }}: - name: PcsTestEndpoint - value: https://product-construction-int.delightfuldune-c0f01ab0.westus2.azurecontainerapps.io + value: https://product-construction-int.agreeablesky-499be9de.westus2.azurecontainerapps.io - name: ScenarioTestSubscription value: "Darc: Maestro Staging" - name: MaestroAppId diff --git a/eng/templates/stages/deploy.yaml b/eng/templates/stages/deploy.yaml index 1319daed7d..2931206985 100644 --- a/eng/templates/stages/deploy.yaml +++ b/eng/templates/stages/deploy.yaml @@ -20,9 +20,6 @@ stages: ${{ else }}: environment: Staging pool: server - strategy: - runOnce: - deploy: {} - stage: deploy displayName: Deploy diff --git a/src/Maestro/Client/src/MaestroApiOptions.cs b/src/Maestro/Client/src/MaestroApiOptions.cs index e7385abe87..8ef91470f1 100644 --- a/src/Maestro/Client/src/MaestroApiOptions.cs +++ b/src/Maestro/Client/src/MaestroApiOptions.cs @@ -23,7 +23,7 @@ public partial class MaestroApiOptions public const string StagingMaestroUri = "https://maestro.int-dot.net/"; public const string OldPcsStagingUri = "https://maestro-int.westus2.cloudapp.azure.com/"; public const string PcsProdUri = "https://product-construction-prod.wittysky-0c79e3cc.westus2.azurecontainerapps.io/"; - public const string PcsStagingUri = "https://product-construction-int.delightfuldune-c0f01ab0.westus2.azurecontainerapps.io/"; + public const string PcsStagingUri = "https://product-construction-int.agreeablesky-499be9de.westus2.azurecontainerapps.io/"; public const string PcsLocalUri = "https://localhost:53180/"; private const string APP_USER_SCOPE = "Maestro.User"; diff --git a/src/Maestro/SubscriptionActorService/Program.cs b/src/Maestro/SubscriptionActorService/Program.cs index 6c2c1ec5ff..0c711e5478 100644 --- a/src/Maestro/SubscriptionActorService/Program.cs +++ b/src/Maestro/SubscriptionActorService/Program.cs @@ -17,7 +17,6 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using Octokit; -using ProductConstructionService.Client; namespace SubscriptionActorService; @@ -74,19 +73,6 @@ public static void Configure(IServiceCollection services) }); services.Configure("GitHub", (o, s) => s.Bind(o)); services.Configure("AzureDevOps", (o, s) => s.Bind(o)); - services.AddSingleton(s => - { - var config = s.GetRequiredService(); - var uri = config["ProductConstructionService:Uri"]; - - var noAuth = config.GetValue("ProductConstructionService:NoAuth"); - if (noAuth) - { - return PcsApiFactory.GetAnonymous(uri); - } - - return PcsApiFactory.GetAuthenticated(uri, managedIdentityId: "system", disableInteractiveAuth: true); - }); services.AddMergePolicies(); services.AddKustoClientProvider("Kusto"); diff --git a/src/Maestro/SubscriptionActorService/SubscriptionActorService.csproj b/src/Maestro/SubscriptionActorService/SubscriptionActorService.csproj index 056ba22679..04776d2698 100644 --- a/src/Maestro/SubscriptionActorService/SubscriptionActorService.csproj +++ b/src/Maestro/SubscriptionActorService/SubscriptionActorService.csproj @@ -34,7 +34,6 @@ - diff --git a/src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/InitializeOperation.cs b/src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/InitializeOperation.cs index c7270eef92..9e5eda98ed 100644 --- a/src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/InitializeOperation.cs +++ b/src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/InitializeOperation.cs @@ -40,7 +40,6 @@ await _vmrInitializer.InitializeRepository( _options.Recursive, new NativePath(_options.SourceMappings), additionalRemotes, - _options.ComponentTemplate, _options.TpnTemplate, _options.GenerateCodeowners, _options.GenerateCredScanSuppressions, diff --git a/src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/UpdateOperation.cs b/src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/UpdateOperation.cs index 51fc00c279..d9cb14013b 100644 --- a/src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/UpdateOperation.cs +++ b/src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/UpdateOperation.cs @@ -40,7 +40,6 @@ await _vmrUpdater.UpdateRepository( barId: null, _options.Recursive, additionalRemotes, - _options.ComponentTemplate, _options.TpnTemplate, _options.GenerateCodeowners, _options.GenerateCredScanSuppressions, diff --git a/src/Microsoft.DotNet.Darc/Darc/Options/VirtualMonoRepo/VmrSyncCommandLineOptions.cs b/src/Microsoft.DotNet.Darc/Darc/Options/VirtualMonoRepo/VmrSyncCommandLineOptions.cs index 873ec08d45..b508e1222f 100644 --- a/src/Microsoft.DotNet.Darc/Darc/Options/VirtualMonoRepo/VmrSyncCommandLineOptions.cs +++ b/src/Microsoft.DotNet.Darc/Darc/Options/VirtualMonoRepo/VmrSyncCommandLineOptions.cs @@ -20,9 +20,6 @@ internal abstract class VmrSyncCommandLineOptions : VmrCommandLineOptions, "Omitting REVISION will synchronize the repo to current HEAD.")] public IEnumerable Repositories { get; set; } - [Option("component-template", Required = false, HelpText = "Path to a template for generating VMRs Component.md file. Leave empty to skip generation.")] - public string ComponentTemplate { get; set; } - [Option("tpn-template", Required = false, HelpText = "Path to a template for generating VMRs THIRD-PARTY-NOTICES file. Leave empty to skip generation.")] public string TpnTemplate { get; set; } diff --git a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/ComponentListGenerator.cs b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/ComponentListGenerator.cs deleted file mode 100644 index d5178dbe90..0000000000 --- a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/ComponentListGenerator.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.DotNet.DarcLib.Helpers; -using Microsoft.DotNet.DarcLib.Models.VirtualMonoRepo; - -#nullable enable -namespace Microsoft.DotNet.DarcLib.VirtualMonoRepo; - -public interface IComponentListGenerator -{ - Task UpdateComponentList(string templatePath); -} - -/// -/// Class responsible for generating the dynamic list of components in Components.md. -/// -public class ComponentListGenerator : IComponentListGenerator -{ - private const string ComponentListStartTag = ""; - private const string ComponentListEndTag = ""; - - private readonly ISourceManifest _sourceManifest; - private readonly IVmrInfo _vmrInfo; - private readonly IFileSystem _fileSystem; - - public ComponentListGenerator( - ISourceManifest sourceManifest, - IVmrInfo vmrInfo, - IFileSystem fileSystem) - { - _sourceManifest = sourceManifest; - _vmrInfo = vmrInfo; - _fileSystem = fileSystem; - } - - public async Task UpdateComponentList(string templatePath) - { - if (!_fileSystem.FileExists(templatePath)) - { - return; - } - - var componentListPath = _vmrInfo.VmrPath / VmrInfo.ComponentListPath; - - using var readStream = _fileSystem.GetFileStream(templatePath, FileMode.Open, FileAccess.Read); - using var writeStream = _fileSystem.GetFileStream(componentListPath, FileMode.Create, FileAccess.Write); - using var reader = new StreamReader(readStream); - using var writer = new StreamWriter(writeStream, Encoding.UTF8); - - string? line; - while ((line = await reader.ReadLineAsync()) != null) - { - await writer.WriteLineAsync(line); - - if (line.Contains(ComponentListStartTag)) - { - await WriteComponentList(writer); - - while (!line.Contains(ComponentListEndTag)) - { - line = reader.ReadLine(); - - if (line == null) - { - throw new Exception($"Component list end tag not found in {templatePath}"); - } - } - - await writer.WriteLineAsync(line); - } - } - } - - private async Task WriteComponentList(StreamWriter writer) - { - var submodules = _sourceManifest.Submodules.OrderBy(s => s.Path).ToList(); - - foreach (ISourceComponent component in _sourceManifest.Repositories.OrderBy(m => m.Path)) - { - await WriteComponentListItem(writer, component, 0); - - foreach (var submodule in submodules.Where(s => s.Path.StartsWith($"{component.Path}/"))) - { - await WriteComponentListItem(writer, submodule, 4); - } - } - } - - private static async Task WriteComponentListItem(StreamWriter writer, ISourceComponent component, int indentation) - { - // TODO (https://github.com/dotnet/arcade/issues/10549): Add also non-GitHub implementations - string[] uriParts = component.RemoteUri.Split('/', StringSplitOptions.RemoveEmptyEntries); - string repo = $"{uriParts[^2]}/{uriParts[^1]}"; - if (repo.EndsWith(".git")) - { - repo = repo[..^4]; - } - - await writer.WriteLineAsync($"{new string(' ', indentation)}- `{VmrInfo.RelativeSourcesDir / component.Path}` "); - await writer.WriteLineAsync($"{new string(' ', indentation)}*[{repo}@{Commit.GetShortSha(component.CommitSha)}]({component.GetPublicUrl()})*"); - } -} diff --git a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/IVmrInitializer.cs b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/IVmrInitializer.cs index 3ca3f35398..37609e12e9 100644 --- a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/IVmrInitializer.cs +++ b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/IVmrInitializer.cs @@ -20,7 +20,6 @@ public interface IVmrInitializer /// When true, initializes dependencies (from Version.Details.xml) recursively /// Path to the source-mappings.json file /// Additional git remotes to use when fetching - /// Path to VMR's README.md template /// Path to VMR's THIRD-PARTY-NOTICES.md template /// Whether to generate a CODEOWNERS file /// Whether to generate a .config/CredScanSuppressions.json file @@ -33,7 +32,6 @@ Task InitializeRepository( bool initializeDependencies, LocalPath sourceMappingsPath, IReadOnlyCollection additionalRemotes, - string? componentTemplatePath, string? tpnTemplatePath, bool generateCodeowners, bool generateCredScanSuppressions, diff --git a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/IVmrUpdater.cs b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/IVmrUpdater.cs index a6f1124602..511e28f4b2 100644 --- a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/IVmrUpdater.cs +++ b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/IVmrUpdater.cs @@ -20,7 +20,6 @@ public interface IVmrUpdater /// Bar id of the build that's being flown, if applicable /// When true, updates dependencies (from Version.Details.xml) recursively /// Additional git remotes to use when fetching - /// Path to VMR's Component.md template /// Path to VMR's THIRD-PARTY-NOTICES.md template /// Whether to generate a CODEOWNERS file /// Whether to generate a .config/CredScanSuppressions.json file @@ -36,7 +35,6 @@ Task UpdateRepository( int? barId, bool updateDependencies, IReadOnlyCollection additionalRemotes, - string? componentTemplatePath, string? tpnTemplatePath, bool generateCodeowners, bool generateCredScanSuppressions, diff --git a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrForwardFlower.cs b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrForwardFlower.cs index bf05d815e2..fa593449d8 100644 --- a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrForwardFlower.cs +++ b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrForwardFlower.cs @@ -247,7 +247,6 @@ protected override async Task SameDirectionFlowAsync( build.Id, updateDependencies: false, additionalRemotes: additionalRemotes, - componentTemplatePath: null, tpnTemplatePath: _vmrInfo.VmrPath / VmrInfo.ThirdPartyNoticesTemplatePath, generateCodeowners: false, generateCredScanSuppressions: true, @@ -303,7 +302,6 @@ await FlowCodeAsync( build.Id, updateDependencies: false, additionalRemotes, - componentTemplatePath: null, tpnTemplatePath: _vmrInfo.VmrPath / VmrInfo.ThirdPartyNoticesTemplatePath, generateCodeowners: false, generateCredScanSuppressions: false, @@ -379,7 +377,6 @@ .. submodules.Select(s => s.Path).Distinct().Select(VmrPatchHandler.GetExclusion build.Id, updateDependencies: false, additionalRemote, - componentTemplatePath: null, tpnTemplatePath: _vmrInfo.VmrPath / VmrInfo.ThirdPartyNoticesTemplatePath, generateCodeowners: false, generateCredScanSuppressions: true, diff --git a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrInfo.cs b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrInfo.cs index f2d7d9b616..73533b4cc7 100644 --- a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrInfo.cs +++ b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrInfo.cs @@ -76,10 +76,8 @@ public class VmrInfo : IVmrInfo public const string IgnoreAttribute = "vmr-ignore"; // TODO (https://github.com/dotnet/arcade-services/issues/4186): Read these from source-mappings.json - public const string ComponentTemplatePath = "src/sdk/src/VirtualMonoRepo/Component.template.md"; public const string ThirdPartyNoticesTemplatePath = "src/sdk/src/VirtualMonoRepo/THIRD-PARTY-NOTICES.template.txt"; - public const string ComponentListPath = "Components.md"; public const string ThirdPartyNoticesFileName = "THIRD-PARTY-NOTICES.txt"; public const string CodeownersFileName = "CODEOWNERS"; public const string CredScanSuppressionsFileName = "CredScanSuppressions.json"; diff --git a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrInitializer.cs b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrInitializer.cs index 523544ea6a..9782e7d50f 100644 --- a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrInitializer.cs +++ b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrInitializer.cs @@ -53,7 +53,6 @@ public VmrInitializer( IVersionDetailsParser versionDetailsParser, IRepositoryCloneManager cloneManager, IThirdPartyNoticesGenerator thirdPartyNoticesGenerator, - IComponentListGenerator readmeComponentListGenerator, ICodeownersGenerator codeownersGenerator, ICredScanSuppressionsGenerator credScanSuppressionsGenerator, ILocalGitClient localGitClient, @@ -65,7 +64,7 @@ public VmrInitializer( ILogger logger, ISourceManifest sourceManifest, IVmrInfo vmrInfo) - : base(vmrInfo, sourceManifest, dependencyTracker, patchHandler, versionDetailsParser, thirdPartyNoticesGenerator, readmeComponentListGenerator, codeownersGenerator, credScanSuppressionsGenerator, localGitClient, localGitRepoFactory, dependencyFileManager, barClient, fileSystem, logger) + : base(vmrInfo, sourceManifest, dependencyTracker, patchHandler, versionDetailsParser, thirdPartyNoticesGenerator, codeownersGenerator, credScanSuppressionsGenerator, localGitClient, localGitRepoFactory, dependencyFileManager, barClient, fileSystem, logger) { _vmrInfo = vmrInfo; _barClient = barClient; @@ -84,7 +83,6 @@ public async Task InitializeRepository( bool initializeDependencies, LocalPath sourceMappingsPath, IReadOnlyCollection additionalRemotes, - string? componentTemplatePath, string? tpnTemplatePath, bool generateCodeowners, bool generateCredScanSuppressions, @@ -154,7 +152,6 @@ public async Task InitializeRepository( await InitializeRepository( update, additionalRemotes, - componentTemplatePath, tpnTemplatePath, generateCodeowners, generateCredScanSuppressions, @@ -184,7 +181,6 @@ await InitializeRepository( private async Task InitializeRepository( VmrDependencyUpdate update, IReadOnlyCollection additionalRemotes, - string? componentTemplatePath, string? tpnTemplatePath, bool generateCodeowners, bool generateCredScanSuppressions, @@ -223,7 +219,6 @@ await UpdateRepoToRevisionAsync( author: null, commitMessage, restoreVmrPatches: false, - componentTemplatePath, tpnTemplatePath, generateCodeowners, generateCredScanSuppressions, diff --git a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrManagerBase.cs b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrManagerBase.cs index b5f076bad9..7f2cf49a23 100644 --- a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrManagerBase.cs +++ b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrManagerBase.cs @@ -29,7 +29,6 @@ public abstract class VmrManagerBase private readonly IVmrPatchHandler _patchHandler; private readonly IVersionDetailsParser _versionDetailsParser; private readonly IThirdPartyNoticesGenerator _thirdPartyNoticesGenerator; - private readonly IComponentListGenerator _componentListGenerator; private readonly ICodeownersGenerator _codeownersGenerator; private readonly ICredScanSuppressionsGenerator _credScanSuppressionsGenerator; private readonly ILocalGitClient _localGitClient; @@ -48,7 +47,6 @@ protected VmrManagerBase( IVmrPatchHandler vmrPatchHandler, IVersionDetailsParser versionDetailsParser, IThirdPartyNoticesGenerator thirdPartyNoticesGenerator, - IComponentListGenerator componentListGenerator, ICodeownersGenerator codeownersGenerator, ICredScanSuppressionsGenerator credScanSuppressionsGenerator, ILocalGitClient localGitClient, @@ -65,7 +63,6 @@ protected VmrManagerBase( _patchHandler = vmrPatchHandler; _versionDetailsParser = versionDetailsParser; _thirdPartyNoticesGenerator = thirdPartyNoticesGenerator; - _componentListGenerator = componentListGenerator; _codeownersGenerator = codeownersGenerator; _credScanSuppressionsGenerator = credScanSuppressionsGenerator; _localGitClient = localGitClient; @@ -83,7 +80,6 @@ public async Task> UpdateRepoToRevisionAs (string Name, string Email)? author, string commitMessage, bool restoreVmrPatches, - string? componentTemplatePath, string? tpnTemplatePath, bool generateCodeowners, bool generateCredScanSuppressions, @@ -115,22 +111,12 @@ public async Task> UpdateRepoToRevisionAs _dependencyInfo.UpdateDependencyVersion(update); - if (componentTemplatePath != null) - { - await _componentListGenerator.UpdateComponentList(componentTemplatePath); - } - var filesToAdd = new List { VmrInfo.GitInfoSourcesDir, _vmrInfo.SourceManifestPath }; - if (_fileSystem.FileExists(_vmrInfo.VmrPath / VmrInfo.ComponentListPath)) - { - filesToAdd.Add(VmrInfo.ComponentListPath); - } - await _localGitClient.StageAsync(_vmrInfo.VmrPath, filesToAdd, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); diff --git a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrRegistrations.cs b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrRegistrations.cs index f35387bebc..ec6f4aeecd 100644 --- a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrRegistrations.cs +++ b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrRegistrations.cs @@ -97,7 +97,6 @@ private static IServiceCollection AddVmrManagers( services.TryAddTransient(); services.TryAddTransient(); services.TryAddTransient(); - services.TryAddTransient(); services.TryAddTransient(); services.TryAddTransient(); services.TryAddTransient(); diff --git a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrUpdater.cs b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrUpdater.cs index 57a2479b52..b38a23dcab 100644 --- a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrUpdater.cs +++ b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrUpdater.cs @@ -55,7 +55,6 @@ [Recursive sync] {name} / {oldShaShort}{{Constants.Arrow}}{newShaShort} private readonly ILogger _logger; private readonly ISourceManifest _sourceManifest; private readonly IThirdPartyNoticesGenerator _thirdPartyNoticesGenerator; - private readonly IComponentListGenerator _readmeComponentListGenerator; private readonly ILocalGitClient _localGitClient; private readonly IGitRepoFactory _gitRepoFactory; private readonly IWorkBranchFactory _workBranchFactory; @@ -66,7 +65,6 @@ public VmrUpdater( IRepositoryCloneManager cloneManager, IVmrPatchHandler patchHandler, IThirdPartyNoticesGenerator thirdPartyNoticesGenerator, - IComponentListGenerator readmeComponentListGenerator, ICodeownersGenerator codeownersGenerator, ICredScanSuppressionsGenerator credScanSuppressionsGenerator, ILocalGitClient localGitClient, @@ -79,7 +77,7 @@ public VmrUpdater( ILogger logger, ISourceManifest sourceManifest, IVmrInfo vmrInfo) - : base(vmrInfo, sourceManifest, dependencyTracker, patchHandler, versionDetailsParser, thirdPartyNoticesGenerator, readmeComponentListGenerator, codeownersGenerator, credScanSuppressionsGenerator, localGitClient, localGitRepoFactory, dependencyFileManager, barClient, fileSystem, logger) + : base(vmrInfo, sourceManifest, dependencyTracker, patchHandler, versionDetailsParser, thirdPartyNoticesGenerator, codeownersGenerator, credScanSuppressionsGenerator, localGitClient, localGitRepoFactory, dependencyFileManager, barClient, fileSystem, logger) { _logger = logger; _sourceManifest = sourceManifest; @@ -90,7 +88,6 @@ public VmrUpdater( _fileSystem = fileSystem; _barClient = barClient; _thirdPartyNoticesGenerator = thirdPartyNoticesGenerator; - _readmeComponentListGenerator = readmeComponentListGenerator; _localGitClient = localGitClient; _gitRepoFactory = gitRepoFactory; _workBranchFactory = workBranchFactory; @@ -104,7 +101,6 @@ public async Task UpdateRepository( int? barId, bool updateDependencies, IReadOnlyCollection additionalRemotes, - string? componentTemplatePath, string? tpnTemplatePath, bool generateCodeowners, bool generateCredScanSuppressions, @@ -149,7 +145,6 @@ public async Task UpdateRepository( return await UpdateRepositoryRecursively( dependencyUpdate, additionalRemotes, - componentTemplatePath, tpnTemplatePath, generateCodeowners, generateCredScanSuppressions, @@ -165,7 +160,6 @@ public async Task UpdateRepository( dependencyUpdate, restoreVmrPatches: true, additionalRemotes, - componentTemplatePath, tpnTemplatePath, generateCodeowners, generateCredScanSuppressions, @@ -191,7 +185,6 @@ private async Task> UpdateRepositoryInter VmrDependencyUpdate update, bool restoreVmrPatches, IReadOnlyCollection additionalRemotes, - string? componentTemplatePath, string? tpnTemplatePath, bool generateCodeowners, bool generateCredScanSuppressions, @@ -273,7 +266,6 @@ await UpdateTargetVersionOnly( author: null, commitMessage, restoreVmrPatches, - componentTemplatePath, tpnTemplatePath, generateCodeowners, generateCredScanSuppressions, @@ -288,7 +280,6 @@ await UpdateTargetVersionOnly( private async Task UpdateRepositoryRecursively( VmrDependencyUpdate rootUpdate, IReadOnlyCollection additionalRemotes, - string? componentTemplatePath, string? tpnTemplatePath, bool generateCodeowners, bool generateCredScanSuppressions, @@ -374,7 +365,6 @@ private async Task UpdateRepositoryRecursively( update, restoreVmrPatches: update.Parent == null, additionalRemotes, - componentTemplatePath, tpnTemplatePath, generateCodeowners, generateCredScanSuppressions, @@ -440,7 +430,7 @@ private async Task UpdateRepositoryRecursively( await ApplyVmrPatches(workBranch, vmrPatchesToReapply, cancellationToken); - await CleanUpRemovedRepos(componentTemplatePath, tpnTemplatePath); + await CleanUpRemovedRepos(tpnTemplatePath); var commitMessage = PrepareCommitMessage( MergeCommitMessage, @@ -618,7 +608,7 @@ private string GetCurrentVersion(SourceMapping mapping) return version.Sha; } - private async Task CleanUpRemovedRepos(string? componentTemplatePath, string? tpnTemplatePath) + private async Task CleanUpRemovedRepos(string? tpnTemplatePath) { var deletedRepos = _sourceManifest .Repositories @@ -639,11 +629,6 @@ private async Task CleanUpRemovedRepos(string? componentTemplatePath, string? tp var sourceManifestPath = _vmrInfo.SourceManifestPath; _fileSystem.WriteToFile(sourceManifestPath, _sourceManifest.ToJson()); - if (componentTemplatePath != null) - { - await _readmeComponentListGenerator.UpdateComponentList(componentTemplatePath); - } - if (tpnTemplatePath != null) { await _thirdPartyNoticesGenerator.UpdateThirdPartyNotices(tpnTemplatePath); diff --git a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/WorkBranch.cs b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/WorkBranch.cs index 5c27851656..fdbe18bce2 100644 --- a/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/WorkBranch.cs +++ b/src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/WorkBranch.cs @@ -34,7 +34,7 @@ public async Task MergeBackAsync(string commitMessage) await _repo.CheckoutAsync(OriginalBranch); var result = await _repo.ExecuteGitCommand( - [ "merge", _workBranch, "--no-commit", "--no-ff", "--no-edit", "--no-squash", "-q" ]); + [ "merge", _workBranch, "--no-commit", "--no-edit", "--squash", "-q" ]); result.ThrowIfFailed($"Failed to merge work branch {_workBranch} into {OriginalBranch}"); diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Assets.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Assets.cs similarity index 97% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Assets.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Assets.cs index 27b2e13252..98206df931 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Assets.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Assets.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.IO; using System.Text; using System.Threading; @@ -13,12 +12,12 @@ -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface IAssets { Task BulkAddLocationsAsync( - IImmutableList body, + List body, CancellationToken cancellationToken = default ); @@ -80,12 +79,12 @@ public Assets(ProductConstructionServiceApi client) partial void HandleFailedBulkAddLocationsRequest(RestApiException ex); public async Task BulkAddLocationsAsync( - IImmutableList body, + List body, CancellationToken cancellationToken = default ) { - if (body == default(IImmutableList)) + if (body == default(List)) { throw new ArgumentNullException(nameof(body)); } @@ -107,7 +106,7 @@ public async Task BulkAddLocationsAsync( _req.Uri = _url; _req.Method = RequestMethod.Post; - if (body != default(IImmutableList)) + if (body != default(List)) { _req.Content = RequestContent.Create(Encoding.UTF8.GetBytes(Client.Serialize(body))); _req.Headers.Add("Content-Type", "application/json; charset=utf-8"); @@ -274,7 +273,7 @@ internal async Task OnBulkAddLocationsFailed(Request req, Response res) using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return Page.FromValues(_body, (page + 1).ToString(), _res); } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/AzDo.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/AzDo.cs similarity index 98% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/AzDo.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/AzDo.cs index 2aef62c493..a711151334 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/AzDo.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/AzDo.cs @@ -11,7 +11,7 @@ -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface IAzDo { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/BuildTime.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/BuildTime.cs similarity index 98% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/BuildTime.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/BuildTime.cs index fc8c050538..228b010cf9 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/BuildTime.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/BuildTime.cs @@ -10,7 +10,7 @@ -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface IBuildTime { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Builds.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Builds.cs similarity index 99% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Builds.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Builds.cs index 3718298afd..a8b6947944 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Builds.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Builds.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.IO; using System.Text; using System.Threading; @@ -13,7 +12,7 @@ -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface IBuilds { @@ -257,7 +256,7 @@ public Builds(ProductConstructionServiceApi client) using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return Page.FromValues(_body, (page + 1).ToString(), _res); } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Channels.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Channels.cs similarity index 96% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Channels.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Channels.cs index bc36f30ac0..d01f385bc4 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Channels.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Channels.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Immutable; +using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -11,11 +11,11 @@ -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface IChannels { - Task> ListChannelsAsync( + Task> ListChannelsAsync( string classification = default, CancellationToken cancellationToken = default ); @@ -26,7 +26,7 @@ public partial interface IChannels CancellationToken cancellationToken = default ); - Task> ListRepositoriesAsync( + Task> ListRepositoriesAsync( int id, int? withBuildsInDays = default, CancellationToken cancellationToken = default @@ -60,7 +60,7 @@ Task RemoveBuildFromChannelAsync( bool includeArcade, bool includeBuildTimes, bool includeDisabledSubscriptions, - IImmutableList includedFrequencies = default, + List includedFrequencies = default, CancellationToken cancellationToken = default ); @@ -79,7 +79,7 @@ public Channels(ProductConstructionServiceApi client) partial void HandleFailedListChannelsRequest(RestApiException ex); - public async Task> ListChannelsAsync( + public async Task> ListChannelsAsync( string classification = default, CancellationToken cancellationToken = default ) @@ -121,7 +121,7 @@ public Channels(ProductConstructionServiceApi client) using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return _body; } } @@ -242,7 +242,7 @@ internal async Task OnCreateChannelFailed(Request req, Response res) partial void HandleFailedListRepositoriesRequest(RestApiException ex); - public async Task> ListRepositoriesAsync( + public async Task> ListRepositoriesAsync( int id, int? withBuildsInDays = default, CancellationToken cancellationToken = default @@ -285,7 +285,7 @@ public async Task> ListRepositoriesAsync( using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return _body; } } @@ -587,7 +587,7 @@ internal async Task OnRemoveBuildFromChannelFailed(Request req, Response res) bool includeArcade, bool includeBuildTimes, bool includeDisabledSubscriptions, - IImmutableList includedFrequencies = default, + List includedFrequencies = default, CancellationToken cancellationToken = default ) { @@ -605,7 +605,7 @@ internal async Task OnRemoveBuildFromChannelFailed(Request req, Response res) { _url.AppendQuery("includeDisabledSubscriptions", Client.Serialize(includeDisabledSubscriptions)); } - if (includedFrequencies != default(IImmutableList)) + if (includedFrequencies != default(List)) { foreach (var _item in includedFrequencies) { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/DefaultChannels.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/DefaultChannels.cs similarity index 97% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/DefaultChannels.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/DefaultChannels.cs index 82fd112125..5dd08ffd96 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/DefaultChannels.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/DefaultChannels.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Immutable; +using System.Collections.Generic; using System.IO; using System.Text; using System.Threading; @@ -12,11 +12,11 @@ -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface IDefaultChannels { - Task> ListAsync( + Task> ListAsync( string branch = default, bool? enabled = default, int? channelId = default, @@ -60,7 +60,7 @@ public DefaultChannels(ProductConstructionServiceApi client) partial void HandleFailedListRequest(RestApiException ex); - public async Task> ListAsync( + public async Task> ListAsync( string branch = default, bool? enabled = default, int? channelId = default, @@ -117,7 +117,7 @@ public DefaultChannels(ProductConstructionServiceApi client) using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return _body; } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Goal.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Goal.cs similarity index 99% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Goal.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Goal.cs index 979aa69c86..369f71ff0b 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Goal.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Goal.cs @@ -11,7 +11,7 @@ -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface IGoal { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/ApiError.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/ApiError.cs similarity index 71% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/ApiError.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/ApiError.cs index 9a256a509e..cd3ef97861 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/ApiError.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/ApiError.cs @@ -1,10 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class ApiError { @@ -16,6 +16,6 @@ public ApiError() public string Message { get; set; } [JsonProperty("errors")] - public IImmutableList Errors { get; set; } + public List Errors { get; set; } } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Asset.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Asset.cs similarity index 79% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Asset.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Asset.cs index 6eb5b33346..4a7e04e681 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Asset.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Asset.cs @@ -1,14 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class Asset { - public Asset(int id, int buildId, bool nonShipping, string name, string version, IImmutableList locations) + public Asset(int id, int buildId, bool nonShipping, string name, string version, List locations) { Id = id; BuildId = buildId; @@ -34,6 +34,6 @@ public Asset(int id, int buildId, bool nonShipping, string name, string version, public bool NonShipping { get; set; } [JsonProperty("locations")] - public IImmutableList Locations { get; } + public List Locations { get; } } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetAndLocation.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetAndLocation.cs similarity index 79% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetAndLocation.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetAndLocation.cs index 01bada8070..b0439352a7 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetAndLocation.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetAndLocation.cs @@ -3,11 +3,11 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class AssetAndLocation { - public AssetAndLocation(int assetId, Models.LocationType locationType) + public AssetAndLocation(int assetId, LocationType locationType) { AssetId = assetId; LocationType = locationType; @@ -20,7 +20,7 @@ public AssetAndLocation(int assetId, Models.LocationType locationType) public string Location { get; set; } [JsonProperty("locationType")] - public Models.LocationType LocationType { get; set; } + public LocationType LocationType { get; set; } [JsonIgnore] public bool IsValid diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetData.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetData.cs similarity index 77% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetData.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetData.cs index e13b61a5c1..bd8af74f2e 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetData.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetData.cs @@ -1,10 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class AssetData { @@ -23,6 +23,6 @@ public AssetData(bool nonShipping) public bool NonShipping { get; set; } [JsonProperty("locations")] - public IImmutableList Locations { get; set; } + public List Locations { get; set; } } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetLocation.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetLocation.cs similarity index 79% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetLocation.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetLocation.cs index 4a55f8bf39..3eafc94434 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetLocation.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetLocation.cs @@ -3,11 +3,11 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class AssetLocation { - public AssetLocation(int id, Models.LocationType type, string location) + public AssetLocation(int id, LocationType type, string location) { Id = id; Type = type; @@ -21,7 +21,7 @@ public AssetLocation(int id, Models.LocationType type, string location) public string Location { get; } [JsonProperty("type")] - public Models.LocationType Type { get; set; } + public LocationType Type { get; set; } [JsonIgnore] public bool IsValid diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetLocationData.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetLocationData.cs similarity index 79% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetLocationData.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetLocationData.cs index 82de28675c..5a9cd6ef49 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AssetLocationData.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AssetLocationData.cs @@ -3,11 +3,11 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class AssetLocationData { - public AssetLocationData(Models.LocationType type) + public AssetLocationData(LocationType type) { Type = type; } @@ -16,7 +16,7 @@ public AssetLocationData(Models.LocationType type) public string Location { get; set; } [JsonProperty("type")] - public Models.LocationType Type { get; set; } + public LocationType Type { get; set; } [JsonIgnore] public bool IsValid diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AzDoBuild.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AzDoBuild.cs similarity index 93% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AzDoBuild.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AzDoBuild.cs index ee0020306b..419e5c0560 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/AzDoBuild.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/AzDoBuild.cs @@ -4,7 +4,7 @@ using System; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class AzDoBuild { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Build.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Build.cs similarity index 78% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Build.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Build.cs index 2fc6b6697a..b21d84536d 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Build.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Build.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class Build { - public Build(int id, DateTimeOffset dateProduced, int staleness, bool released, bool stable, string commit, IImmutableList channels, IImmutableList assets, IImmutableList dependencies, IImmutableList incoherencies) + public Build(int id, DateTimeOffset dateProduced, int staleness, bool released, bool stable, string commit, List channels, List assets, List dependencies, List incoherencies) { Id = id; DateProduced = dateProduced; @@ -60,16 +60,16 @@ public Build(int id, DateTimeOffset dateProduced, int staleness, bool released, public DateTimeOffset DateProduced { get; } [JsonProperty("channels")] - public IImmutableList Channels { get; } + public List Channels { get; } [JsonProperty("assets")] - public IImmutableList Assets { get; } + public List Assets { get; } [JsonProperty("dependencies")] - public IImmutableList Dependencies { get; } + public List Dependencies { get; } [JsonProperty("incoherencies")] - public IImmutableList Incoherencies { get; } + public List Incoherencies { get; } [JsonProperty("staleness")] public int Staleness { get; } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildData.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildData.cs similarity index 90% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildData.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildData.cs index 05cb82bebe..51b29a47c9 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildData.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildData.cs @@ -1,10 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class BuildData { @@ -24,10 +24,10 @@ public BuildData(string commit, string azureDevOpsAccount, string azureDevOpsPro public string Commit { get; set; } [JsonProperty("assets")] - public IImmutableList Assets { get; set; } + public List Assets { get; set; } [JsonProperty("dependencies")] - public IImmutableList Dependencies { get; set; } + public List Dependencies { get; set; } [JsonProperty("azureDevOpsBuildId")] public int? AzureDevOpsBuildId { get; set; } @@ -63,7 +63,7 @@ public BuildData(string commit, string azureDevOpsAccount, string azureDevOpsPro public bool Stable { get; set; } [JsonProperty("incoherencies")] - public IImmutableList Incoherencies { get; set; } + public List Incoherencies { get; set; } [JsonIgnore] public bool IsValid diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildGraph.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildGraph.cs similarity index 61% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildGraph.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildGraph.cs index 8712dbad89..f4ff58e2e9 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildGraph.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildGraph.cs @@ -1,27 +1,27 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class BuildGraph { - public BuildGraph(IImmutableDictionary builds) + public BuildGraph(Dictionary builds) { Builds = builds; } [JsonProperty("builds")] - public IImmutableDictionary Builds { get; set; } + public Dictionary Builds { get; set; } [JsonIgnore] public bool IsValid { get { - if (Builds == default(IImmutableDictionary)) + if (Builds == default(Dictionary)) { return false; } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildIncoherence.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildIncoherence.cs similarity index 89% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildIncoherence.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildIncoherence.cs index 8c6ffd295f..a1e90c818c 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildIncoherence.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildIncoherence.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class BuildIncoherence { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildRef.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildRef.cs similarity index 91% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildRef.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildRef.cs index 6cfe51e033..8aa33faf58 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildRef.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildRef.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class BuildRef { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildTime.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildTime.cs similarity index 90% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildTime.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildTime.cs index d4e3392b78..bed339e8d9 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildTime.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildTime.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class BuildTime { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildUpdate.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildUpdate.cs similarity index 83% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildUpdate.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildUpdate.cs index c2a1c0de09..98d5a42924 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/BuildUpdate.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/BuildUpdate.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class BuildUpdate { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Channel.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Channel.cs similarity index 93% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Channel.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Channel.cs index 6fa5433d62..134dfab719 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Channel.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Channel.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class Channel { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Commit.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Commit.cs similarity index 87% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Commit.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Commit.cs index b3ee81690d..fb0e2ed70c 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Commit.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Commit.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class Commit { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/DefaultChannel.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/DefaultChannel.cs similarity index 89% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/DefaultChannel.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/DefaultChannel.cs index 6e76b117f8..c5ccf58af6 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/DefaultChannel.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/DefaultChannel.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class DefaultChannel { @@ -24,7 +24,7 @@ public DefaultChannel(int id, string repository, bool enabled) public string Branch { get; set; } [JsonProperty("channel")] - public Models.Channel Channel { get; set; } + public Channel Channel { get; set; } [JsonProperty("enabled")] public bool Enabled { get; set; } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/DefaultChannelCreateData.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/DefaultChannelCreateData.cs similarity index 94% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/DefaultChannelCreateData.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/DefaultChannelCreateData.cs index f0c5393703..d17a44c858 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/DefaultChannelCreateData.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/DefaultChannelCreateData.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class DefaultChannelCreateData { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/DefaultChannelUpdateData.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/DefaultChannelUpdateData.cs similarity index 89% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/DefaultChannelUpdateData.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/DefaultChannelUpdateData.cs index 0bf9ddee74..9dfe401ae2 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/DefaultChannelUpdateData.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/DefaultChannelUpdateData.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class DefaultChannelUpdateData { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/FlowEdge.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/FlowEdge.cs similarity index 94% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/FlowEdge.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/FlowEdge.cs index beaac8a9eb..8b4f4cf203 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/FlowEdge.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/FlowEdge.cs @@ -4,7 +4,7 @@ using System; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class FlowEdge { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/FlowGraph.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/FlowGraph.cs similarity index 57% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/FlowGraph.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/FlowGraph.cs index ead3669fba..6bb0984b38 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/FlowGraph.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/FlowGraph.cs @@ -1,35 +1,35 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class FlowGraph { - public FlowGraph(IImmutableList flowRefs, IImmutableList flowEdges) + public FlowGraph(List flowRefs, List flowEdges) { FlowRefs = flowRefs; FlowEdges = flowEdges; } [JsonProperty("flowRefs")] - public IImmutableList FlowRefs { get; set; } + public List FlowRefs { get; set; } [JsonProperty("flowEdges")] - public IImmutableList FlowEdges { get; set; } + public List FlowEdges { get; set; } [JsonIgnore] public bool IsValid { get { - if (FlowRefs == default(IImmutableList)) + if (FlowRefs == default(List)) { return false; } - if (FlowEdges == default(IImmutableList)) + if (FlowEdges == default(List)) { return false; } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/FlowRef.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/FlowRef.cs similarity index 87% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/FlowRef.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/FlowRef.cs index af9e904b14..cc2bc2d902 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/FlowRef.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/FlowRef.cs @@ -1,10 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class FlowRef { @@ -46,9 +46,9 @@ public FlowRef(double officialBuildTime, double prBuildTime, bool onLongestBuild public int GoalTimeInMinutes { get; set; } [JsonProperty("inputChannels")] - public IImmutableList InputChannels { get; set; } + public List InputChannels { get; set; } [JsonProperty("outputChannels")] - public IImmutableList OutputChannels { get; set; } + public List OutputChannels { get; set; } } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Goal.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Goal.cs similarity index 82% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Goal.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Goal.cs index f65fbf98ee..a66a8a397a 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Goal.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Goal.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class Goal { @@ -17,7 +17,7 @@ public Goal(int definitionId, int minutes) public int DefinitionId { get; set; } [JsonProperty("channel")] - public Models.Channel Channel { get; set; } + public Channel Channel { get; set; } [JsonProperty("minutes")] public int Minutes { get; set; } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/GoalRequestJson.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/GoalRequestJson.cs similarity index 85% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/GoalRequestJson.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/GoalRequestJson.cs index 9528c6d0e1..e2d3c5adf8 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/GoalRequestJson.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/GoalRequestJson.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class GoalRequestJson { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/LocationType.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/LocationType.cs similarity index 85% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/LocationType.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/LocationType.cs index 5e78800006..d58b2a12bc 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/LocationType.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/LocationType.cs @@ -3,7 +3,7 @@ using System.Runtime.Serialization; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public enum LocationType { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/MergePolicy.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/MergePolicy.cs similarity index 66% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/MergePolicy.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/MergePolicy.cs index a0b969fa86..c600d0e747 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/MergePolicy.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/MergePolicy.cs @@ -1,10 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class MergePolicy { @@ -16,6 +16,6 @@ public MergePolicy() public string Name { get; set; } [JsonProperty("properties")] - public IImmutableDictionary Properties { get; set; } + public Dictionary Properties { get; set; } } } diff --git a/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/PullRequestUpdate.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/PullRequestUpdate.cs new file mode 100644 index 0000000000..d1e6298ab2 --- /dev/null +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/PullRequestUpdate.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Newtonsoft.Json; + +namespace Microsoft.DotNet.ProductConstructionService.Client.Models +{ + public partial class PullRequestUpdate + { + public PullRequestUpdate() + { + } + + [JsonProperty("sourceRepository")] + public string SourceRepository { get; set; } + } +} diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/ReleasePipeline.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/ReleasePipeline.cs similarity index 91% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/ReleasePipeline.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/ReleasePipeline.cs index 329589cf44..40a76b1956 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/ReleasePipeline.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/ReleasePipeline.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class ReleasePipeline { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/RepositoryBranch.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/RepositoryBranch.cs similarity index 74% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/RepositoryBranch.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/RepositoryBranch.cs index 5722c153cb..fbbd7059e3 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/RepositoryBranch.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/RepositoryBranch.cs @@ -1,10 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class RepositoryBranch { @@ -19,6 +19,6 @@ public RepositoryBranch() public string Branch { get; set; } [JsonProperty("mergePolicies")] - public IImmutableList MergePolicies { get; set; } + public List MergePolicies { get; set; } } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/RepositoryHistoryItem.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/RepositoryHistoryItem.cs similarity index 94% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/RepositoryHistoryItem.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/RepositoryHistoryItem.cs index 4ddabe36eb..47c1ddbb10 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/RepositoryHistoryItem.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/RepositoryHistoryItem.cs @@ -4,7 +4,7 @@ using System; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class RepositoryHistoryItem { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Subscription.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Subscription.cs similarity index 82% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Subscription.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Subscription.cs index c2ae2dde88..2685bcd8af 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/Subscription.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/Subscription.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class Subscription { - public Subscription(Guid id, bool enabled, bool sourceEnabled, string sourceRepository, string targetRepository, string targetBranch, string sourceDirectory, string targetDirectory, string pullRequestFailureNotificationTags, IImmutableList excludedAssets) + public Subscription(Guid id, bool enabled, bool sourceEnabled, string sourceRepository, string targetRepository, string targetBranch, string sourceDirectory, string targetDirectory, string pullRequestFailureNotificationTags, List excludedAssets) { Id = id; Enabled = enabled; @@ -27,7 +27,7 @@ public Subscription(Guid id, bool enabled, bool sourceEnabled, string sourceRepo public Guid Id { get; } [JsonProperty("channel")] - public Models.Channel Channel { get; set; } + public Channel Channel { get; set; } [JsonProperty("sourceRepository")] public string SourceRepository { get; } @@ -39,10 +39,10 @@ public Subscription(Guid id, bool enabled, bool sourceEnabled, string sourceRepo public string TargetBranch { get; } [JsonProperty("policy")] - public Models.SubscriptionPolicy Policy { get; set; } + public SubscriptionPolicy Policy { get; set; } [JsonProperty("lastAppliedBuild")] - public Models.Build LastAppliedBuild { get; set; } + public Build LastAppliedBuild { get; set; } [JsonProperty("enabled")] public bool Enabled { get; } @@ -60,6 +60,6 @@ public Subscription(Guid id, bool enabled, bool sourceEnabled, string sourceRepo public string PullRequestFailureNotificationTags { get; } [JsonProperty("excludedAssets")] - public IImmutableList ExcludedAssets { get; } + public List ExcludedAssets { get; } } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionData.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionData.cs similarity index 85% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionData.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionData.cs index b85b38ca2f..3979b33fc3 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionData.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionData.cs @@ -1,14 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class SubscriptionData { - public SubscriptionData(string channelName, string sourceRepository, string targetRepository, string targetBranch, Models.SubscriptionPolicy policy) + public SubscriptionData(string channelName, string sourceRepository, string targetRepository, string targetBranch, SubscriptionPolicy policy) { ChannelName = channelName; SourceRepository = sourceRepository; @@ -42,13 +42,13 @@ public SubscriptionData(string channelName, string sourceRepository, string targ public string TargetDirectory { get; set; } [JsonProperty("policy")] - public Models.SubscriptionPolicy Policy { get; set; } + public SubscriptionPolicy Policy { get; set; } [JsonProperty("pullRequestFailureNotificationTags")] public string PullRequestFailureNotificationTags { get; set; } [JsonProperty("excludedAssets")] - public IImmutableList ExcludedAssets { get; set; } + public List ExcludedAssets { get; set; } [JsonIgnore] public bool IsValid @@ -71,7 +71,7 @@ public bool IsValid { return false; } - if (Policy == default(Models.SubscriptionPolicy)) + if (Policy == default(SubscriptionPolicy)) { return false; } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionHistoryItem.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionHistoryItem.cs similarity index 94% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionHistoryItem.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionHistoryItem.cs index f82ffc8bce..8382af938e 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionHistoryItem.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionHistoryItem.cs @@ -4,7 +4,7 @@ using System; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class SubscriptionHistoryItem { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionPolicy.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionPolicy.cs similarity index 69% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionPolicy.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionPolicy.cs index 5961c46bb4..9005fb292d 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionPolicy.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionPolicy.cs @@ -1,14 +1,14 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class SubscriptionPolicy { - public SubscriptionPolicy(bool batchable, Models.UpdateFrequency updateFrequency) + public SubscriptionPolicy(bool batchable, UpdateFrequency updateFrequency) { Batchable = batchable; UpdateFrequency = updateFrequency; @@ -18,10 +18,10 @@ public SubscriptionPolicy(bool batchable, Models.UpdateFrequency updateFrequency public bool Batchable { get; set; } [JsonProperty("updateFrequency")] - public Models.UpdateFrequency UpdateFrequency { get; set; } + public UpdateFrequency UpdateFrequency { get; set; } [JsonProperty("mergePolicies")] - public IImmutableList MergePolicies { get; set; } + public List MergePolicies { get; set; } [JsonIgnore] public bool IsValid diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionUpdate.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionUpdate.cs similarity index 82% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionUpdate.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionUpdate.cs index 04e7211a51..665cc2f7d1 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/SubscriptionUpdate.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/SubscriptionUpdate.cs @@ -1,10 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; +using System.Collections.Generic; using Newtonsoft.Json; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public partial class SubscriptionUpdate { @@ -19,7 +19,7 @@ public SubscriptionUpdate() public string SourceRepository { get; set; } [JsonProperty("policy")] - public Models.SubscriptionPolicy Policy { get; set; } + public SubscriptionPolicy Policy { get; set; } [JsonProperty("enabled")] public bool? Enabled { get; set; } @@ -37,6 +37,6 @@ public SubscriptionUpdate() public string TargetDirectory { get; set; } [JsonProperty("excludedAssets")] - public IImmutableList ExcludedAssets { get; set; } + public List ExcludedAssets { get; set; } } } diff --git a/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/TrackedPullRequest.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/TrackedPullRequest.cs new file mode 100644 index 0000000000..6957ad9c48 --- /dev/null +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/TrackedPullRequest.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Microsoft.DotNet.ProductConstructionService.Client.Models +{ + public partial class TrackedPullRequest + { + public TrackedPullRequest() + { + } + + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("channel")] + public string Channel { get; set; } + + [JsonProperty("targetBranch")] + public string TargetBranch { get; set; } + + [JsonProperty("updates")] + public List Updates { get; set; } + } +} diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/UpdateFrequency.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/UpdateFrequency.cs similarity index 88% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/UpdateFrequency.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/UpdateFrequency.cs index d74312f921..821885e0ae 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Models/UpdateFrequency.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Models/UpdateFrequency.cs @@ -3,7 +3,7 @@ using System.Runtime.Serialization; -namespace ProductConstructionService.Client.Models +namespace Microsoft.DotNet.ProductConstructionService.Client.Models { public enum UpdateFrequency { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/PagedResponse.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/PagedResponse.cs similarity index 98% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/PagedResponse.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/PagedResponse.cs index dea824818c..a8e358de64 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/PagedResponse.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/PagedResponse.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Azure; -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public static class AsyncEnumerable { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Pipelines.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Pipelines.cs similarity index 97% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Pipelines.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Pipelines.cs index 3061564d97..f07544f6cb 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Pipelines.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Pipelines.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Immutable; +using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -11,11 +11,11 @@ -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface IPipelines { - Task> ListAsync( + Task> ListAsync( string organization = default, int? pipelineIdentifier = default, string project = default, @@ -54,7 +54,7 @@ public Pipelines(ProductConstructionServiceApi client) partial void HandleFailedListRequest(RestApiException ex); - public async Task> ListAsync( + public async Task> ListAsync( string organization = default, int? pipelineIdentifier = default, string project = default, @@ -106,7 +106,7 @@ public Pipelines(ProductConstructionServiceApi client) using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return _body; } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/ProductConstructionServiceApi.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/ProductConstructionServiceApi.cs similarity index 98% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/ProductConstructionServiceApi.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/ProductConstructionServiceApi.cs index f85954d6dc..949fe8d24a 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/ProductConstructionServiceApi.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/ProductConstructionServiceApi.cs @@ -20,7 +20,7 @@ using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface IProductConstructionServiceApi { @@ -30,10 +30,11 @@ public partial interface IProductConstructionServiceApi IAzDo AzDo { get; } IBuilds Builds { get; } IBuildTime BuildTime { get; } - IChannels Channels { get; } IDefaultChannels DefaultChannels { get; } IGoal Goal { get; } + IChannels Channels { get; } IPipelines Pipelines { get; } + IPullRequest PullRequest { get; } IRepository Repository { get; } IStatus Status { get; } ISubscriptions Subscriptions { get; } @@ -120,14 +121,16 @@ public HttpPipeline Pipeline public IBuildTime BuildTime { get; } - public IChannels Channels { get; } - public IDefaultChannels DefaultChannels { get; } public IGoal Goal { get; } + public IChannels Channels { get; } + public IPipelines Pipelines { get; } + public IPullRequest PullRequest { get; } + public IRepository Repository { get; } public IStatus Status { get; } @@ -147,10 +150,11 @@ public ProductConstructionServiceApi(ProductConstructionServiceApiOptions option AzDo = new AzDo(this); Builds = new Builds(this); BuildTime = new BuildTime(this); - Channels = new Channels(this); DefaultChannels = new DefaultChannels(this); Goal = new Goal(this); + Channels = new Channels(this); Pipelines = new Pipelines(this); + PullRequest = new PullRequest(this); Repository = new Repository(this); Status = new Status(this); Subscriptions = new Subscriptions(this); @@ -179,6 +183,7 @@ internal void OnFailedRequest(RestApiException ex) partial void HandleFailedRequest(RestApiException ex); + [MethodImpl(MethodImplOptions.AggressiveInlining)] public string Serialize(string value) { diff --git a/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/PullRequest.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/PullRequest.cs new file mode 100644 index 0000000000..b2b57294e5 --- /dev/null +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/PullRequest.cs @@ -0,0 +1,104 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; + + + +namespace Microsoft.DotNet.ProductConstructionService.Client +{ + public partial interface IPullRequest + { + Task> GetTrackedPullRequestsAsync( + CancellationToken cancellationToken = default + ); + + } + + internal partial class PullRequest : IServiceOperations, IPullRequest + { + public PullRequest(ProductConstructionServiceApi client) + { + Client = client ?? throw new ArgumentNullException(nameof(client)); + } + + public ProductConstructionServiceApi Client { get; } + + partial void HandleFailedRequest(RestApiException ex); + + partial void HandleFailedGetTrackedPullRequestsRequest(RestApiException ex); + + public async Task> GetTrackedPullRequestsAsync( + CancellationToken cancellationToken = default + ) + { + + const string apiVersion = "2020-02-20"; + + var _baseUri = Client.Options.BaseUri; + var _url = new RequestUriBuilder(); + _url.Reset(_baseUri); + _url.AppendPath( + "/api/pull-requests/tracked", + false); + + _url.AppendQuery("api-version", Client.Serialize(apiVersion)); + + + using (var _req = Client.Pipeline.CreateRequest()) + { + _req.Uri = _url; + _req.Method = RequestMethod.Get; + + using (var _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false)) + { + if (_res.Status < 200 || _res.Status >= 300) + { + await OnGetTrackedPullRequestsFailed(_req, _res).ConfigureAwait(false); + } + + if (_res.ContentStream == null) + { + await OnGetTrackedPullRequestsFailed(_req, _res).ConfigureAwait(false); + } + + using (var _reader = new StreamReader(_res.ContentStream)) + { + var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); + var _body = Client.Deserialize>(_content); + return _body; + } + } + } + } + + internal async Task OnGetTrackedPullRequestsFailed(Request req, Response res) + { + string content = null; + if (res.ContentStream != null) + { + using (var reader = new StreamReader(res.ContentStream)) + { + content = await reader.ReadToEndAsync().ConfigureAwait(false); + } + } + + var ex = new RestApiException( + req, + res, + content, + Client.Deserialize(content) + ); + HandleFailedGetTrackedPullRequestsRequest(ex); + HandleFailedRequest(ex); + Client.OnFailedRequest(ex); + throw ex; + } + } +} diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Repository.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Repository.cs similarity index 94% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Repository.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Repository.cs index efd210ddf3..6da93f93d7 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Repository.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Repository.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.IO; using System.Text; using System.Threading; @@ -13,17 +12,17 @@ -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface IRepository { - Task> ListRepositoriesAsync( + Task> ListRepositoriesAsync( string branch = default, string repository = default, CancellationToken cancellationToken = default ); - Task> GetMergePoliciesAsync( + Task> GetMergePoliciesAsync( string branch, string repository, CancellationToken cancellationToken = default @@ -32,7 +31,7 @@ public partial interface IRepository Task SetMergePoliciesAsync( string branch, string repository, - IImmutableList body = default, + List body = default, CancellationToken cancellationToken = default ); @@ -65,7 +64,7 @@ public Repository(ProductConstructionServiceApi client) partial void HandleFailedListRepositoriesRequest(RestApiException ex); - public async Task> ListRepositoriesAsync( + public async Task> ListRepositoriesAsync( string branch = default, string repository = default, CancellationToken cancellationToken = default @@ -112,7 +111,7 @@ public Repository(ProductConstructionServiceApi client) using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return _body; } } @@ -144,7 +143,7 @@ internal async Task OnListRepositoriesFailed(Request req, Response res) partial void HandleFailedGetMergePoliciesRequest(RestApiException ex); - public async Task> GetMergePoliciesAsync( + public async Task> GetMergePoliciesAsync( string branch, string repository, CancellationToken cancellationToken = default @@ -201,7 +200,7 @@ internal async Task OnListRepositoriesFailed(Request req, Response res) using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return _body; } } @@ -236,7 +235,7 @@ internal async Task OnGetMergePoliciesFailed(Request req, Response res) public async Task SetMergePoliciesAsync( string branch, string repository, - IImmutableList body = default, + List body = default, CancellationToken cancellationToken = default ) { @@ -276,7 +275,7 @@ public async Task SetMergePoliciesAsync( _req.Uri = _url; _req.Method = RequestMethod.Post; - if (body != default(IImmutableList)) + if (body != default(List)) { _req.Content = RequestContent.Create(Encoding.UTF8.GetBytes(Client.Serialize(body))); _req.Headers.Add("Content-Type", "application/json; charset=utf-8"); @@ -432,7 +431,7 @@ internal async Task OnSetMergePoliciesFailed(Request req, Response res) using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return Page.FromValues(_body, (page + 1).ToString(), _res); } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Status.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Status.cs similarity index 89% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Status.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Status.cs index c745505bd1..e7f67fb82b 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Status.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Status.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Collections.Immutable; +using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -11,19 +11,19 @@ -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface IStatus { - Task> GetPcsWorkItemProcessorStatusAsync( + Task> GetPcsWorkItemProcessorStatusAsync( CancellationToken cancellationToken = default ); - Task> StartPcsWorkItemProcessorsAsync( + Task> StartPcsWorkItemProcessorsAsync( CancellationToken cancellationToken = default ); - Task> StopPcsWorkItemProcessorsAsync( + Task> StopPcsWorkItemProcessorsAsync( CancellationToken cancellationToken = default ); @@ -42,7 +42,7 @@ public Status(ProductConstructionServiceApi client) partial void HandleFailedGetPcsWorkItemProcessorStatusRequest(RestApiException ex); - public async Task> GetPcsWorkItemProcessorStatusAsync( + public async Task> GetPcsWorkItemProcessorStatusAsync( CancellationToken cancellationToken = default ) { @@ -79,7 +79,7 @@ public async Task> GetPcsWorkItemProcessorS using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return _body; } } @@ -111,7 +111,7 @@ internal async Task OnGetPcsWorkItemProcessorStatusFailed(Request req, Response partial void HandleFailedStartPcsWorkItemProcessorsRequest(RestApiException ex); - public async Task> StartPcsWorkItemProcessorsAsync( + public async Task> StartPcsWorkItemProcessorsAsync( CancellationToken cancellationToken = default ) { @@ -148,7 +148,7 @@ public async Task> StartPcsWorkItemProcesso using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return _body; } } @@ -180,7 +180,7 @@ internal async Task OnStartPcsWorkItemProcessorsFailed(Request req, Response res partial void HandleFailedStopPcsWorkItemProcessorsRequest(RestApiException ex); - public async Task> StopPcsWorkItemProcessorsAsync( + public async Task> StopPcsWorkItemProcessorsAsync( CancellationToken cancellationToken = default ) { @@ -217,7 +217,7 @@ public async Task> StopPcsWorkItemProcessor using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return _body; } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Subscriptions.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Subscriptions.cs similarity index 98% rename from src/ProductConstructionService/ProductConstructionService.Client/Generated/Subscriptions.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Subscriptions.cs index e7d4992476..9e34c009c7 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/Generated/Subscriptions.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Generated/Subscriptions.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.IO; using System.Text; using System.Threading; @@ -13,11 +12,11 @@ -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial interface ISubscriptions { - Task> ListSubscriptionsAsync( + Task> ListSubscriptionsAsync( bool? enabled = default, int? channelId = default, string sourceDirectory = default, @@ -86,7 +85,7 @@ public Subscriptions(ProductConstructionServiceApi client) partial void HandleFailedListSubscriptionsRequest(RestApiException ex); - public async Task> ListSubscriptionsAsync( + public async Task> ListSubscriptionsAsync( bool? enabled = default, int? channelId = default, string sourceDirectory = default, @@ -158,7 +157,7 @@ public Subscriptions(ProductConstructionServiceApi client) using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return _body; } } @@ -719,7 +718,7 @@ internal async Task OnTriggerDailyUpdateFailed(Request req, Response res) using (var _reader = new StreamReader(_res.ContentStream)) { var _content = await _reader.ReadToEndAsync().ConfigureAwait(false); - var _body = Client.Deserialize>(_content); + var _body = Client.Deserialize>(_content); return Page.FromValues(_body, (page + 1).ToString(), _res); } } diff --git a/src/ProductConstructionService/ProductConstructionService.Client/GlobalSuppressions.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/GlobalSuppressions.cs similarity index 69% rename from src/ProductConstructionService/ProductConstructionService.Client/GlobalSuppressions.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/GlobalSuppressions.cs index 12ad617984..e0ae4164a9 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/GlobalSuppressions.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/GlobalSuppressions.cs @@ -3,5 +3,5 @@ using System.Diagnostics.CodeAnalysis; -[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "Auto-generate code", Scope = "namespaceanddescendants", Target = "~N:ProductConstructionService.Client")] -[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Auto-generate code", Scope = "namespaceanddescendants", Target = "~N:ProductConstructionService.Client")] +[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "Auto-generate code", Scope = "namespaceanddescendants", Target = "~N:Microsoft.DotNet.ProductConstructionService.Client")] +[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Auto-generate code", Scope = "namespaceanddescendants", Target = "~N:Microsoft.DotNet.ProductConstructionService.Client")] diff --git a/src/ProductConstructionService/ProductConstructionService.Client/ProductConstructionService.Client.csproj b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Microsoft.DotNet.ProductConstructionService.Client.csproj similarity index 100% rename from src/ProductConstructionService/ProductConstructionService.Client/ProductConstructionService.Client.csproj rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/Microsoft.DotNet.ProductConstructionService.Client.csproj diff --git a/src/ProductConstructionService/ProductConstructionService.Client/PcsApiFactory.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/PcsApiFactory.cs similarity index 98% rename from src/ProductConstructionService/ProductConstructionService.Client/PcsApiFactory.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/PcsApiFactory.cs index a0ea4ac113..8e428df39e 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/PcsApiFactory.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/PcsApiFactory.cs @@ -4,7 +4,7 @@ using System; #nullable enable -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public static class PcsApiFactory { diff --git a/src/ProductConstructionService/ProductConstructionService.Client/ProductConstructionServiceApiOptions.cs b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/ProductConstructionServiceApiOptions.cs similarity index 97% rename from src/ProductConstructionService/ProductConstructionService.Client/ProductConstructionServiceApiOptions.cs rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/ProductConstructionServiceApiOptions.cs index 94edce4d20..338d1123cf 100644 --- a/src/ProductConstructionService/ProductConstructionService.Client/ProductConstructionServiceApiOptions.cs +++ b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/ProductConstructionServiceApiOptions.cs @@ -7,7 +7,7 @@ using Azure.Core; using Maestro.Common.AppCredentials; -namespace ProductConstructionService.Client +namespace Microsoft.DotNet.ProductConstructionService.Client { public partial class ProductConstructionServiceApiOptions { @@ -23,7 +23,7 @@ public partial class ProductConstructionServiceApiOptions public const string StagingMaestroUri = "https://maestro.int-dot.net/"; public const string OldStagingMaestroUri = "https://maestro-int.westus2.cloudapp.azure.com/"; public const string PcsProdUri = "https://product-construction-prod.wittysky-0c79e3cc.westus2.azurecontainerapps.io/"; - public const string PcsStagingUri = "https://product-construction-int.delightfuldune-c0f01ab0.westus2.azurecontainerapps.io/"; + public const string PcsStagingUri = "https://product-construction-int.agreeablesky-499be9de.westus2.azurecontainerapps.io/"; public const string PcsLocalUri = "https://localhost:53180/"; private const string APP_USER_SCOPE = "Maestro.User"; diff --git a/src/ProductConstructionService/ProductConstructionService.Client/generate-client.cmd b/src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/generate-client.cmd similarity index 100% rename from src/ProductConstructionService/ProductConstructionService.Client/generate-client.cmd rename to src/ProductConstructionService/Microsoft.DotNet.ProductConstructionService.Client/generate-client.cmd diff --git a/src/ProductConstructionService/ProductConstructionService.Api/Api/v2020_02_20/Controllers/PullRequestController.cs b/src/ProductConstructionService/ProductConstructionService.Api/Api/v2020_02_20/Controllers/PullRequestController.cs new file mode 100644 index 0000000000..5c238af1fa --- /dev/null +++ b/src/ProductConstructionService/ProductConstructionService.Api/Api/v2020_02_20/Controllers/PullRequestController.cs @@ -0,0 +1,141 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Net; +using System.Text.RegularExpressions; +using Maestro.Data; +using Microsoft.AspNetCore.ApiVersioning; +using Microsoft.AspNetCore.ApiVersioning.Swashbuckle; +using Microsoft.AspNetCore.Mvc; +using Microsoft.DotNet.DarcLib.Helpers; +using Microsoft.EntityFrameworkCore; +using ProductConstructionService.Common; +using ProductConstructionService.DependencyFlow; + +namespace ProductConstructionService.Api.Api.v2020_02_20.Controllers; + +[Route("pull-requests")] +[ApiVersion("2020-02-20")] +public partial class PullRequestController : ControllerBase +{ + [GeneratedRegex(@"https://api.github.com/repos/(?[^/]+)/(?[^/]+)/pulls/(?[0-9]+)/?")] + private static partial Regex GitHubApiPrUrlRegex(); + + [GeneratedRegex(@"https://dev.azure.com/(?[^/]+)/(?[^/]+)/_apis/git/repositories/(?[^/]+)/pullRequests/(?[0-9]+)/?")] + private static partial Regex AzdoApiPrUrlRegex(); + + private static readonly Dictionary WellKnownIds = new() + { + ["7ea9116e-9fac-403d-b258-b31fcf1bb293"] = "internal", // AzDO's dnceng/internal + }; + + private static string ResolveWellKnownIds(string str) + { + foreach (var pair in WellKnownIds) + { + str = str.Replace(pair.Key, pair.Value); + } + + return str; + } + + private readonly IRedisCacheFactory _cacheFactory; + private readonly BuildAssetRegistryContext _context; + + public PullRequestController( + IRedisCacheFactory cacheFactory, + BuildAssetRegistryContext context) + { + _cacheFactory = cacheFactory; + _context = context; + } + + [HttpGet("tracked")] + [SwaggerApiResponse(HttpStatusCode.OK, Type = typeof(List), Description = "The list of currently tracked pull requests by the service")] + [ValidateModelState] + public async Task GetTrackedPullRequests() + { + var cache = _cacheFactory.Create(nameof(InProgressPullRequest) + "_"); + + var prs = new List(); + await foreach (var key in cache.GetKeysAsync(nameof(InProgressPullRequest) + "_*")) + { + var pr = await _cacheFactory + .Create(key, includeTypeInKey: false) + .TryGetStateAsync(); + + if (pr == null) + { + continue; + } + + var subscriptionIds = pr.ContainedSubscriptions.Select(s => s.SubscriptionId).ToList(); + var subscriptions = await _context.Subscriptions + .Where(s => subscriptionIds.Contains(s.Id)) + .Include(s => s.Channel) + .ToListAsync(); + + var sampleSub = subscriptions.FirstOrDefault(); + + string? org = null; + string? repoName = null; + if (sampleSub != null) + { + if (GitRepoUrlParser.ParseTypeFromUri(sampleSub.TargetRepository) == GitRepoType.AzureDevOps) + { + (repoName, org) = GitRepoUrlParser.GetRepoNameAndOwner(sampleSub.TargetRepository); + } + } + + var updates = subscriptions + .Select(update => new PullRequestUpdate( + TurnApiUrlToWebsite(update.SourceRepository, org, repoName), + pr.ContainedSubscriptions.First(s => s.SubscriptionId == update.Id).BuildId)) + .ToList(); + + prs.Add(new TrackedPullRequest( + TurnApiUrlToWebsite(pr.Url, org, repoName), + sampleSub?.Channel?.Name, + sampleSub?.TargetBranch, + updates)); + } + + return Ok(prs.AsQueryable()); + } + + private static string TurnApiUrlToWebsite(string url, string? orgName, string? repoName) + { + var match = GitHubApiPrUrlRegex().Match(url); + if (match.Success) + { + return $"https://github.com/{match.Groups["org"]}/{match.Groups["repo"]}/pull/{match.Groups["id"]}"; + } + + match = AzdoApiPrUrlRegex().Match(url); + if (match.Success) + { + // If we have the repo name, use it to replace the repo GUID in the URL + if (repoName != null) + { + WellKnownIds[match.Groups["repo"].Value] = orgName + "-" +repoName; + } + + var org = ResolveWellKnownIds(match.Groups["org"].Value); + var project = ResolveWellKnownIds(match.Groups["project"].Value); + var repo = ResolveWellKnownIds(match.Groups["repo"].Value); + return $"https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{match.Groups["id"]}"; + } + + return url; + } + + private record TrackedPullRequest( + string Url, + string? Channel, + string? TargetBranch, + List Updates); + + private record PullRequestUpdate( + string SourceRepository, + int BuildId); +} diff --git a/src/ProductConstructionService/ProductConstructionService.AppHost/Program.cs b/src/ProductConstructionService/ProductConstructionService.AppHost/Program.cs index 26202e1933..da5f4e5d94 100644 --- a/src/ProductConstructionService/ProductConstructionService.AppHost/Program.cs +++ b/src/ProductConstructionService/ProductConstructionService.AppHost/Program.cs @@ -3,9 +3,11 @@ var builder = DistributedApplication.CreateBuilder(args); -var redisCache = builder.AddRedis("redis", port: 55689); +var redisCache = builder + .AddRedis("redis", port: 55689); + var queues = builder.AddAzureStorage("storage") - .RunAsEmulator(emulator => emulator.WithImageTag("3.31.0")) // Workaround for https://github.com/dotnet/aspire/issues/5078 + .RunAsEmulator() .AddQueues("queues"); builder.AddProject("productConstructionServiceApi") diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildGraphData.cs b/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildGraphData.cs index b1b0ad4fad..092f2dad1f 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildGraphData.cs +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildGraphData.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Globalization; -using ProductConstructionService.Client.Models; +using Microsoft.DotNet.ProductConstructionService.Client.Models; namespace ProductConstructionService.BarViz.Code.Helpers; diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildHelper.cs b/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildHelper.cs index 949a560ecc..e781287231 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildHelper.cs +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildHelper.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using ProductConstructionService.Client.Models; +using Microsoft.DotNet.ProductConstructionService.Client.Models; namespace ProductConstructionService.BarViz.Code.Helpers; diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildTreeViewItem.cs b/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildTreeViewItem.cs index 8e9043b446..b72fab9a41 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildTreeViewItem.cs +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Code/Helpers/BuildTreeViewItem.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.FluentUI.AspNetCore.Components; -using ProductConstructionService.Client.Models; +using Microsoft.DotNet.ProductConstructionService.Client.Models; namespace ProductConstructionService.BarViz.Code.Helpers; diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Assets.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Assets.razor index 7a555e973f..f4d39d8d0e 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Assets.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Assets.razor @@ -1,6 +1,6 @@ @using Azure.Core -@using ProductConstructionService.Client -@using ProductConstructionService.Client.Models; +@using Microsoft.DotNet.ProductConstructionService.Client; +@using Microsoft.DotNet.ProductConstructionService.Client.Models; @using System.ComponentModel.DataAnnotations @inject IProductConstructionServiceApi PcsApi diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/BuildInfo.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/BuildInfo.razor index 73582b940d..5fcc31e25d 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/BuildInfo.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/BuildInfo.razor @@ -1,6 +1,6 @@ @using ProductConstructionService.BarViz.Code.Helpers; -@using ProductConstructionService.Client -@using ProductConstructionService.Client.Models; +@using Microsoft.DotNet.ProductConstructionService.Client; +@using Microsoft.DotNet.ProductConstructionService.Client.Models; @using TextCopy; @inject IClipboard Clipboard @inject IProductConstructionServiceApi PcsApi diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/ChannelNavMenuItem.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/ChannelNavMenuItem.razor index 4f045c5e00..c001ff79f8 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/ChannelNavMenuItem.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/ChannelNavMenuItem.razor @@ -1,6 +1,6 @@ @using ProductConstructionService.BarViz.Code.Helpers -@using ProductConstructionService.Client -@using ProductConstructionService.Client.Models; +@using Microsoft.DotNet.ProductConstructionService.Client; +@using Microsoft.DotNet.ProductConstructionService.Client.Models; @using System.Collections.Immutable @inject IProductConstructionServiceApi PcsApi @@ -46,7 +46,7 @@ public required Channel Channel { get; set; } private bool loaded = false; - private IImmutableList repositories = []; + private List repositories = []; private async Task OnExpandedChanged() { diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Dependencies.razor.cs b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Dependencies.razor.cs index 10ecf901dd..98612c94d3 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Dependencies.razor.cs +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Dependencies.razor.cs @@ -2,9 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.AspNetCore.Components; +using Microsoft.DotNet.ProductConstructionService.Client; +using Microsoft.DotNet.ProductConstructionService.Client.Models; using ProductConstructionService.BarViz.Code.Helpers; -using ProductConstructionService.Client; -using ProductConstructionService.Client.Models; namespace ProductConstructionService.BarViz.Components; diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/DependencyGrid.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/DependencyGrid.razor index 9f3a48276f..720cd84456 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/DependencyGrid.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/DependencyGrid.razor @@ -1,5 +1,5 @@ @using ProductConstructionService.BarViz.Code.Helpers -@using ProductConstructionService.Client.Models; +@using Microsoft.DotNet.ProductConstructionService.Client.Models; diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/PinnedChannels.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/PinnedChannels.razor index f7dfc8a3e3..0add0cacd6 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/PinnedChannels.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/PinnedChannels.razor @@ -1,4 +1,4 @@ -@using ProductConstructionService.Client.Models; +@using Microsoft.DotNet.ProductConstructionService.Client.Models; @using System.Collections.Immutable @inject NavigationManager NavManager @inject Blazored.SessionStorage.ISyncSessionStorageService SessionStorage @@ -57,7 +57,7 @@ @code { [Parameter] - public IImmutableList? AvailableChannels { get; set; } + public List? AvailableChannels { get; set; } [Parameter] public List? PrePinnedChannels { get; set; } diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Subscriptions.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Subscriptions.razor index c02b2a417d..f40736fb0e 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Subscriptions.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Components/Subscriptions.razor @@ -1,5 +1,5 @@ -@using ProductConstructionService.Client -@using ProductConstructionService.Client.Models; +@using Microsoft.DotNet.ProductConstructionService.Client; +@using Microsoft.DotNet.ProductConstructionService.Client.Models; @using System.ComponentModel.DataAnnotations @inject IProductConstructionServiceApi PcsApi diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/MainLayout.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/MainLayout.razor index 0b3c853c98..e1594118ec 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/MainLayout.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/MainLayout.razor @@ -9,6 +9,10 @@ + + Tracked pull requests + +
diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/NavMenu.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/NavMenu.razor index bbce1cd6a0..2628339eb2 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/NavMenu.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Layout/NavMenu.razor @@ -1,6 +1,6 @@ @using ProductConstructionService.BarViz.Components -@using ProductConstructionService.Client -@using ProductConstructionService.Client.Models; +@using Microsoft.DotNet.ProductConstructionService.Client; +@using Microsoft.DotNet.ProductConstructionService.Client.Models; @using System.Collections.Immutable @inject IProductConstructionServiceApi PcsApi @inject NavigationManager NavManager @@ -34,8 +34,7 @@ private bool expanded = true; - private IImmutableList AvailableChannels = []; - + private List AvailableChannels = []; private List Categories = []; private List PrePinnedChannels = []; diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Build.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Build.razor index b250515b1c..e2264ca083 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Build.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Build.razor @@ -1,8 +1,8 @@ @page "/channel/{ChannelId:int}/{RepoSlug}/build/{BuildId}" @using ProductConstructionService.BarViz.Code.Helpers @using ProductConstructionService.BarViz.Components.Common -@using ProductConstructionService.Client -@using ProductConstructionService.Client.Models; +@using Microsoft.DotNet.ProductConstructionService.Client; +@using Microsoft.DotNet.ProductConstructionService.Client.Models; @using ProductConstructionService.BarViz.Components; @inject IProductConstructionServiceApi PcsApi @@ -51,7 +51,7 @@ else private string? Channel { get; set; } - private ProductConstructionService.Client.Models.Build? _build; + private Microsoft.DotNet.ProductConstructionService.Client.Models.Build? _build; protected override async Task OnParametersSetAsync() { diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Channel.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Channel.razor index a0f58ce742..4074d01447 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Channel.razor +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Channel.razor @@ -1,7 +1,7 @@ @page "/channel/{ChannelId:int}" -@using ProductConstructionService.Client -@using ProductConstructionService.Client.Models; +@using Microsoft.DotNet.ProductConstructionService.Client; +@using Microsoft.DotNet.ProductConstructionService.Client.Models; @inject IProductConstructionServiceApi PcsApi @channel?.Name @@ -19,7 +19,7 @@ [Parameter] public int? ChannelId { get; set; } - private Client.Models.Channel? channel; + private Microsoft.DotNet.ProductConstructionService.Client.Models.Channel? channel; protected override async Task OnParametersSetAsync() { diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/PullRequests.razor b/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/PullRequests.razor new file mode 100644 index 0000000000..9251d700ac --- /dev/null +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Pages/PullRequests.razor @@ -0,0 +1,67 @@ +@page "/pullrequests" + +@using Microsoft.DotNet.ProductConstructionService.Client +@using Microsoft.DotNet.ProductConstructionService.Client.Models; +@inject IProductConstructionServiceApi api + +Tracked Pull Requests + + + + + + @context.Url + + + @if (context.Channel != null) + { + @context.Channel + } + else + { + + + + } + + + @if (context.TargetBranch != null) + { + @context.TargetBranch + } + else + { + + + + } + + + + + +@code { + IQueryable? TrackedPullRequests = null; + Timer? _timer; + + protected override async Task OnInitializedAsync() + { + await LoadDataAsync(); + _timer = new Timer(async _ => await LoadDataAsync(), null, TimeSpan.Zero, TimeSpan.FromSeconds(30)); + } + + private async Task LoadDataAsync() + { + TrackedPullRequests = (await api.PullRequest.GetTrackedPullRequestsAsync()).AsQueryable(); + await InvokeAsync(StateHasChanged); + } + + public void Dispose() + { + _timer?.Dispose(); + } +} diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/ProductConstructionService.BarViz.csproj b/src/ProductConstructionService/ProductConstructionService.BarViz/ProductConstructionService.BarViz.csproj index bd9b683e8c..ec9540cc9e 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/ProductConstructionService.BarViz.csproj +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/ProductConstructionService.BarViz.csproj @@ -18,7 +18,7 @@ - + diff --git a/src/ProductConstructionService/ProductConstructionService.BarViz/Program.cs b/src/ProductConstructionService/ProductConstructionService.BarViz/Program.cs index a2b388a79b..d2e88dd743 100644 --- a/src/ProductConstructionService/ProductConstructionService.BarViz/Program.cs +++ b/src/ProductConstructionService/ProductConstructionService.BarViz/Program.cs @@ -1,14 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Collections.Immutable; +using Blazored.SessionStorage; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Microsoft.DotNet.ProductConstructionService.Client; using Microsoft.FluentUI.AspNetCore.Components; using ProductConstructionService.BarViz; -using TextCopy; using ProductConstructionService.BarViz.Code.Services; -using Blazored.SessionStorage; -using System.Collections.Immutable; +using TextCopy; // Needed for Newtonsoft.Json to work so it must not get trimmed away // DynamicDependency attribute did not work for some reason @@ -25,7 +26,7 @@ builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(PcsApiBaseAddress) }); builder.Services.AddFluentUIComponents(); -builder.Services.AddSingleton(ProductConstructionService.Client.PcsApiFactory.GetAnonymous(PcsApiBaseAddress)); +builder.Services.AddSingleton(PcsApiFactory.GetAnonymous(PcsApiBaseAddress)); builder.Services.InjectClipboard(); builder.Services.AddSingleton(); builder.Services.AddBlazoredSessionStorage(); diff --git a/src/ProductConstructionService/ProductConstructionService.Cli/Operations/GetPCSStatusOperation.cs b/src/ProductConstructionService/ProductConstructionService.Cli/Operations/GetPCSStatusOperation.cs index e5b50723cc..4721c96db1 100644 --- a/src/ProductConstructionService/ProductConstructionService.Cli/Operations/GetPCSStatusOperation.cs +++ b/src/ProductConstructionService/ProductConstructionService.Cli/Operations/GetPCSStatusOperation.cs @@ -1,10 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Microsoft.DotNet.ProductConstructionService.Client; using Microsoft.Extensions.Logging; -using ProductConstructionService.Client; namespace ProductConstructionService.Cli.Operations; + internal class GetPcsStatusOperation : IOperation { private readonly IProductConstructionServiceApi _client; diff --git a/src/ProductConstructionService/ProductConstructionService.Cli/Operations/StartPCSOperation.cs b/src/ProductConstructionService/ProductConstructionService.Cli/Operations/StartPCSOperation.cs index 29ca47dbde..8c9b6d0de2 100644 --- a/src/ProductConstructionService/ProductConstructionService.Cli/Operations/StartPCSOperation.cs +++ b/src/ProductConstructionService/ProductConstructionService.Cli/Operations/StartPCSOperation.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Logging; -using ProductConstructionService.Client; +using Microsoft.DotNet.ProductConstructionService.Client; namespace ProductConstructionService.Cli.Operations; internal class StartPCSOperation : IOperation diff --git a/src/ProductConstructionService/ProductConstructionService.Cli/Operations/StopPCSOperation.cs b/src/ProductConstructionService/ProductConstructionService.Cli/Operations/StopPCSOperation.cs index 86405e9c15..c1bf5084e5 100644 --- a/src/ProductConstructionService/ProductConstructionService.Cli/Operations/StopPCSOperation.cs +++ b/src/ProductConstructionService/ProductConstructionService.Cli/Operations/StopPCSOperation.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Logging; -using ProductConstructionService.Client; +using Microsoft.DotNet.ProductConstructionService.Client; namespace ProductConstructionService.Cli.Operations; internal class StopPcsOperation : IOperation diff --git a/src/ProductConstructionService/ProductConstructionService.Cli/Options/PCSStatusOptions.cs b/src/ProductConstructionService/ProductConstructionService.Cli/Options/PCSStatusOptions.cs index 7c3075de88..f311cc0b31 100644 --- a/src/ProductConstructionService/ProductConstructionService.Cli/Options/PCSStatusOptions.cs +++ b/src/ProductConstructionService/ProductConstructionService.Cli/Options/PCSStatusOptions.cs @@ -3,7 +3,7 @@ using CommandLine; using Microsoft.Extensions.DependencyInjection; -using ProductConstructionService.Client; +using Microsoft.DotNet.ProductConstructionService.Client; namespace ProductConstructionService.Cli.Options; diff --git a/src/ProductConstructionService/ProductConstructionService.Cli/ProductConstructionService.Cli.csproj b/src/ProductConstructionService/ProductConstructionService.Cli/ProductConstructionService.Cli.csproj index 3c3ea7818c..fd069f767a 100644 --- a/src/ProductConstructionService/ProductConstructionService.Cli/ProductConstructionService.Cli.csproj +++ b/src/ProductConstructionService/ProductConstructionService.Cli/ProductConstructionService.Cli.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/ProductConstructionService/ProductConstructionService.Common/RedisCache.cs b/src/ProductConstructionService/ProductConstructionService.Common/RedisCache.cs index ef29fd3589..fe7c17e005 100644 --- a/src/ProductConstructionService/ProductConstructionService.Common/RedisCache.cs +++ b/src/ProductConstructionService/ProductConstructionService.Common/RedisCache.cs @@ -10,10 +10,12 @@ namespace ProductConstructionService.Common; public interface IRedisCache { + Task GetAsync(string key); Task GetAsync(); Task SetAsync(string value, TimeSpan? expiration = null); Task TryDeleteAsync(); Task TryGetAsync(); + IAsyncEnumerable GetKeysAsync(string pattern); } public class RedisCache : IRedisCache @@ -51,6 +53,24 @@ public async Task TryDeleteAsync() { return await Cache.StringGetAsync(_stateKey); } + + public async Task GetAsync(string key) + { + return await Cache.StringGetAsync(key); + } + + public async IAsyncEnumerable GetKeysAsync(string pattern) + { + // We most likely only have one endpoint so no need to parallelize this part + foreach (var endpoint in _connection.GetEndPoints()) + { + var server = _connection.GetServer(endpoint); + await foreach (var key in server.KeysAsync(pattern: pattern)) + { + yield return key.ToString(); + } + } + } } public interface IRedisCache where T : class @@ -58,6 +78,7 @@ public interface IRedisCache where T : class Task SetAsync(T value, TimeSpan? expiration = null); Task TryDeleteAsync(); Task TryGetStateAsync(); + IAsyncEnumerable GetKeysAsync(string pattern); } public class RedisCache : IRedisCache where T : class @@ -68,20 +89,23 @@ public class RedisCache : IRedisCache where T : class WriteIndented = false, }; - private readonly IRedisCache _stateManager; + private readonly IRedisCache _cache; private readonly ILogger _logger; - public RedisCache( - IRedisCache stateManager, - ILogger logger) + public RedisCache(IRedisCache cache, ILogger logger) { - _stateManager = stateManager; + _cache = cache; _logger = logger; } - public async Task TryGetStateAsync() => await TryGetStateAsync(false); + public IAsyncEnumerable GetKeysAsync(string pattern) + => _cache.GetKeysAsync(pattern); + + public async Task TryGetStateAsync() + => await TryGetStateAsync(false); - public async Task TryDeleteAsync() => await TryGetStateAsync(true); + public async Task TryDeleteAsync() + => await TryGetStateAsync(true); public async Task SetAsync(T value, TimeSpan? expiration = null) { @@ -96,12 +120,12 @@ public async Task SetAsync(T value, TimeSpan? expiration = null) return; } - await _stateManager.SetAsync(json, expiration ?? RedisCache.DefaultExpiration); + await _cache.SetAsync(json, expiration ?? RedisCache.DefaultExpiration); } private async Task TryGetStateAsync(bool delete) { - var state = await _stateManager.TryGetAsync(); + var state = await _cache.TryGetAsync(); if (state == null) { return null; @@ -109,7 +133,7 @@ public async Task SetAsync(T value, TimeSpan? expiration = null) if (delete) { - await _stateManager.TryDeleteAsync(); + await _cache.TryDeleteAsync(); } try diff --git a/src/ProductConstructionService/ProductConstructionService.DependencyFlow/NonBatchedPullRequestUpdater.cs b/src/ProductConstructionService/ProductConstructionService.DependencyFlow/NonBatchedPullRequestUpdater.cs index 6f6cb042e3..760a1acd1f 100644 --- a/src/ProductConstructionService/ProductConstructionService.DependencyFlow/NonBatchedPullRequestUpdater.cs +++ b/src/ProductConstructionService/ProductConstructionService.DependencyFlow/NonBatchedPullRequestUpdater.cs @@ -17,6 +17,7 @@ internal class NonBatchedPullRequestUpdater : PullRequestUpdater private readonly NonBatchedPullRequestUpdaterId _id; private readonly BuildAssetRegistryContext _context; private readonly IPullRequestPolicyFailureNotifier _pullRequestPolicyFailureNotifier; + private readonly ILogger _logger; public NonBatchedPullRequestUpdater( NonBatchedPullRequestUpdaterId id, @@ -57,6 +58,7 @@ public NonBatchedPullRequestUpdater( _id = id; _context = context; _pullRequestPolicyFailureNotifier = pullRequestPolicyFailureNotifier; + _logger = logger; } public Guid SubscriptionId => _id.SubscriptionId; @@ -64,14 +66,21 @@ public NonBatchedPullRequestUpdater( private async Task RetrieveSubscription() { Subscription? subscription = await _context.Subscriptions.FindAsync(SubscriptionId); + + // This can mainly happen during E2E tests where we delete a subscription + // while some PRs have just been closed and there's a reminder on those still if (subscription == null) { + _logger.LogInformation( + $"Failed to find a subscription {SubscriptionId}. " + + "Possibly it was deleted while an existing PR is still tracked. Untracking PR..."); + // We don't know if the subscription was a code flow one, so just unset both + await _pullRequestState.TryDeleteAsync(); await _pullRequestCheckReminders.UnsetReminderAsync(isCodeFlow: true); await _pullRequestCheckReminders.UnsetReminderAsync(isCodeFlow: false); await _pullRequestUpdateReminders.UnsetReminderAsync(isCodeFlow: true); await _pullRequestUpdateReminders.UnsetReminderAsync(isCodeFlow: false); - return null; } diff --git a/src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestStatus.cs b/src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestStatus.cs index 869070e3f6..68efe0f0ff 100644 --- a/src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestStatus.cs +++ b/src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestStatus.cs @@ -6,7 +6,6 @@ namespace ProductConstructionService.DependencyFlow; public enum PullRequestStatus { Invalid = 0, - UnknownPR = 1, Completed = 2, InProgressCanUpdate = 3, InProgressCannotUpdate = 4, diff --git a/src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdater.cs b/src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdater.cs index b518ec177c..106a9ce078 100644 --- a/src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdater.cs +++ b/src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestUpdater.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Net; using Maestro.Contracts; using Maestro.Data.Models; using Maestro.MergePolicyEvaluation; @@ -91,6 +90,44 @@ public PullRequestUpdater( protected abstract Task> GetMergePolicyDefinitions(); + /// + /// Applies or queues asset updates for the target repository and branch from the given build and list of assets. + /// + /// The id of the subscription the update comes from + /// The build that the updated assets came from + /// The commit hash that built the assets + /// The list of assets + /// + /// This function will queue updates if there is a pull request and it is currently not-updateable. + /// A pull request is considered "not-updateable" based on merge policies. + /// If at least one merge policy calls and + /// no merge policy calls then the pull request is considered + /// not-updateable. + /// + /// PRs are marked as non-updateable so that we can allow pull request checks to complete on a PR prior + /// to pushing additional commits. + /// + public async Task UpdateAssetsAsync( + Guid subscriptionId, + SubscriptionType type, + int buildId, + string sourceRepo, + string sourceSha, + List assets) + { + return await ProcessPendingUpdatesAsync(new() + { + UpdaterId = Id.ToString(), + SubscriptionId = subscriptionId, + SubscriptionType = type, + BuildId = buildId, + SourceSha = sourceSha, + SourceRepo = sourceRepo, + Assets = assets, + IsCoherencyUpdate = false, + }); + } + /// /// Process any pending pull request updates. /// @@ -111,7 +148,8 @@ public async Task ProcessPendingUpdatesAsync(SubscriptionUpdateWorkItem up } else { - switch (await GetPullRequestStatusAsync(pr, isCodeFlow)) + var prStatus = await GetPullRequestStatusAsync(pr, isCodeFlow); + switch (prStatus) { case PullRequestStatus.Completed: case PullRequestStatus.Invalid: @@ -121,11 +159,13 @@ public async Task ProcessPendingUpdatesAsync(SubscriptionUpdateWorkItem up case PullRequestStatus.InProgressCanUpdate: // If we can update it, we will do it below break; - default: - _logger.LogInformation("PR {url} for subscription {subscriptionId} cannot be updated at this time", pr.Url, update.SubscriptionId); + case PullRequestStatus.InProgressCannotUpdate: + _logger.LogInformation("PR {url} for subscription {subscriptionId} cannot be updated at this time. Deferring update..", pr.Url, update.SubscriptionId); await _pullRequestUpdateReminders.SetReminderAsync(update, DefaultReminderDelay, isCodeFlow); await _pullRequestCheckReminders.UnsetReminderAsync(isCodeFlow); return false; + default: + throw new NotImplementedException($"Unknown PR status {prStatus}"); } } @@ -139,7 +179,6 @@ public async Task ProcessPendingUpdatesAsync(SubscriptionUpdateWorkItem up if (pr != null) { await UpdatePullRequestAsync(pr, update); - _logger.LogInformation("Pull request {url} for subscription {subscriptionId} was updated", pr.Url, update.SubscriptionId); await _pullRequestUpdateReminders.UnsetReminderAsync(isCodeFlow); return true; } @@ -166,7 +205,8 @@ public async Task CheckPullRequestAsync(PullRequestCheck pullRequestCheck) if (inProgressPr == null) { _logger.LogInformation("No in-progress pull request found for a PR check"); - await ClearAllStateAsync(); + await ClearAllStateAsync(isCodeFlow: true); + await ClearAllStateAsync(isCodeFlow: false); return false; } @@ -201,12 +241,13 @@ protected virtual Task TagSourceRepositoryGitHubContactsIfPossibleAsync(InProgre // If the PR is currently open, then evaluate the merge policies, which will potentially // merge the PR if they are successful. case PrStatus.Open: - var mergePolicyResult = await CheckMergePolicyAsync(pr, remote); + MergePolicyCheckResult mergePolicyResult = await CheckMergePolicyAsync(pr, remote); _logger.LogInformation("Policy check status for pull request {url} is {result}", pr.Url, mergePolicyResult); switch (mergePolicyResult) { + // Policies evaluated successfully and the PR was merged just now case MergePolicyCheckResult.Merged: await UpdateSubscriptionsForMergedPRAsync(pr.ContainedSubscriptions); await AddDependencyFlowEventsAsync( @@ -216,7 +257,7 @@ await AddDependencyFlowEventsAsync( mergePolicyResult, pr.Url); - await ClearAllStateAsync(); + await ClearAllStateAsync(isCodeFlow); return PullRequestStatus.Completed; case MergePolicyCheckResult.FailedPolicies: @@ -235,6 +276,7 @@ await AddDependencyFlowEventsAsync( return PullRequestStatus.InProgressCannotUpdate; default: + await SetPullRequestCheckReminder(pr, isCodeFlow); throw new NotImplementedException($"Unknown merge policy check result {mergePolicyResult}"); } @@ -259,7 +301,7 @@ await AddDependencyFlowEventsAsync( _logger.LogInformation("PR {url} has been manually {action}. Stopping tracking it", pr.Url, status.ToString().ToLowerInvariant()); - await ClearAllStateAsync(); + await ClearAllStateAsync(isCodeFlow); // Also try to clean up the PR branch. try @@ -356,8 +398,7 @@ private async Task UpdateSubscriptionsForMergedPRAsync(IEnumerable - /// Applies or queues asset updates for the target repository and branch from the given build and list of assets. - /// - /// The id of the subscription the update comes from - /// The build that the updated assets came from - /// The commit hash that built the assets - /// The list of assets - /// - /// This function will queue updates if there is a pull request and it is currently not-updateable. - /// A pull request is considered "not-updateable" based on merge policies. - /// If at least one merge policy calls and - /// no merge policy calls then the pull request is considered - /// not-updateable. - /// - /// PRs are marked as non-updateable so that we can allow pull request checks to complete on a PR prior - /// to pushing additional commits. - /// - public async Task UpdateAssetsAsync( - Guid subscriptionId, - SubscriptionType type, - int buildId, - string sourceRepo, - string sourceSha, - List assets) - { - // Check if we track an on-going PR already - InProgressPullRequest? pr = await _pullRequestState.TryGetStateAsync(); - bool isCodeFlow = type == SubscriptionType.DependenciesAndSources; - - bool canUpdate; - if (pr == null) - { - _logger.LogInformation("No existing pull request state found"); - canUpdate = true; - } - else - { - var status = await GetPullRequestStatusAsync(pr, isCodeFlow); - canUpdate = status == PullRequestStatus.InProgressCanUpdate; - - if (status == PullRequestStatus.Completed || status == PullRequestStatus.Invalid) - { - // If the PR is completed, we will open a new one - pr = null; - } - } - - var update = new SubscriptionUpdateWorkItem - { - UpdaterId = Id.ToString(), - SubscriptionId = subscriptionId, - SubscriptionType = type, - BuildId = buildId, - SourceSha = sourceSha, - SourceRepo = sourceRepo, - Assets = assets, - IsCoherencyUpdate = false, - }; - - // Regardless of code flow or regular PR, if the PR are not complete, postpone the update - if (pr != null && !canUpdate) - { - await _pullRequestUpdateReminders.SetReminderAsync(update, DefaultReminderDelay, isCodeFlow); - await _pullRequestCheckReminders.UnsetReminderAsync(isCodeFlow); - _logger.LogInformation("Pull request '{prUrl}' cannot be updated, update queued", pr!.Url); - return true; - } - - if (type == SubscriptionType.DependenciesAndSources) - { - return await ProcessCodeFlowUpdateAsync(update, pr); - } - - try - { - if (pr == null) - { - var prUrl = await CreatePullRequestAsync(update); - if (prUrl == null) - { - _logger.LogInformation("Updates require no changes, no pull request created"); - } - else - { - _logger.LogInformation("Pull request '{prUrl}' created", prUrl); - } - - return true; - } - - await UpdatePullRequestAsync(pr, update); - } - catch (HttpRequestException reqEx) when (reqEx.Message.Contains(((int)HttpStatusCode.Unauthorized).ToString())) - { - // We want to preserve the HttpRequestException's information but it's not serializable - // We'll log the full exception object so it's in Application Insights, and strip any single quotes from the message to ensure - // GitHub issues are properly created. - _logger.LogError(reqEx, "Failure to authenticate to repository"); - return false; - } - - return true; - } - /// /// Creates a pull request from the given updates. /// @@ -844,13 +781,11 @@ private async Task SetPullRequestCheckReminder(InProgressPullRequest prState, bo await _pullRequestState.SetAsync(prState); } - private async Task ClearAllStateAsync() + private async Task ClearAllStateAsync(bool isCodeFlow) { await _pullRequestState.TryDeleteAsync(); - await _pullRequestCheckReminders.UnsetReminderAsync(isCodeFlow: true); - await _pullRequestUpdateReminders.UnsetReminderAsync(isCodeFlow: true); - await _pullRequestCheckReminders.UnsetReminderAsync(isCodeFlow: false); - await _pullRequestUpdateReminders.UnsetReminderAsync(isCodeFlow: false); + await _pullRequestCheckReminders.UnsetReminderAsync(isCodeFlow); + await _pullRequestUpdateReminders.UnsetReminderAsync(isCodeFlow); } /// diff --git a/src/ProductConstructionService/Readme.md b/src/ProductConstructionService/Readme.md index 4e225dfbe1..c0b6e7674d 100644 --- a/src/ProductConstructionService/Readme.md +++ b/src/ProductConstructionService/Readme.md @@ -1,15 +1,18 @@ # Getting started with local development 1. Install the latest Preview VS. - - Be sure to install the `Azure Development => .NET Aspire SDK (Preview)` optional workload in the VS installer. - - If you're building the project using the command line, run `dotnet workload install aspire` or `dotnet workload update` to install/update the aspire workload. + - Be sure to install the `Azure Development => .NET Aspire SDK (Preview)` optional workload in the VS installer + - Be sure to install the `ASP.NET and web development` => `.NET 8.0/9.0 WebAssembly Build Tools` + - If you're building the project using the command line, run `dotnet workload install aspire` or `dotnet workload update` to install/update the aspire workload +1. Install Docker Desktop: https://www.docker.com/products/docker-desktop 1. Install SQL Server Express: https://www.microsoft.com/en-us/sql-server/sql-server-downloads -1. Install Node.js LTS. When asked, at the end of installation, also opt-in for all necessary tools. +1. Install Node.js LTS. When asked, at the end of installation, also opt-in for all necessary tools 1. Install Entity Framework Core CLI by running `dotnet tool install --global dotnet-ef` -1. From the `src\Maestro\Maestro.Data` project directory, run `dotnet ef --msbuildprojectextensionspath database update`. - - Note that the generated files are in the root artifacts folder, not the artifacts folder within the Maestro.Data project folder -1. Join the `maestro-auth-test` org in GitHub (you will need to ask someone to manually add you to the org). -1. Make sure you can read the `ProductConstructionDev` keyvault. If you can't, ask someone to add you to the keyvault. +1. Build the `src\Maestro\Maestro.Data\Maestro.Data.csproj` project (either from console or from IDE) +1. From the `src\Maestro\Maestro.Data` project directory, run `dotnet ef --msbuildprojectextensionspath database update` + - Note that the generated files are in the root artifacts folder, not the artifacts folder within the `Maestro.Data` project folder +1. Join the `maestro-auth-test` org in GitHub (you will need to ask someone to manually add you to the org) +1. Make sure you can read the `ProductConstructionDev` keyvault. If you can't, ask someone to add you to the keyvault 1. In SQL Server Object Explorer in Visual Studio, find the local SQLExpress database for the build asset registry and populate the Repositories table with the following rows: ```sql @@ -21,7 +24,6 @@ ('https://github.com/maestro-auth-test/arcade', 289474), ('https://github.com/maestro-auth-test/dnceng-vmr', 289474); ``` -1. Install Docker Desktop: https://www.docker.com/products/docker-desktop # Configuring the service for local runs @@ -43,13 +45,13 @@ When running locally: "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "http://localhost:18848", + "applicationUrl": "https://localhost:18848", "environmentVariables": { "VmrPath": "D:\\tmp\\vmr", "TmpPath": "D:\\tmp\\", "VmrUri": "https://github.com/maestro-auth-test/dnceng-vmr", - "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19265", - "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20130" + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:19265", + "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:20130" } } } @@ -159,6 +161,54 @@ The last part is setting up the pipeline: When creating a Container App with a bicep template, we have to give it some kind of boilerplate docker image, since our repository will be empty at the time of creation. Since we have a custom startup health probe, this revision will fail to activate. After the first run of the pipeline (deployment), make sure to deactivate the first, default revision. +# Changing the database model + +In case you need to change the database model (e.g. add a column to a table), follow the usual [EF Core code-first migration steps](https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli#evolving-your-model). +In practice this means the following: +1. Make the change to the model classes in the `Maestro.Data` project +1. Install the [EF Core CLI](https://docs.microsoft.com/en-us/ef/core/cli/dotnet) + ```ps1 + dotnet tool install --global dotnet-ef + ``` +1. Go to the `src\Maestro\Maestro.Data` project directory and build the project + ```ps1 + cd src\Maestro\Maestro.Data + dotnet build + ``` +1. Run the following command to create a new migration + ```ps1 + dotnet ef --msbuildprojectextensionspath migrations add + ``` + +The steps above will produce a new migration file which will later be processed by the CI pipeline on the real database. +Test this migration locally by running: +```ps1 +dotnet ef --msbuildprojectextensionspath database update +``` +You should see something like: +``` +Build started... +Build succeeded. +Applying migration '20240201144006_'. +Done. +``` + +If your change of the model changes the public API of the service, update also the `Maestro.Client`. + +## Changing the API / Updating `Microsoft.DotNet.ProductConstructionService.Client` + +`Microsoft.DotNet.ProductConstructionService.Client` is an auto-generated client library for the PCS API. It is generated using Swagger Codegen which parses the `swagger.json` file. +The `swagger.json` file is accessible at `/swagger.json` when the PCS API is running. +If you changed the API (e.g. changed an endpoint, model coming from the API, etc.), you need to regenerate the `Microsoft.DotNet.ProductConstructionService.Client` library. + +If you need to update the client library, follow these steps: + +1. Change the model/endpoint/.. +1. Change `src\ProductConstructionService\Client\src\Microsoft.DotNet.Microsoft.DotNet.ProductConstructionService.Client.csproj` and point the `SwaggerDocumentUri` to `https://localhost:53180/swagger.json`. +1. Start the Maestro application locally, verify you can access the swagger.json file. You can now stop debugging, the local SF cluster will keep running. +1. Run `src\ProductConstructionService\Microsoft.DotNet.ProductConstructionService.Client\src\generate-client.cmd` which will regenerate the C# classes. +1. You might see code-style changes in the C# classes as the SDK of the repo has now been updated. You can quickly use the Visual Studio's refactorings to fix those and minimize the code changes in this project. + # General deployment notes The Product Construction Service uses the [Blue-Green](https://learn.microsoft.com/en-us/azure/container-apps/blue-green-deployment?pivots=bicep) deployment approach, implemented in the [ProductConstructionService.Deployment](https://github.com/dotnet/arcade-services/tree/main/src/ProductConstructionService/ProductConstructionService.Deployment) script. The script does the following: diff --git a/test/Microsoft.DotNet.Darc.VirtualMonoRepo.E2E.Tests/VmrTestsBase.cs b/test/Microsoft.DotNet.Darc.VirtualMonoRepo.E2E.Tests/VmrTestsBase.cs index d0196d67f9..c3c6a77749 100644 --- a/test/Microsoft.DotNet.Darc.VirtualMonoRepo.E2E.Tests/VmrTestsBase.cs +++ b/test/Microsoft.DotNet.Darc.VirtualMonoRepo.E2E.Tests/VmrTestsBase.cs @@ -182,7 +182,6 @@ await vmrInitializer.InitializeRepository( initializeDependencies: true, sourceMappingsPath: sourceMappingsPath, additionalRemotes: Array.Empty(), - componentTemplatePath: null, tpnTemplatePath: null, generateCodeowners: false, generateCredScanSuppressions: false, @@ -208,7 +207,6 @@ await vmrUpdater.UpdateRepository( barId: null, updateDependencies: true, additionalRemotes: additionalRemotes, - componentTemplatePath: null, tpnTemplatePath: null, generateCodeowners: generateCodeowners, generateCredScanSuppressions: generateCredScanSuppressions, diff --git a/test/ProductConstructionService.DependencyFlow.Tests/MockRedisCache.cs b/test/ProductConstructionService.DependencyFlow.Tests/MockRedisCache.cs index c05fd25add..d91fe3fe34 100644 --- a/test/ProductConstructionService.DependencyFlow.Tests/MockRedisCache.cs +++ b/test/ProductConstructionService.DependencyFlow.Tests/MockRedisCache.cs @@ -20,7 +20,12 @@ public MockRedisCache(string key, Dictionary data) public Task GetAsync() { - return _data.TryGetValue(_key, out object? value) + return GetAsync(_key); + } + + public Task GetAsync(string key) + { + return _data.TryGetValue(key, out object? value) ? Task.FromResult((string?)value) : Task.FromResult((string?)null); } @@ -39,6 +44,11 @@ public Task TryDeleteAsync() } public Task TryGetAsync() => throw new NotImplementedException(); + + public IAsyncEnumerable GetKeysAsync(string pattern) + { + return _data.Keys.ToAsyncEnumerable(); + } } internal class MockRedisCache @@ -78,7 +88,12 @@ public Task SetAsync(T value, TimeSpan? expiration = null) public Task TryGetStateAsync() { return _data.TryGetValue(_key, out object? value) - ? Task.FromResult((T?)value) + ? Task.FromResult((T?)value) : Task.FromResult(default(T?)); } + + public IAsyncEnumerable GetKeysAsync(string pattern) + { + return _data.Keys.ToAsyncEnumerable(); + } } diff --git a/test/ProductConstructionService.ScenarioTests/CodeFlowScenarioTestBase.cs b/test/ProductConstructionService.ScenarioTests/CodeFlowScenarioTestBase.cs index f784bbbdd5..10ebc82bd9 100644 --- a/test/ProductConstructionService.ScenarioTests/CodeFlowScenarioTestBase.cs +++ b/test/ProductConstructionService.ScenarioTests/CodeFlowScenarioTestBase.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using FluentAssertions; +using Octokit; #nullable enable namespace ProductConstructionService.ScenarioTests; @@ -16,24 +17,28 @@ protected async Task CheckForwardFlowGitHubPullRequest( { var expectedPRTitle = GetCodeFlowPRName(targetBranch, sourceRepoName); - Octokit.PullRequest pullRequest = await WaitForPullRequestAsync(targetRepoName, targetBranch); - IReadOnlyList files = await GitHubApi.PullRequest.Files(TestParameters.GitHubTestOrg, targetRepoName, pullRequest.Number); + PullRequest pullRequest = await WaitForPullRequestAsync(targetRepoName, targetBranch); - files.Count.Should().Be(testFiles.Length + 2); + await using (CleanUpPullRequestAfter(TestParameters.GitHubTestOrg, targetRepoName, pullRequest)) + { + IReadOnlyList files = await GitHubApi.PullRequest.Files(TestParameters.GitHubTestOrg, targetRepoName, pullRequest.Number); - // Verify source-manifest has changes - var sourceManifestFile = files.FirstOrDefault(file => file.FileName == "src/source-manifest.json"); - sourceManifestFile.Should().NotBeNull(); + files.Count.Should().Be(testFiles.Length + 2); - var repoPropsFile = files.FirstOrDefault(file => file.FileName == $"prereqs/git-info/{sourceRepoName}.props"); - repoPropsFile.Should().NotBeNull(); + // Verify source-manifest has changes + var sourceManifestFile = files.FirstOrDefault(file => file.FileName == "src/source-manifest.json"); + sourceManifestFile.Should().NotBeNull(); - // Verify new files are in the PR - foreach (var testFile in testFiles) - { - var newFile = files.FirstOrDefault(file => file.FileName == $"src/{sourceRepoName}/{testFile}"); - newFile.Should().NotBeNull(); - newFile!.Patch.Should().Be(testFilePatches[testFile]); + var repoPropsFile = files.FirstOrDefault(file => file.FileName == $"prereqs/git-info/{sourceRepoName}.props"); + repoPropsFile.Should().NotBeNull(); + + // Verify new files are in the PR + foreach (var testFile in testFiles) + { + var newFile = files.FirstOrDefault(file => file.FileName == $"src/{sourceRepoName}/{testFile}"); + newFile.Should().NotBeNull(); + newFile!.Patch.Should().Be(testFilePatches[testFile]); + } } } @@ -48,19 +53,23 @@ protected async Task CheckBackwardFlowGitHubPullRequest( { var expectedPRTitle = GetCodeFlowPRName(targetBranch, sourceRepoName); - Octokit.PullRequest pullRequest = await WaitForPullRequestAsync(targetRepoName, targetBranch); - IReadOnlyList files = await GitHubApi.PullRequest.Files(TestParameters.GitHubTestOrg, targetRepoName, pullRequest.Number); + PullRequest pullRequest = await WaitForPullRequestAsync(targetRepoName, targetBranch); - var versionDetailsFile = files.FirstOrDefault(file => file.FileName == "eng/Version.Details.xml"); - versionDetailsFile.Should().NotBeNull(); - versionDetailsFile!.Patch.Should().Contain(GetExpectedCodeFlowDependencyVersionEntry(sourceRepoName, commitSha, buildId)); - - // Verify new files are in the PR - foreach (var testFile in testFiles) + await using (CleanUpPullRequestAfter(TestParameters.GitHubTestOrg, targetRepoName, pullRequest)) { - var newFile = files.FirstOrDefault(file => file.FileName == $"{testFile}"); - newFile.Should().NotBeNull(); - newFile!.Patch.Should().Be(testFilePatches[testFile]); + IReadOnlyList files = await GitHubApi.PullRequest.Files(TestParameters.GitHubTestOrg, targetRepoName, pullRequest.Number); + + var versionDetailsFile = files.FirstOrDefault(file => file.FileName == "eng/Version.Details.xml"); + versionDetailsFile.Should().NotBeNull(); + versionDetailsFile!.Patch.Should().Contain(GetExpectedCodeFlowDependencyVersionEntry(sourceRepoName, commitSha, buildId)); + + // Verify new files are in the PR + foreach (var testFile in testFiles) + { + var newFile = files.FirstOrDefault(file => file.FileName == $"{testFile}"); + newFile.Should().NotBeNull(); + newFile!.Patch.Should().Be(testFilePatches[testFile]); + } } } diff --git a/test/ProductConstructionService.ScenarioTests/EndToEndFlowLogic.cs b/test/ProductConstructionService.ScenarioTests/EndToEndFlowLogic.cs index 1f969a8337..340fe18587 100644 --- a/test/ProductConstructionService.ScenarioTests/EndToEndFlowLogic.cs +++ b/test/ProductConstructionService.ScenarioTests/EndToEndFlowLogic.cs @@ -1,10 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; using Microsoft.DotNet.DarcLib.Models.Darc; +using Microsoft.DotNet.ProductConstructionService.Client.Models; using NUnit.Framework; -using ProductConstructionService.Client.Models; namespace ProductConstructionService.ScenarioTests; @@ -16,8 +15,8 @@ internal abstract class TestLogic : ScenarioTestBase public async Task DarcBatchedFlowTestBase( string targetBranch, string channelName, - IImmutableList source1Assets, - IImmutableList source2Assets, + List source1Assets, + List source2Assets, List expectedDependencies, bool isAzDoTest) { @@ -75,18 +74,29 @@ public async Task DarcBatchedFlowTestBase( if (isAzDoTest) { - await CheckBatchedAzDoPullRequest([source1RepoName, source2RepoName], targetRepoName, targetBranch, expectedDependencies, reposFolder.Directory); + await CheckBatchedAzDoPullRequest( + [source1RepoName, source2RepoName], + targetRepoName, + targetBranch, + expectedDependencies, + reposFolder.Directory); } else { - await CheckBatchedGitHubPullRequest(targetBranch, [source1RepoName, source2RepoName], targetRepoName, expectedDependencies, reposFolder.Directory); + await CheckBatchedGitHubPullRequest( + targetBranch, + [source1RepoName, source2RepoName], + targetRepoName, + expectedDependencies, + reposFolder.Directory, + cleanUp: true); } } } } } - public async Task NonBatchedGitHubFlowTestBase(string targetBranch, string channelName, IImmutableList sourceAssets, + public async Task NonBatchedGitHubFlowTestBase(string targetBranch, string channelName, List sourceAssets, List expectedDependencies, bool allChecks = false) { var targetRepoName = TestRepository.TestRepo2Name; @@ -126,14 +136,22 @@ public async Task NonBatchedGitHubFlowTestBase(string targetBranch, string chann TestContext.WriteLine($"Waiting on PR to be opened in {targetRepoUri}"); - await CheckNonBatchedGitHubPullRequest(sourceRepoName, targetRepoName, targetBranch, expectedDependencies, reposFolder.Directory, isCompleted: true, isUpdated: false); + await CheckNonBatchedGitHubPullRequest( + sourceRepoName, + targetRepoName, + targetBranch, + expectedDependencies, + reposFolder.Directory, + isCompleted: true, + isUpdated: false, + cleanUp: true); } } } } - public async Task NonBatchedGitHubFlowCoherencyTestBase(string targetBranch, string channelName, IImmutableList sourceAssets, - IImmutableList childSourceAssets, List expectedDependencies, string coherentParent, bool allChecks) + public async Task NonBatchedGitHubFlowCoherencyTestBase(string targetBranch, string channelName, List sourceAssets, + List childSourceAssets, List expectedDependencies, string coherentParent, bool allChecks) { var targetRepoName = TestRepository.TestRepo3Name; var sourceRepoName = TestRepository.TestRepo2Name; @@ -180,14 +198,22 @@ public async Task NonBatchedGitHubFlowCoherencyTestBase(string targetBranch, str TestContext.WriteLine($"Waiting on PR to be opened in {targetRepoUri}"); - await CheckNonBatchedGitHubPullRequest(sourceRepoName, targetRepoName, targetBranch, expectedDependencies, reposFolder.Directory, isCompleted: allChecks, isUpdated: false); + await CheckNonBatchedGitHubPullRequest( + sourceRepoName, + targetRepoName, + targetBranch, + expectedDependencies, + reposFolder.Directory, + isCompleted: allChecks, + isUpdated: false, + cleanUp: true); } } } } - public async Task NonBatchedGitHubFlowCoherencyOnlyTestBase(string targetBranch, string channelName, IImmutableList sourceAssets, - IImmutableList childSourceAssets, List expectedNonCoherencyDependencies, + public async Task NonBatchedGitHubFlowCoherencyOnlyTestBase(string targetBranch, string channelName, List sourceAssets, + List childSourceAssets, List expectedNonCoherencyDependencies, List expectedCoherencyDependencies, string coherentParent) { var targetRepoName = TestRepository.TestRepo3Name; @@ -243,7 +269,15 @@ public async Task NonBatchedGitHubFlowCoherencyOnlyTestBase(string targetBranch, TestContext.WriteLine($"Waiting on PR to be opened in {targetRepoUri}"); - await CheckNonBatchedGitHubPullRequest(sourceRepoName, targetRepoName, targetBranch, expectedNonCoherencyDependencies, reposFolder.Directory, isCompleted: true, isUpdated: false); + await CheckNonBatchedGitHubPullRequest( + sourceRepoName, + targetRepoName, + targetBranch, + expectedNonCoherencyDependencies, + reposFolder.Directory, + isCompleted: true, + isUpdated: false, + cleanUp: false); await RunGitAsync("checkout", targetBranch); await RunGitAsync("pull", "origin", targetBranch); @@ -259,14 +293,22 @@ public async Task NonBatchedGitHubFlowCoherencyOnlyTestBase(string targetBranch, TestContext.WriteLine($"Waiting on PR to be opened in {targetRepoUri}"); var expectedPRTitle = $"[{targetBranch}] Update dependencies to ensure coherency"; - await CheckGitHubPullRequest(expectedPRTitle, targetRepoName, targetBranch, expectedCoherencyDependencies, reposFolder.Directory, isCompleted: false, isUpdated: false); + await CheckGitHubPullRequest( + expectedPRTitle, + targetRepoName, + targetBranch, + expectedCoherencyDependencies, + reposFolder.Directory, + isCompleted: false, + isUpdated: false, + cleanUp: true); } } } } } - public async Task NonBatchedUpdatingGitHubFlowTestBase(string targetBranch, string channelName, IImmutableList source1Assets, IImmutableList source1AssetsUpdated, + public async Task NonBatchedUpdatingGitHubFlowTestBase(string targetBranch, string channelName, List source1Assets, List source1AssetsUpdated, List expectedDependencies, List expectedUpdatedDependencies, bool allChecks = false) { var targetRepoName = TestRepository.TestRepo2Name; @@ -307,7 +349,15 @@ public async Task NonBatchedUpdatingGitHubFlowTestBase(string targetBranch, stri await TriggerSubscriptionAsync(subscription1Id.Value); TestContext.WriteLine($"Waiting on PR to be opened in {targetRepoUri}"); - await CheckNonBatchedGitHubPullRequest(sourceRepoName, targetRepoName, targetBranch, expectedDependencies, reposFolder.Directory, allChecks); + await CheckNonBatchedGitHubPullRequest( + sourceRepoName, + targetRepoName, + targetBranch, + expectedDependencies, + reposFolder.Directory, + allChecks, + isUpdated: false, + cleanUp: false); TestContext.WriteLine("Set up another build for intake into target repository"); Build build2 = await CreateBuildAsync(sourceRepoUri, sourceBranch, TestRepository.CoherencyTestRepo2Commit, Source2BuildNumber, source1AssetsUpdated); @@ -317,7 +367,15 @@ public async Task NonBatchedUpdatingGitHubFlowTestBase(string targetBranch, stri await TriggerSubscriptionAsync(subscription1Id.Value); TestContext.WriteLine($"Waiting for PR to be updated in {targetRepoUri}"); - await CheckNonBatchedGitHubPullRequest(sourceRepoName, targetRepoName, targetBranch, expectedUpdatedDependencies, reposFolder.Directory, allChecks, true); + await CheckNonBatchedGitHubPullRequest( + sourceRepoName, + targetRepoName, + targetBranch, + expectedUpdatedDependencies, + reposFolder.Directory, + allChecks, + isUpdated: true, + cleanUp: false); // Then remove the second build from the channel, trigger the sub again, and it should revert back to the original dependency set TestContext.Write("Remove the build from the channel and verify that the original dependencies are restored"); @@ -328,13 +386,21 @@ public async Task NonBatchedUpdatingGitHubFlowTestBase(string targetBranch, stri TestContext.WriteLine($"Waiting for PR to be updated in {targetRepoUri}"); - await CheckNonBatchedGitHubPullRequest(sourceRepoName, targetRepoName, targetBranch, expectedDependencies, reposFolder.Directory, allChecks, true); + await CheckNonBatchedGitHubPullRequest( + sourceRepoName, + targetRepoName, + targetBranch, + expectedDependencies, + reposFolder.Directory, + allChecks, + isUpdated: true, + cleanUp: true); } } } } - public static async Task NonBatchedUpdatingAzDoFlowTestBase(string targetBranch, string channelName, IImmutableList sourceAssets, IImmutableList updatedSourceAssets, + public static async Task NonBatchedUpdatingAzDoFlowTestBase(string targetBranch, string channelName, List sourceAssets, List updatedSourceAssets, List expectedDependencies, List expectedUpdatedDependencies) { var targetRepoName = TestRepository.TestRepo2Name; @@ -374,7 +440,15 @@ public static async Task NonBatchedUpdatingAzDoFlowTestBase(string targetBranch, await TriggerSubscriptionAsync(subscription1Id.Value); TestContext.WriteLine($"Waiting on PR to be opened in {targetRepoUri}"); - await CheckNonBatchedAzDoPullRequest(sourceRepoName, targetRepoName, targetBranch, expectedDependencies, reposFolder.Directory, isCompleted: false, isUpdated: false); + await CheckNonBatchedAzDoPullRequest( + sourceRepoName, + targetRepoName, + targetBranch, + expectedDependencies, + reposFolder.Directory, + isCompleted: false, + isUpdated: false, + cleanUp: false); TestContext.WriteLine("Set up another build for intake into target repository"); Build build2 = await CreateBuildAsync(sourceRepoUri, sourceBranch, TestRepository.CoherencyTestRepo2Commit, Source2BuildNumber, updatedSourceAssets); @@ -383,7 +457,15 @@ public static async Task NonBatchedUpdatingAzDoFlowTestBase(string targetBranch, await TriggerSubscriptionAsync(subscription1Id.Value); TestContext.WriteLine($"Waiting for PR to be updated in {targetRepoUri}"); - await CheckNonBatchedAzDoPullRequest(sourceRepoName, targetRepoName, targetBranch, expectedUpdatedDependencies, reposFolder.Directory, isCompleted: false, isUpdated: true); + await CheckNonBatchedAzDoPullRequest( + sourceRepoName, + targetRepoName, + targetBranch, + expectedUpdatedDependencies, + reposFolder.Directory, + isCompleted: false, + isUpdated: true, + cleanUp: false); // Then remove the second build from the channel, trigger the sub again, and it should revert back to the original dependency set TestContext.Write("Remove the build from the channel and verify that the original dependencies are restored"); @@ -393,13 +475,21 @@ public static async Task NonBatchedUpdatingAzDoFlowTestBase(string targetBranch, await TriggerSubscriptionAsync(subscription1Id.Value); TestContext.WriteLine($"Waiting for PR to be updated in {targetRepoUri}"); - await CheckNonBatchedAzDoPullRequest(sourceRepoName, targetRepoName, targetBranch, expectedDependencies, reposFolder.Directory, isCompleted: false, isUpdated: true); + await CheckNonBatchedAzDoPullRequest( + sourceRepoName, + targetRepoName, + targetBranch, + expectedDependencies, + reposFolder.Directory, + isCompleted: false, + isUpdated: true, + cleanUp: true); } } } } - public static async Task NonBatchedAzDoFlowTestBase(string targetBranch, string channelName, IImmutableList sourceAssets, + public static async Task NonBatchedAzDoFlowTestBase(string targetBranch, string channelName, List sourceAssets, List expectedDependencies, bool allChecks = false, bool isFeedTest = false, string[] expectedFeeds = null, string[] notExpectedFeeds = null) { var targetRepoName = TestRepository.TestRepo2Name; @@ -441,13 +531,31 @@ public static async Task NonBatchedAzDoFlowTestBase(string targetBranch, string if (allChecks) { - await CheckNonBatchedAzDoPullRequest(sourceRepoName, targetRepoName, targetBranch, expectedDependencies, reposFolder.Directory, isCompleted: true, isUpdated: false); + await CheckNonBatchedAzDoPullRequest( + sourceRepoName, + targetRepoName, + targetBranch, + expectedDependencies, + reposFolder.Directory, + isCompleted: true, + isUpdated: false, + cleanUp: true); return; } if (isFeedTest) { - await CheckNonBatchedAzDoPullRequest(sourceRepoName, targetRepoName, targetBranch, expectedDependencies, reposFolder.Directory, isCompleted: false, isUpdated: false, expectedFeeds: expectedFeeds, notExpectedFeeds: notExpectedFeeds); + await CheckNonBatchedAzDoPullRequest( + sourceRepoName, + targetRepoName, + targetBranch, + expectedDependencies, + reposFolder.Directory, + isCompleted: false, + isUpdated: false, + cleanUp: true, + expectedFeeds: expectedFeeds, + notExpectedFeeds: notExpectedFeeds); return; } } diff --git a/test/ProductConstructionService.ScenarioTests/ObjectHelpers/BuildRefComparer.cs b/test/ProductConstructionService.ScenarioTests/ObjectHelpers/BuildRefComparer.cs index e5079747fa..48d87f026e 100644 --- a/test/ProductConstructionService.ScenarioTests/ObjectHelpers/BuildRefComparer.cs +++ b/test/ProductConstructionService.ScenarioTests/ObjectHelpers/BuildRefComparer.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; -using ProductConstructionService.Client.Models; +using Microsoft.DotNet.ProductConstructionService.Client.Models; namespace ProductConstructionService.ScenarioTests.ObjectHelpers; diff --git a/test/ProductConstructionService.ScenarioTests/ProductConstructionService.ScenarioTests.csproj b/test/ProductConstructionService.ScenarioTests/ProductConstructionService.ScenarioTests.csproj index 41cb7df177..04d142f29c 100644 --- a/test/ProductConstructionService.ScenarioTests/ProductConstructionService.ScenarioTests.csproj +++ b/test/ProductConstructionService.ScenarioTests/ProductConstructionService.ScenarioTests.csproj @@ -18,7 +18,7 @@ - + diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTestBase.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTestBase.cs index d2d18ec8e8..232084fa5d 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTestBase.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTestBase.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; @@ -16,8 +15,8 @@ using Newtonsoft.Json.Linq; using NuGet.Configuration; using NUnit.Framework; -using ProductConstructionService.Client; -using ProductConstructionService.Client.Models; +using Microsoft.DotNet.ProductConstructionService.Client; +using Microsoft.DotNet.ProductConstructionService.Client.Models; using ProductConstructionService.ScenarioTests.ObjectHelpers; [assembly: Parallelizable(ParallelScope.Fixtures)] @@ -182,7 +181,7 @@ private static async Task> SearchPullRequestsAsync(string repoU return prs; } - private static async Task> GetAzDoPullRequestAsync(int pullRequestId, string targetRepoName, string targetBranch, bool isUpdated, string? expectedPRTitle = null) + private static async Task> GetAzDoPullRequestAsync(int pullRequestId, string targetRepoName, string targetBranch, bool isUpdated, bool cleanUp, string? expectedPRTitle = null) { var repoUri = GetAzDoRepoUrl(targetRepoName); (var accountName, var projectName, var repoName) = AzureDevOpsClient.ParseRepoUri(repoUri); @@ -206,7 +205,7 @@ private static async Task> GetAzDoPullRequestA try { - JObject content = await TestParameters.AzDoClient.ExecuteAzureDevOpsAPIRequestAsync( + await TestParameters.AzDoClient.ExecuteAzureDevOpsAPIRequestAsync( HttpMethod.Patch, accountName, projectName, @@ -214,6 +213,11 @@ private static async Task> GetAzDoPullRequestA new NUnitLogger(), "{ \"status\" : \"abandoned\"}", logFailure: false); + + if (cleanUp) + { + await TestParameters.AzDoClient.DeleteBranchAsync(repoUri, pr.HeadBranch); + } } catch { @@ -228,30 +232,49 @@ private static async Task> GetAzDoPullRequestA throw new ScenarioTestException($"The created pull request for {targetRepoName} targeting {targetBranch} was not updated with subsequent subscriptions after creation"); } - protected async Task CheckBatchedGitHubPullRequest(string targetBranch, string[] sourceRepoNames, - string targetRepoName, List expectedDependencies, string repoDirectory) + protected async Task CheckBatchedGitHubPullRequest( + string targetBranch, + string[] sourceRepoNames, + string targetRepoName, + List expectedDependencies, + string repoDirectory, + bool cleanUp) { var repoNames = sourceRepoNames .Select(name => $"{TestParameters.GitHubTestOrg}/{name}") .OrderBy(s => s); var expectedPRTitle = $"[{targetBranch}] Update dependencies from {string.Join(", ", repoNames)}"; - await CheckGitHubPullRequest(expectedPRTitle, targetRepoName, targetBranch, expectedDependencies, repoDirectory, false, true); + await CheckGitHubPullRequest(expectedPRTitle, targetRepoName, targetBranch, expectedDependencies, repoDirectory, isCompleted: false, isUpdated: true, cleanUp); } - protected async Task CheckNonBatchedGitHubPullRequest(string sourceRepoName, string targetRepoName, string targetBranch, - List expectedDependencies, string repoDirectory, bool isCompleted = false, bool isUpdated = false) + protected async Task CheckNonBatchedGitHubPullRequest( + string sourceRepoName, + string targetRepoName, + string targetBranch, + List expectedDependencies, + string repoDirectory, + bool isCompleted, + bool isUpdated, + bool cleanUp) { var expectedPRTitle = $"[{targetBranch}] Update dependencies from {TestParameters.GitHubTestOrg}/{sourceRepoName}"; - await CheckGitHubPullRequest(expectedPRTitle, targetRepoName, targetBranch, expectedDependencies, repoDirectory, isCompleted, isUpdated); + await CheckGitHubPullRequest(expectedPRTitle, targetRepoName, targetBranch, expectedDependencies, repoDirectory, isCompleted, isUpdated, cleanUp); } protected static string GetCodeFlowPRName(string targetBranch, string sourceRepoName) => $"[{targetBranch}] Source code changes from {TestParameters.GitHubTestOrg}/{sourceRepoName}"; protected static string GetExpectedCodeFlowDependencyVersionEntry(string repo, string sha, int buildId) => $"Source Uri=\"{GetGitHubRepoUrl(repo)}\" Sha=\"{sha}\" BarId=\"{buildId}\" />"; - protected async Task CheckGitHubPullRequest(string expectedPRTitle, string targetRepoName, string targetBranch, - List expectedDependencies, string repoDirectory, bool isCompleted, bool isUpdated) + protected async Task CheckGitHubPullRequest( + string expectedPRTitle, + string targetRepoName, + string targetBranch, + List expectedDependencies, + string repoDirectory, + bool isCompleted, + bool isUpdated, + bool cleanUp) { TestContext.WriteLine($"Checking opened PR in {targetBranch} {targetRepoName}"); Octokit.PullRequest pullRequest = isUpdated @@ -262,13 +285,20 @@ protected async Task CheckGitHubPullRequest(string expectedPRTitle, string targe using (ChangeDirectory(repoDirectory)) { - await ValidatePullRequestDependencies(pullRequest.Head.Ref, expectedDependencies); + var cleanUpTask = cleanUp + ? CleanUpPullRequestAfter(TestParameters.GitHubTestOrg, targetRepoName, pullRequest) + : AsyncDisposable.Create(async () => await Task.CompletedTask); - if (isCompleted) + await using (cleanUpTask) { - TestContext.WriteLine($"Checking for automatic merging of PR in {targetBranch} {targetRepoName}"); + await ValidatePullRequestDependencies(pullRequest.Head.Ref, expectedDependencies); + + if (isCompleted) + { + TestContext.WriteLine($"Checking for automatic merging of PR in {targetBranch} {targetRepoName}"); - await WaitForMergedPullRequestAsync(targetRepoName, targetBranch); + await WaitForMergedPullRequestAsync(targetRepoName, targetBranch); + } } } } @@ -286,7 +316,17 @@ protected static async Task CheckBatchedAzDoPullRequest( .OrderBy(s => s); var expectedPRTitle = $"[{targetBranch}] Update dependencies from {string.Join(", ", repoNames)}"; - await CheckAzDoPullRequest(expectedPRTitle, targetRepoName, targetBranch, expectedDependencies, repoDirectory, complete, true, null, null); + await CheckAzDoPullRequest( + expectedPRTitle, + targetRepoName, + targetBranch, + expectedDependencies, + repoDirectory, + complete, + isUpdated: true, + cleanUp: true, + expectedFeeds: null, + notExpectedFeeds: null); } protected static async Task CheckNonBatchedAzDoPullRequest( @@ -295,14 +335,25 @@ protected static async Task CheckNonBatchedAzDoPullRequest( string targetBranch, List expectedDependencies, string repoDirectory, - bool isCompleted = false, - bool isUpdated = false, + bool isCompleted, + bool isUpdated, + bool cleanUp, string[]? expectedFeeds = null, string[]? notExpectedFeeds = null) { var expectedPRTitle = $"[{targetBranch}] Update dependencies from {TestParameters.AzureDevOpsAccount}/{TestParameters.AzureDevOpsProject}/{sourceRepoName}"; // TODO (https://github.com/dotnet/arcade-services/issues/3149): I noticed we are not passing isCompleted further down - when I put it there the tests started failing - but we should fix this - await CheckAzDoPullRequest(expectedPRTitle, targetRepoName, targetBranch, expectedDependencies, repoDirectory, false, isUpdated, expectedFeeds, notExpectedFeeds); + await CheckAzDoPullRequest( + expectedPRTitle, + targetRepoName, + targetBranch, + expectedDependencies, + repoDirectory, + false, + isUpdated, + cleanUp, + expectedFeeds, + notExpectedFeeds); } protected static async Task CheckAzDoPullRequest( @@ -313,13 +364,14 @@ protected static async Task CheckAzDoPullRequest( string repoDirectory, bool isCompleted, bool isUpdated, + bool cleanUp, string[]? expectedFeeds, string[]? notExpectedFeeds) { var targetRepoUri = GetAzDoApiRepoUrl(targetRepoName); TestContext.WriteLine($"Checking Opened PR in {targetBranch} {targetRepoUri} ..."); var pullRequestId = await GetAzDoPullRequestIdAsync(targetRepoName, targetBranch); - await using AsyncDisposableValue pullRequest = await GetAzDoPullRequestAsync(pullRequestId, targetRepoName, targetBranch, isUpdated, expectedPRTitle); + await using AsyncDisposableValue pullRequest = await GetAzDoPullRequestAsync(pullRequestId, targetRepoName, targetBranch, isUpdated, cleanUp, expectedPRTitle); var trimmedTitle = Regex.Replace(pullRequest.Value.Title, @"\s+", " "); trimmedTitle.Should().Be(expectedPRTitle); @@ -620,12 +672,12 @@ protected static async Task DeleteSubscriptionById(string subscriptionId return await RunDarcAsync("delete-subscriptions", "--id", subscriptionId, "--quiet"); } - protected static Task CreateBuildAsync(string repositoryUrl, string branch, string commit, string buildNumber, IImmutableList assets) + protected static Task CreateBuildAsync(string repositoryUrl, string branch, string commit, string buildNumber, List assets) { - return CreateBuildAsync(repositoryUrl, branch, commit, buildNumber, assets, ImmutableList.Empty); + return CreateBuildAsync(repositoryUrl, branch, commit, buildNumber, assets, []); } - protected static async Task CreateBuildAsync(string repositoryUrl, string branch, string commit, string buildNumber, IImmutableList assets, IImmutableList dependencies) + protected static async Task CreateBuildAsync(string repositoryUrl, string branch, string commit, string buildNumber, List assets, List dependencies) { Build build = await PcsApi.Builds.CreateAsync(new BuildData( commit: commit, @@ -832,7 +884,7 @@ protected static async Task DeleteBranchAsync(string branchName) await RunGitAsync("push", "origin", "--delete", branchName); } - protected static IImmutableList GetAssetData(string asset1Name, string asset1Version, string asset2Name, string asset2Version) + protected static List GetAssetData(string asset1Name, string asset1Version, string asset2Name, string asset2Version) { var location = @"https://pkgs.dev.azure.com/dnceng/public/_packaging/NotARealFeed/nuget/v3/index.json"; LocationType locationType = LocationType.NugetFeed; @@ -841,7 +893,7 @@ protected static IImmutableList GetAssetData(string asset1Name, strin AssetData asset2 = GetAssetDataWithLocations(asset2Name, asset2Version, location, locationType); - return ImmutableList.Create(asset1, asset2); + return [asset1, asset2]; } protected static AssetData GetAssetDataWithLocations( @@ -880,17 +932,23 @@ protected static AssetData GetAssetDataWithLocations( return asset; } - protected static IImmutableList GetSingleAssetData(string assetName, string assetVersion) + protected static List GetSingleAssetData(string assetName, string assetVersion) { - var asset = new AssetData(false) - { - Name = assetName, - Version = assetVersion, - Locations = ImmutableList.Create(new AssetLocationData(LocationType.NugetFeed) - { Location = @"https://pkgs.dev.azure.com/dnceng/public/_packaging/NotARealFeed/nuget/v3/index.json" }) - }; - - return ImmutableList.Create(asset); + return + [ + new AssetData(false) + { + Name = assetName, + Version = assetVersion, + Locations = + [ + new AssetLocationData(LocationType.NugetFeed) + { + Location = @"https://pkgs.dev.azure.com/dnceng/public/_packaging/NotARealFeed/nuget/v3/index.json" + } + ] + } + ]; } protected static async Task SetRepositoryPolicies(string repoUri, string branchName, string[]? policyParams = null) @@ -963,16 +1021,35 @@ protected static async Task ValidateGithubMaestroCheckRunsSuccessful(strin protected static string GetTestChannelName([CallerMemberName] string testName = "") { - return $"c{testName}_{Guid.NewGuid().ToString().Substring(0, 16)}"; + return $"Test {testName} {Guid.NewGuid().ToString().Substring(0, 16)}"; } protected static string GetTestBranchName([CallerMemberName] string testName = "") { - return $"b{testName}_{Guid.NewGuid().ToString().Substring(0, 16)}"; + return $"test/{testName}/{Guid.NewGuid().ToString().Substring(0, 16)}"; } protected string GetUniqueAssetName(string packageName) { return $"{packageName}.{_packageNameSalt}"; } + + protected static IAsyncDisposable CleanUpPullRequestAfter(string owner, string repo, Octokit.PullRequest pullRequest) + => AsyncDisposable.Create(async () => + { + try + { + var pullRequestUpdate = new Octokit.PullRequestUpdate + { + State = Octokit.ItemState.Closed + }; + + await GitHubApi.Repository.PullRequest.Update(owner, repo, pullRequest.Number, pullRequestUpdate); + await GitHubApi.Git.Reference.Delete(owner, repo, $"heads/{pullRequest.Head.Ref}"); + } + catch + { + // Closed already + } + }); } diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_AzDoFlow.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_AzDoFlow.cs index 14447e06b1..28b842743e 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_AzDoFlow.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_AzDoFlow.cs @@ -1,10 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; using Microsoft.DotNet.DarcLib.Models.Darc; using NUnit.Framework; -using ProductConstructionService.Client.Models; +using Microsoft.DotNet.ProductConstructionService.Client.Models; namespace ProductConstructionService.ScenarioTests; @@ -14,9 +13,9 @@ namespace ProductConstructionService.ScenarioTests; [NonParallelizable] internal class ScenarioTests_AzDoFlow : TestLogic { - private IImmutableList _source1Assets = null; - private IImmutableList _source2Assets = null; - private IImmutableList _source1AssetsUpdated = null; + private List _source1Assets = null; + private List _source2Assets = null; + private List _source1AssetsUpdated = null; private List _expectedAzDoDependenciesSource1 = null; private List _expectedAzDoDependenciesSource2 = null; private List _expectedAzDoDependenciesSource1Updated = null; @@ -156,7 +155,7 @@ public async Task Darc_AzDoFlow_FeedFlow() string[] expectedFeeds = [proxyFeed, azdoFeed1, azdoFeed3]; string[] notExpectedFeeds = [regularFeed, azdoFeed2, buildContainer]; - IImmutableList feedFlowSourceAssets = + List feedFlowSourceAssets = [ GetAssetDataWithLocations(GetUniqueAssetName("Foo"), "1.1.0", proxyFeed, LocationType.NugetFeed), GetAssetDataWithLocations(GetUniqueAssetName("Bar"), "2.1.0", azdoFeed1, LocationType.NugetFeed), diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Builds.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Builds.cs index bd5641330a..7152237e16 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Builds.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Builds.cs @@ -1,11 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; using FluentAssertions; +using Microsoft.DotNet.ProductConstructionService.Client.Models; using NUnit.Framework; using NUnit.Framework.Internal; -using ProductConstructionService.Client.Models; namespace ProductConstructionService.ScenarioTests; @@ -20,7 +19,7 @@ internal class ScenarioTests_Builds : ScenarioTestBase private const string SourceCommit = "123456"; private const string SourceBranch = "master"; - private IImmutableList _sourceAssets; + private List _sourceAssets; [SetUp] public void SetUp() diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_CodeFlow.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_CodeFlow.cs index 699adbd419..04fae2bc79 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_CodeFlow.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_CodeFlow.cs @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Microsoft.DotNet.ProductConstructionService.Client.Models; using NUnit.Framework; -using ProductConstructionService.Client.Models; #nullable enable diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Dependencies.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Dependencies.cs index dc05506db3..37a33c635c 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Dependencies.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_Dependencies.cs @@ -1,12 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; using FluentAssertions; using NUnit.Framework; using NUnit.Framework.Internal; using NUnit.Framework.Legacy; -using ProductConstructionService.Client.Models; +using Microsoft.DotNet.ProductConstructionService.Client.Models; using ProductConstructionService.ScenarioTests.ObjectHelpers; namespace ProductConstructionService.ScenarioTests; @@ -32,9 +31,9 @@ public async Task ArcadeDependencies_EndToEnd() var targetBranch = GetTestBranchName(); var testChannelName = GetTestChannelName(); - IImmutableList source1Assets = GetAssetData(GetUniqueAssetName("Foo"), "1.1.0", GetUniqueAssetName("Bar"), "2.1.0"); - IImmutableList source2Assets = GetAssetData(GetUniqueAssetName("Pizza"), "3.1.0", GetUniqueAssetName("Hamburger"), "4.1.0"); - IImmutableList targetAssets = GetAssetData(GetUniqueAssetName("Source1"), "3.1.0", GetUniqueAssetName("Source2"), "4.1.0"); + List source1Assets = GetAssetData(GetUniqueAssetName("Foo"), "1.1.0", GetUniqueAssetName("Bar"), "2.1.0"); + List source2Assets = GetAssetData(GetUniqueAssetName("Pizza"), "3.1.0", GetUniqueAssetName("Hamburger"), "4.1.0"); + List targetAssets = GetAssetData(GetUniqueAssetName("Source1"), "3.1.0", GetUniqueAssetName("Source2"), "4.1.0"); var source1RepoUri = GetGitHubRepoUrl(source1RepoName); var source2RepoUri = GetGitHubRepoUrl(source2RepoName); var targetRepoUri = GetGitHubRepoUrl(targetRepoName); @@ -50,11 +49,11 @@ public async Task ArcadeDependencies_EndToEnd() Build build2 = await CreateBuildAsync(source2RepoUri, sourceBranch, sourceCommit, sourceBuildNumber, source2Assets); await AddBuildToChannelAsync(build2.Id, testChannelName); - ImmutableList dependencies = []; - var buildRef1 = new BuildRef(build1.Id, true, 1); - dependencies = dependencies.Add(buildRef1); - var buildRef2 = new BuildRef(build2.Id, true, 2); - dependencies = dependencies.Add(buildRef2); + List dependencies = + [ + new BuildRef(build1.Id, true, 1), + new BuildRef(build2.Id, true, 2) + ]; // Add the target build once, should populate the BuildDependencies table and calculate TimeToInclusion TestContext.WriteLine("Set up targetBuild in target repository"); diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_GitHubFlow.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_GitHubFlow.cs index 60be9d77fb..365e38f841 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_GitHubFlow.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_GitHubFlow.cs @@ -1,11 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; using Microsoft.DotNet.DarcLib.Models.Darc; using NUnit.Framework; using NUnit.Framework.Internal; -using ProductConstructionService.Client.Models; +using Microsoft.DotNet.ProductConstructionService.Client.Models; namespace ProductConstructionService.ScenarioTests; @@ -15,9 +14,9 @@ namespace ProductConstructionService.ScenarioTests; [Parallelizable] internal class ScenarioTests_GitHubFlow : TestLogic { - private IImmutableList _source1Assets = null; - private IImmutableList _source2Assets = null; - private IImmutableList _source1AssetsUpdated = null; + private List _source1Assets = null; + private List _source2Assets = null; + private List _source1AssetsUpdated = null; private List _expectedDependenciesSource1 = null; private List _expectedDependenciesSource2 = null; private List _expectedDependenciesSource1Updated = null; @@ -156,7 +155,7 @@ public async Task Darc_GitHubFlow_NonBatched_StrictCoherency() } ]; - IImmutableList sourceAssets = GetAssetData(GetUniqueAssetName("Foo"), "1.1.0", GetUniqueAssetName("Bar"), "2.1.0"); + List sourceAssets = GetAssetData(GetUniqueAssetName("Foo"), "1.1.0", GetUniqueAssetName("Bar"), "2.1.0"); await NonBatchedGitHubFlowTestBase( GetTestBranchName(), @@ -209,8 +208,8 @@ public async Task Darc_GitHubFlow_NonBatched_FailingCoherencyUpdate() }, ]; - IImmutableList sourceAssets = GetAssetData(GetUniqueAssetName("Foo"), "1.1.0", GetUniqueAssetName("Bar"), "2.1.0"); - IImmutableList childSourceAssets = GetAssetData(GetUniqueAssetName("Fzz"), "1.1.0", GetUniqueAssetName("ASD"), "1.1.1"); + List sourceAssets = GetAssetData(GetUniqueAssetName("Foo"), "1.1.0", GetUniqueAssetName("Bar"), "2.1.0"); + List childSourceAssets = GetAssetData(GetUniqueAssetName("Fzz"), "1.1.0", GetUniqueAssetName("ASD"), "1.1.1"); await NonBatchedGitHubFlowCoherencyTestBase( GetTestBranchName(), @@ -287,8 +286,8 @@ public async Task Darc_GitHubFlow_NonBatched_FailingCoherentOnlyUpdate() }, ]; - IImmutableList sourceAssets = GetAssetData(GetUniqueAssetName("A1"), "1.1.0", GetUniqueAssetName("A2"), "1.1.0"); - IImmutableList childSourceAssets = GetAssetData(GetUniqueAssetName("B1"), "2.1.0", GetUniqueAssetName("B2"), "2.1.0"); + List sourceAssets = GetAssetData(GetUniqueAssetName("A1"), "1.1.0", GetUniqueAssetName("A2"), "1.1.0"); + List childSourceAssets = GetAssetData(GetUniqueAssetName("B1"), "2.1.0", GetUniqueAssetName("B2"), "2.1.0"); await NonBatchedGitHubFlowCoherencyOnlyTestBase( GetTestBranchName(), diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_MergePolicies.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_MergePolicies.cs index 59f1d27797..287e1e8f56 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_MergePolicies.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_MergePolicies.cs @@ -1,10 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; using FluentAssertions; using NUnit.Framework; -using ProductConstructionService.Client.Models; +using Microsoft.DotNet.ProductConstructionService.Client.Models; namespace ProductConstructionService.ScenarioTests; @@ -70,7 +69,7 @@ public async Task AutoMergeFlowTestBase(string targetRepo, string sourceRepo, st var sourceBranch = "dependencyflow-tests"; var sourceCommit = "0b36b99e29b1751403e23cfad0a7dff585818051"; var sourceBuildNumber = _random.Next(int.MaxValue).ToString(); - ImmutableList sourceAssets = + List sourceAssets = [ new AssetData(true) { diff --git a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_SdkUpdate.cs b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_SdkUpdate.cs index b687a938f3..d7a5969827 100644 --- a/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_SdkUpdate.cs +++ b/test/ProductConstructionService.ScenarioTests/ScenarioTests/ScenarioTests_SdkUpdate.cs @@ -1,12 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Collections.Immutable; using FluentAssertions; using Microsoft.DotNet.DarcLib.Helpers; using Microsoft.DotNet.DarcLib.Models.Darc; using NUnit.Framework; -using ProductConstructionService.Client.Models; +using Microsoft.DotNet.ProductConstructionService.Client.Models; namespace ProductConstructionService.ScenarioTests; @@ -21,16 +20,16 @@ internal class ScenarioTests_SdkUpdate : ScenarioTestBase [TestCase(true)] public async Task ArcadeSdkUpdate_E2E(bool targetAzDO) { - var testChannelName = "Test Channel " + _random.Next(int.MaxValue); - const string sourceOrg = "maestro-auth-test"; + var testChannelName = GetTestChannelName(); + var targetBranch = GetTestBranchName(); + const string sourceRepo = "arcade"; - const string sourceRepoUri = $"https://github.com/{sourceOrg}/{sourceRepo}"; + const string sourceRepoUri = $"https://github.com/{TestRepository.TestOrg}/{sourceRepo}"; const string sourceBranch = "dependencyflow-tests"; - const string sourceCommit = "f3d51d2c9af2a3eb046fa54c5acdef9fb37db172"; const string newArcadeSdkVersion = "2.1.0"; var sourceBuildNumber = _random.Next(int.MaxValue).ToString(); - ImmutableList sourceAssets = + List sourceAssets = [ new AssetData(true) { @@ -38,21 +37,19 @@ public async Task ArcadeSdkUpdate_E2E(bool targetAzDO) Version = newArcadeSdkVersion } ]; - var targetRepo = "maestro-test2"; - var targetBranch = "test/" + _random.Next(int.MaxValue).ToString(); await using AsyncDisposableValue channel = await CreateTestChannelAsync(testChannelName); await using AsyncDisposableValue sub = - await CreateSubscriptionAsync(testChannelName, sourceRepo, targetRepo, targetBranch, "none", sourceOrg: sourceOrg, targetIsAzDo: targetAzDO); + await CreateSubscriptionAsync(testChannelName, sourceRepo, TestRepository.TestRepo2Name, targetBranch, "none", TestRepository.TestOrg, targetIsAzDo: targetAzDO); Build build = - await CreateBuildAsync(GetRepoUrl(sourceOrg, sourceRepo), sourceBranch, sourceCommit, sourceBuildNumber, sourceAssets); + await CreateBuildAsync(GetRepoUrl(TestRepository.TestOrg, sourceRepo), sourceBranch, TestRepository.ArcadeTestRepoCommit, sourceBuildNumber, sourceAssets); await using IAsyncDisposable _ = await AddBuildToChannelAsync(build.Id, testChannelName); using TemporaryDirectory repo = targetAzDO - ? await CloneAzDoRepositoryAsync(targetRepo) - : await CloneRepositoryAsync(targetRepo); + ? await CloneAzDoRepositoryAsync(TestRepository.TestRepo2Name) + : await CloneRepositoryAsync(TestRepository.TestRepo2Name); using (ChangeDirectory(repo.Directory)) { @@ -62,71 +59,83 @@ await RunDarcAsync("add-dependency", "--type", "toolset", "--repo", sourceRepoUri); await RunGitAsync("commit", "-am", "Add dependencies."); - await using IAsyncDisposable ___ = await PushGitBranchAsync("origin", targetBranch); + await using IAsyncDisposable __ = await PushGitBranchAsync("origin", targetBranch); await TriggerSubscriptionAsync(sub.Value); - var expectedTitle = $"[{targetBranch}] Update dependencies from {sourceOrg}/{sourceRepo}"; + var expectedTitle = $"[{targetBranch}] Update dependencies from {TestRepository.TestOrg}/{sourceRepo}"; DependencyDetail expectedDependency = new() { Name = DependencyFileManager.ArcadeSdkPackageName, Version = newArcadeSdkVersion, RepoUri = sourceRepoUri, - Commit = sourceCommit, + Commit = TestRepository.ArcadeTestRepoCommit, Type = DependencyType.Toolset, Pinned = false, }; string prHead; + IAsyncDisposable cleanUp; if (targetAzDO) { prHead = await CheckAzDoPullRequest( expectedTitle, - targetRepo, + TestRepository.TestRepo2Name, targetBranch, [expectedDependency], repo.Directory, isCompleted: false, isUpdated: false, + cleanUp: false, expectedFeeds: null, notExpectedFeeds: null); + + cleanUp = AsyncDisposable.Create(async () => + { + await TestParameters.AzDoClient.DeleteBranchAsync(GetAzDoRepoUrl(TestRepository.TestRepo2Name), prHead); + }); } else { - Octokit.PullRequest pr = await WaitForPullRequestAsync(targetRepo, targetBranch); + Octokit.PullRequest pr = await WaitForPullRequestAsync(TestRepository.TestRepo2Name, targetBranch); pr.Title.Should().BeEquivalentTo(expectedTitle); prHead = pr.Head.Ref; + + cleanUp = CleanUpPullRequestAfter(TestRepository.TestOrg, TestRepository.TestRepo2Name, pr); } - await CheckoutRemoteRefAsync(prHead); - - var dependencies = await RunDarcAsync("get-dependencies"); - var dependencyLines = dependencies.Split(['\n', '\r'], StringSplitOptions.RemoveEmptyEntries); - dependencyLines.Should().BeEquivalentTo( - [ - $"Name: {DependencyFileManager.ArcadeSdkPackageName}", - $"Version: {newArcadeSdkVersion}", - $"Repo: {sourceRepoUri}", - $"Commit: {sourceCommit}", - "Type: Toolset", - "Pinned: False", - ]); - - using TemporaryDirectory arcadeRepo = await CloneRepositoryAsync(sourceOrg, sourceRepo); - using (ChangeDirectory(arcadeRepo.Directory)) + await using (cleanUp) { - await CheckoutRemoteRefAsync(sourceCommit); + await CheckoutRemoteRefAsync(prHead); + + var dependencies = await RunDarcAsync("get-dependencies"); + var dependencyLines = dependencies.Split(['\n', '\r'], StringSplitOptions.RemoveEmptyEntries); + dependencyLines.Should().BeEquivalentTo( + [ + $"Name: {DependencyFileManager.ArcadeSdkPackageName}", + $"Version: {newArcadeSdkVersion}", + $"Repo: {sourceRepoUri}", + $"Commit: {TestRepository.ArcadeTestRepoCommit}", + "Type: Toolset", + "Pinned: False", + ]); + + using TemporaryDirectory arcadeRepo = await CloneRepositoryAsync(TestRepository.TestOrg, sourceRepo); + using (ChangeDirectory(arcadeRepo.Directory)) + { + await CheckoutRemoteRefAsync(TestRepository.ArcadeTestRepoCommit); + } + + var arcadeFiles = Directory.EnumerateFileSystemEntries(Path.Join(arcadeRepo.Directory, "eng", "common"), + "*", SearchOption.AllDirectories) + .Select(s => s.Substring(arcadeRepo.Directory.Length)) + .ToHashSet(); + var repoFiles = Directory.EnumerateFileSystemEntries(Path.Join(repo.Directory, "eng", "common"), + "*", SearchOption.AllDirectories) + .Select(s => s.Substring(repo.Directory.Length)) + .ToHashSet(); + + arcadeFiles.Should().BeEquivalentTo(repoFiles); } - - var arcadeFiles = Directory.EnumerateFileSystemEntries(Path.Join(arcadeRepo.Directory, "eng", "common"), - "*", SearchOption.AllDirectories) - .Select(s => s.Substring(arcadeRepo.Directory.Length)) - .ToHashSet(); - var repoFiles = Directory.EnumerateFileSystemEntries(Path.Join(repo.Directory, "eng", "common"), "*", - SearchOption.AllDirectories) - .Select(s => s.Substring(repo.Directory.Length)) - .ToHashSet(); - - arcadeFiles.Should().BeEquivalentTo(repoFiles); } } } diff --git a/test/ProductConstructionService.ScenarioTests/TestParameters.cs b/test/ProductConstructionService.ScenarioTests/TestParameters.cs index f4f102b191..6ad58d1119 100644 --- a/test/ProductConstructionService.ScenarioTests/TestParameters.cs +++ b/test/ProductConstructionService.ScenarioTests/TestParameters.cs @@ -8,10 +8,10 @@ using Microsoft.DotNet.DarcLib; using Microsoft.DotNet.DarcLib.Helpers; using Microsoft.DotNet.Internal.Testing.Utility; +using Microsoft.DotNet.ProductConstructionService.Client; using Microsoft.Extensions.Configuration; using NUnit.Framework; using Octokit.Internal; -using ProductConstructionService.Client; #nullable enable namespace ProductConstructionService.ScenarioTests; @@ -58,7 +58,7 @@ static TestParameters() PcsBaseUri = Environment.GetEnvironmentVariable("PCS_BASEURI") ?? userSecrets["PCS_BASEURI"] - ?? "https://product-construction-int.delightfuldune-c0f01ab0.westus2.azurecontainerapps.io/"; + ?? "https://product-construction-int.agreeablesky-499be9de.westus2.azurecontainerapps.io/"; pcsToken = Environment.GetEnvironmentVariable("PCS_TOKEN") ?? userSecrets["PCS_TOKEN"]; IsCI = Environment.GetEnvironmentVariable("DARC_IS_CI")?.ToLower() == "true"; diff --git a/test/ProductConstructionService.ScenarioTests/TestRepository.cs b/test/ProductConstructionService.ScenarioTests/TestRepository.cs index f091a5cf01..908158c586 100644 --- a/test/ProductConstructionService.ScenarioTests/TestRepository.cs +++ b/test/ProductConstructionService.ScenarioTests/TestRepository.cs @@ -5,15 +5,16 @@ namespace ProductConstructionService.ScenarioTests; internal class TestRepository { - internal static string TestRepo1Name => "maestro-test1"; - internal static string TestRepo2Name => "maestro-test2"; - internal static string TestRepo3Name => "maestro-test3"; - internal static string VmrTestRepoName => "maestro-test-vmr"; - internal static string SourceBranch => "master"; + internal const string TestOrg = "maestro-auth-test"; + internal const string TestRepo1Name = "maestro-test1"; + internal const string TestRepo2Name = "maestro-test2"; + internal const string TestRepo3Name = "maestro-test3"; + internal const string VmrTestRepoName = "maestro-test-vmr"; + internal const string SourceBranch = "master"; // This branch and commit data is special for the coherency test // It's required to make sure that the dependency tree is set up correctly in the repo without conflicting with other test cases - internal static string CoherencySourceBranch => "coherency-tree"; - internal static string CoherencyTestRepo1Commit => "cc1a27107a1f4c4bc5e2f796c5ef346f60abb404"; - internal static string CoherencyTestRepo2Commit => "8460158878d4b7568f55d27960d4453877523ea6"; + internal const string CoherencyTestRepo1Commit = "cc1a27107a1f4c4bc5e2f796c5ef346f60abb404"; + internal const string CoherencyTestRepo2Commit = "8460158878d4b7568f55d27960d4453877523ea6"; + internal const string ArcadeTestRepoCommit = "f3d51d2c9af2a3eb046fa54c5acdef9fb37db172"; } diff --git a/test/ProductConstructionService.WorkItem.Tests/FakeRedisCache.cs b/test/ProductConstructionService.WorkItem.Tests/FakeRedisCache.cs index 766f180b3d..e43da30349 100644 --- a/test/ProductConstructionService.WorkItem.Tests/FakeRedisCache.cs +++ b/test/ProductConstructionService.WorkItem.Tests/FakeRedisCache.cs @@ -8,7 +8,6 @@ internal class FakeRedisCache : IRedisCache { private string? _value; - public Task GetAsync() => Task.FromResult(_value); public Task SetAsync(string value, TimeSpan? expiration = null) { _value = value; @@ -17,4 +16,7 @@ public Task SetAsync(string value, TimeSpan? expiration = null) public Task TryDeleteAsync() => throw new NotImplementedException(); public Task TryGetAsync() => Task.FromResult(_value); + public Task GetAsync() => Task.FromResult(_value); + public Task GetAsync(string key) => throw new NotImplementedException(); + public IAsyncEnumerable GetKeysAsync(string pattern) => throw new NotImplementedException(); } diff --git a/test/SubscriptionActorService.Tests/PullRequestActorTests.cs b/test/SubscriptionActorService.Tests/PullRequestActorTests.cs index e07069d4f2..166bfc0005 100644 --- a/test/SubscriptionActorService.Tests/PullRequestActorTests.cs +++ b/test/SubscriptionActorService.Tests/PullRequestActorTests.cs @@ -17,12 +17,10 @@ using Microsoft.DotNet.ServiceFabric.ServiceHost; using Microsoft.DotNet.Services.Utility; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Microsoft.ServiceFabric.Actors; using Microsoft.VisualStudio.Services.Common; using Moq; using NUnit.Framework; -using ProductConstructionService.Client; using SubscriptionActorService.StateModel; using Asset = Maestro.Contracts.Asset; @@ -82,7 +80,6 @@ protected override void RegisterServices(IServiceCollection services) services.AddScoped(); services.AddTransient(); services.AddSingleton(_updateResolver.Object); - services.AddSingleton(Mock.Of()); _remoteFactory .Setup(f => f.CreateRemoteAsync(It.IsAny()))