From 78ce8e5a907fdbd2982a53a2aba71476a00e7ac2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Jun 2025 23:06:24 +0000 Subject: [PATCH 1/3] Initial plan for issue From 03bc9481e648a3d9ac43825ca8eacb0354ffd90a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Jun 2025 23:15:30 +0000 Subject: [PATCH 2/3] Update Azure pipeline conditions to respect canceled status Co-authored-by: benbp <1020379+benbp@users.noreply.github.com> --- eng/common/pipelines/templates/jobs/perf.yml | 2 +- eng/common/pipelines/templates/steps/detect-api-changes.yml | 2 +- eng/pipelines/apiview-review-gen-cadl.yml | 4 ++-- eng/pipelines/apiview-review-gen-typespec.yml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eng/common/pipelines/templates/jobs/perf.yml b/eng/common/pipelines/templates/jobs/perf.yml index 67c4accf380..4e63700cd81 100644 --- a/eng/common/pipelines/templates/jobs/perf.yml +++ b/eng/common/pipelines/templates/jobs/perf.yml @@ -208,7 +208,7 @@ jobs: inputs: targetPath: $(System.DefaultWorkingDirectory)/${{ parameters.Language }}-profile.zip artifactName: ${{ parameters.Language }}-profile.zip - condition: ${{ parameters.Profile }} + condition: and(succeeded(), ${{ parameters.Profile }}) - template: /eng/common/TestResources/remove-test-resources.yml parameters: diff --git a/eng/common/pipelines/templates/steps/detect-api-changes.yml b/eng/common/pipelines/templates/steps/detect-api-changes.yml index d997caa8491..3144f0b2f3d 100644 --- a/eng/common/pipelines/templates/steps/detect-api-changes.yml +++ b/eng/common/pipelines/templates/steps/detect-api-changes.yml @@ -10,7 +10,7 @@ steps: $apiChangeDetectRequestUrl = "https://apiview.dev/api/PullRequests/CreateAPIRevisionIfAPIHasChanges" echo "##vso[task.setvariable variable=ApiChangeDetectRequestUrl]$apiChangeDetectRequestUrl" displayName: "Set API change detect request URL" - condition: and(${{ parameters.Condition}}, eq(variables['ApiChangeDetectRequestUrl'], '')) + condition: and(succeeded(), ${{ parameters.Condition}}, eq(variables['ApiChangeDetectRequestUrl'], '')) - task: Powershell@2 inputs: diff --git a/eng/pipelines/apiview-review-gen-cadl.yml b/eng/pipelines/apiview-review-gen-cadl.yml index 221c7018fae..6a5d8e0f7c1 100644 --- a/eng/pipelines/apiview-review-gen-cadl.yml +++ b/eng/pipelines/apiview-review-gen-cadl.yml @@ -35,13 +35,13 @@ jobs: Write-Host "Reviews: $($reviews)" echo "##vso[task.setvariable variable=Reviews]$reviews" displayName: "Setup Reviews Variable" - condition: eq(variables['Reviews'], '') + condition: and(succeeded(), eq(variables['Reviews'], '')) - pwsh: | $url = "${{parameters.APIViewURL}}" echo "##vso[task.setvariable variable=APIViewURL]$url" displayName: "Setup APIViewURL Variable" - condition: eq(variables['APIViewURL'], '') + condition: and(succeeded(), eq(variables['APIViewURL'], '')) - task: Powershell@2 displayName: 'Generate APIView Token files' diff --git a/eng/pipelines/apiview-review-gen-typespec.yml b/eng/pipelines/apiview-review-gen-typespec.yml index 4efcb68a33d..1bf7f5f724c 100644 --- a/eng/pipelines/apiview-review-gen-typespec.yml +++ b/eng/pipelines/apiview-review-gen-typespec.yml @@ -35,13 +35,13 @@ jobs: Write-Host "Reviews: $($reviews)" echo "##vso[task.setvariable variable=Reviews]$reviews" displayName: "Setup Reviews Variable" - condition: eq(variables['Reviews'], '') + condition: and(succeeded(), eq(variables['Reviews'], '')) - pwsh: | $url = "${{parameters.APIViewURL}}" echo "##vso[task.setvariable variable=APIViewURL]$url" displayName: "Setup APIViewURL Variable" - condition: eq(variables['APIViewURL'], '') + condition: and(succeeded(), eq(variables['APIViewURL'], '')) - task: Powershell@2 displayName: 'Generate APIView Token files' From f0635a23a83cd5cae2c6b6e054d832cf4346a449 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 Aug 2025 21:11:00 +0000 Subject: [PATCH 3/3] Remove obsolete CADL pipeline files since CADL was renamed to TypeSpec Co-authored-by: praveenkuttappan <55455725+praveenkuttappan@users.noreply.github.com> --- eng/pipelines/apiview-review-gen-cadl.yml | 70 --------------- eng/scripts/Create-Apiview-Token-Cadl.ps1 | 103 ---------------------- 2 files changed, 173 deletions(-) delete mode 100644 eng/pipelines/apiview-review-gen-cadl.yml delete mode 100644 eng/scripts/Create-Apiview-Token-Cadl.ps1 diff --git a/eng/pipelines/apiview-review-gen-cadl.yml b/eng/pipelines/apiview-review-gen-cadl.yml deleted file mode 100644 index 6a5d8e0f7c1..00000000000 --- a/eng/pipelines/apiview-review-gen-cadl.yml +++ /dev/null @@ -1,70 +0,0 @@ -pr: none - -trigger: none - -parameters: - - name: Reviews - type: string - default: '[{"ReviewID":"","RevisionID":"","SourceRepoName":"","FileName":"","SourceBranchName":""}]' - - name: APIViewURL - type: string - default: 'https://apiview.dev' - -pool: - name: azsdk-pool - demands: ImageOverride -equals 24.04 - -variables: - NodeVersion: '18.x' - -jobs: -- job: CreateCadlReviewCodeFile - displayName: 'Create CADL API review token file' - - variables: - - template: /eng/pipelines/templates/variables/globals.yml - - steps: - - task: NodeTool@0 - inputs: - versionSpec: $(NodeVersion) - displayName: "Use Node $(NodeVersion)" - - - pwsh: | - $reviews = "${{ parameters.Reviews }}" - Write-Host "Reviews: $($reviews)" - echo "##vso[task.setvariable variable=Reviews]$reviews" - displayName: "Setup Reviews Variable" - condition: and(succeeded(), eq(variables['Reviews'], '')) - - - pwsh: | - $url = "${{parameters.APIViewURL}}" - echo "##vso[task.setvariable variable=APIViewURL]$url" - displayName: "Setup APIViewURL Variable" - condition: and(succeeded(), eq(variables['APIViewURL'], '')) - - - task: Powershell@2 - displayName: 'Generate APIView Token files' - inputs: - pwsh: true - filePath: $(Build.SourcesDirectory)/eng/scripts/Create-Apiview-Token-Cadl.ps1 - arguments: > - -Reviews "$(Reviews)" - -OutputDir "$(Build.ArtifactStagingDirectory)" - -WorkingDir "$(Pipeline.Workspace)" - -GitPat "$(github-access-token)" - - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: '$(Build.ArtifactStagingDirectory)' - artifactName: 'apiview' - - - task: Powershell@2 - displayName: 'Send Request to APIView to Update Token files' - condition: succeededOrFailed() - inputs: - pwsh: true - filePath: $(Build.SourcesDirectory)/eng/scripts/Apiview-Update-Generated-Review.ps1 - arguments: > - -BuildId $(Build.BuildId) - -ApiviewUpdateUrl "$(APIViewURL)/review/UpdateApiReview" diff --git a/eng/scripts/Create-Apiview-Token-Cadl.ps1 b/eng/scripts/Create-Apiview-Token-Cadl.ps1 deleted file mode 100644 index 5f620d4a48f..00000000000 --- a/eng/scripts/Create-Apiview-Token-Cadl.ps1 +++ /dev/null @@ -1,103 +0,0 @@ -[CmdletBinding()] -param ( - [ValidateNotNullOrEmpty()] - [string] $Reviews, - [ValidateNotNullOrEmpty()] - [string] $WorkingDir, - [ValidateNotNullOrEmpty()] - [string] $OutputDir, - [string] $GitPat = "" -) - -Set-StrictMode -Version 3 - -function Sparse-Checkout($branchName, $packagePath) -{ - git sparse-checkout init - git sparse-checkout set $packagePath - git checkout $branchName -} - -function Generate-Apiview-File($packagePath) -{ - Write-Host "Generating API review token file from path '$($packagePath)'" - Push-Location $packagePath - npm install - npm list - cadl compile . --emit=@azure-tools/cadl-apiview - Pop-Location -} - -function Stage-Apiview-File($packagePath, $reviewId, $revisionId) -{ - $tokenFilePath = Join-Path $packagePath "cadl-output" - $stagingReviewPath = Join-Path $OutputDir $reviewId - $stagingPath = Join-Path $stagingReviewPath $revisionId - Write-Host "Copying APIView file from '$($tokenFilePath)' to '$($stagingPath)'" - New-Item $stagingPath -ItemType Directory -Force - Get-ChildItem -Path $tokenFilePath -Filter *.json -recurse | Copy-Item -Destination $stagingPath - Write-Host "Files in Staging path $($stagingPath)" - ls $stagingPath -} - - -Write-Host "Review Details Json: $($Reviews)" -$revs = ConvertFrom-Json $Reviews -if ($revs) -{ - $prevRepo = "" - foreach ($r in $revs) - { - $reviewId = $r.ReviewID - $revisionId = $r.RevisionID - $packagePath = $r.FileName - $GitRepoName = $r.SourceRepoName - $branchName = $r.SourceBranchName - - if ($packagePath.StartsWith("/")) - { - $packagePath = $packagePath.Substring(1) - } - Write-Host "Generating API review for Review ID: '$($reviewId), Revision ID: '$($revisionId)" - Write-Host "URL to Repo: '$($GitRepoName), Branch name: '$($branchName), Package Path: '$($packagePath)" - - $repoDirectory = Split-Path $GitRepoName -leaf - # initialize git clone if current review is generated from different repo than previous one - if ($GitRepoName -ne $prevRepo) - { - $gitUrl = "https://github.com" - if ($GitPat) - { - $gitUrl = "https://$GitPat@github.com" - } - - $gitUrl = "$gitUrl/$GitRepoName.git" - if (Test-Path $repoDirectory) - { - Write-Host "Destination path '$($repoDirectory)' already exists in working directory. Deleting '$($repoDirectory)'" - Remove-Item $repoDirectory -Force -Recurse - } - git clone --no-checkout --filter=tree:0 $gitUrl - if ($LASTEXITCODE) { exit $LASTEXITCODE } - $prevRepo = $GitRepoName - } - - Push-Location $repoDirectory - try - { - Write-Host "GitHub Repo Name: '$($repoDirectory)" - # Sparse checkout package root path - Sparse-Checkout -branchName $branchName -packagePath $packagePath - # Generate API code file - Generate-Apiview-File -packagePath $packagePath - #Copy generated code file to stagin location - Stage-Apiview-File -packagePath $packagePath -reviewId $reviewId -revisionId $revisionId - } - finally - { - Pop-Location - } - } - - Write-Host "Generated and copied Api review token file to output directory" -} \ No newline at end of file