From 8f85797753a55fce881318f0a1e242c2864dc173 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Fri, 23 Jul 2021 15:33:07 -0700 Subject: [PATCH] Add template for insertion creation and use for pr val --- azure-pipelines-official.yml | 50 ++++-------------------- azure-pipelines-pr-validation.yml | 21 ++++++++++ eng/pipelines/insert.yml | 65 +++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 42 deletions(-) create mode 100644 eng/pipelines/insert.yml diff --git a/azure-pipelines-official.yml b/azure-pipelines-official.yml index 049428c7868a4..550ec76156aa9 100644 --- a/azure-pipelines-official.yml +++ b/azure-pipelines-official.yml @@ -308,14 +308,6 @@ stages: pool: vmImage: windows-2019 steps: - - checkout: none - - - task: NuGetCommand@2 - displayName: 'Install RIT from Azure Artifacts' - inputs: - command: custom - arguments: 'install RoslynTools.VisualStudioInsertionTool -PreRelease -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json' - - powershell: | $response = Invoke-RestMethod -Headers @{Authorization = "Bearer $(System.AccessToken)"} "https://dev.azure.com/dnceng/internal/_apis/git/repositories/dotnet-roslyn/items?path=eng/config/PublishData.json&api-version=6.0" $branchName = "$(Build.SourceBranch)".Substring("refs/heads/".Length) @@ -343,40 +335,14 @@ stages: Write-Host "##vso[task.setvariable variable=VSBranchName]$($branchData.vsBranch)" displayName: Set Insertion Variables - - powershell: | - mv RoslynTools.VisualStudioInsertionTool.* RIT - .\RIT\tools\OneOffInsertion.ps1 ` - -autoComplete "$(Insertion.AutoComplete)" ` - -buildQueueName "$(Build.DefinitionName)" ` - -cherryPick "(default)" ` - -clientId "$(ClientId)" ` - -clientSecret "$(ClientSecret)" ` - -componentAzdoUri "$(System.CollectionUri)" ` - -componentBranchName "$(ComponentBranchName)" ` - -componentGitHubRepoName "dotnet/roslyn" ` - -componentName "Roslyn" ` - -componentProjectName "internal" ` - -createDraftPR "$(Insertion.CreateDraftPR)" ` - -defaultValueSentinel "(default)" ` - -dropPath "(default)" ` - -insertCore "(default)" ` - -insertDevDiv "(default)" ` - -insertionCount "1" ` - -insertToolset "$(Insertion.InsertToolset)" ` - -titlePrefix "$(Insertion.TitlePrefix)" ` - -titleSuffix "$(Insertion.TitleSuffix)" ` - -queueValidation "true" ` - -requiredValueSentinel "REQUIRED" ` - -reviewerGUID "6c25b447-1d90-4840-8fde-d8b22cb8733e" ` - -specificBuild "$(Build.BuildNumber)" ` - -updateAssemblyVersions "(default)" ` - -updateCoreXTLibraries "(default)" ` - -visualStudioBranchName "$(VSBranchName)" ` - -writePullRequest "prid.txt" ` - displayName: 'Run OneOffInsertion.ps1' - - - script: 'echo. && echo. && type "prid.txt" && echo. && echo.' - displayName: 'Report PR URL' + - template: eng/pipelines/insert.yml + parameters: + createDraftPR: $(Insertion.CreateDraftPR) + insertToolset: $(Insertion.InsertToolset) + componentBuildProjectName: internal + componentBranchName: $(ComponentBranchName) + vsBranchName: $(VSBranchName) + titlePrefix: $(Insertion.TitlePrefix) - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - template: eng\common\templates\post-build\post-build.yml diff --git a/azure-pipelines-pr-validation.yml b/azure-pipelines-pr-validation.yml index 7f1078fdc5928..e8372bf0b99fe 100644 --- a/azure-pipelines-pr-validation.yml +++ b/azure-pipelines-pr-validation.yml @@ -194,3 +194,24 @@ stages: - task: ms-vseng.MicroBuildTasks.521a94ea-9e68-468a-8167-6dcf361ea776.MicroBuildCleanup@1 displayName: Perform Cleanup Tasks condition: succeededOrFailed() + +- stage: insert + displayName: Create Insertion + dependsOn: + - build + + jobs: + - job: insert + displayName: Insert to VS + pool: + vmImage: windows-2019 + steps: + - template: eng/pipelines/insert.yml + parameters: + createDraftPR: true + insertToolset: $(InsertToolset) + componentBuildProjectName: DevDiv + componentBranchName: $(ComponentBranchName) + vsBranchName: $(VisualStudioBranchName) + titlePrefix: $(OptionalTitlePrefix) + diff --git a/eng/pipelines/insert.yml b/eng/pipelines/insert.yml new file mode 100644 index 0000000000000..80d4662e22b36 --- /dev/null +++ b/eng/pipelines/insert.yml @@ -0,0 +1,65 @@ +parameters: + # These are actually a booleans but must be defined as string. + # Parameters are evaluated at compile time, but all variables are strings at compile time. + # So in order to pass a parameter that comes from a variable these must be typed as string. + - name: createDraftPR + type: string + default: '' + - name: insertToolset + type: string + default: '' + + - name: componentBuildProjectName + type: string + - name: componentBranchName + type: string + - name: vsBranchName + type: string + - name: titlePrefix + type: string + default: '' + +steps: + - checkout: none + + - task: NuGetCommand@2 + displayName: 'Install RIT from Azure Artifacts' + inputs: + command: custom + arguments: 'install RoslynTools.VisualStudioInsertionTool -PreRelease -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json' + + - powershell: | + Write-Host "##vso[task.setvariable variable=Insertion.AutoComplete]$(-not ${{ parameters.createDraftPR }})" + mv RoslynTools.VisualStudioInsertionTool.* RIT + .\RIT\tools\OneOffInsertion.ps1 ` + -autoComplete "$(Insertion.AutoComplete)" ` + -buildQueueName "$(Build.DefinitionName)" ` + -cherryPick "(default)" ` + -clientId "$(ClientId)" ` + -clientSecret "$(ClientSecret)" ` + -componentAzdoUri "$(System.CollectionUri)" ` + -componentBranchName "${{ parameters.componentBranchName }}" ` + -componentGitHubRepoName "dotnet/roslyn" ` + -componentName "Roslyn" ` + -componentProjectName "${{ parameters.componentBuildProjectName }}" ` + -createDraftPR "${{ parameters.createDraftPR }}" ` + -defaultValueSentinel "(default)" ` + -dropPath "(default)" ` + -insertCore "(default)" ` + -insertDevDiv "(default)" ` + -insertionCount "1" ` + -insertToolset "${{ parameters.insertToolset }}" ` + -titlePrefix "${{ parameters.titlePrefix }}" ` + -titleSuffix "(default)" ` + -queueValidation "true" ` + -requiredValueSentinel "REQUIRED" ` + -reviewerGUID "6c25b447-1d90-4840-8fde-d8b22cb8733e" ` + -specificBuild "$(Build.BuildNumber)" ` + -updateAssemblyVersions "(default)" ` + -updateCoreXTLibraries "(default)" ` + -visualStudioBranchName "${{ parameters.vsBranchName }}" ` + -writePullRequest "prid.txt" ` + displayName: 'Run OneOffInsertion.ps1' + + - script: 'echo. && echo. && type "prid.txt" && echo. && echo.' + displayName: 'Report PR URL'