From 1831a55f19c58ac99775cdd3369c3a79e11f3e6c Mon Sep 17 00:00:00 2001 From: praveenkuttappan Date: Fri, 24 Sep 2021 14:41:05 -0400 Subject: [PATCH 1/6] Publis api file --- eng/pipelines/templates/steps/build.yml | 14 +++++++++----- eng/scripts/Language-Settings.ps1 | 20 ++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/eng/pipelines/templates/steps/build.yml b/eng/pipelines/templates/steps/build.yml index ec174fa4b38b..7b3b86b7b577 100644 --- a/eng/pipelines/templates/steps/build.yml +++ b/eng/pipelines/templates/steps/build.yml @@ -68,11 +68,6 @@ steps: node eng/tools/rush-runner.js unlink displayName: "Unlink dependencies" - - template: /eng/common/pipelines/templates/steps/create-apireview.yml - parameters: - Artifacts: ${{ parameters.Artifacts }} - ArtifactPath: $(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }} - - template: ../steps/generate-doc.yml parameters: ServiceDirectory: ${{parameters.ServiceDirectory}} @@ -86,6 +81,7 @@ steps: New-Item -Type Directory -Name $artifactName -Path $(Build.ArtifactStagingDirectory) > $null Copy-Item sdk/${{parameters.ServiceDirectory}}/**/$artifactName-[0-9]*.[0-9]*.[0-9]*.tgz $(Build.ArtifactStagingDirectory)/$artifactName Copy-Item sdk/${{parameters.ServiceDirectory}}/**/browser/$artifactName-[0-9]*.[0-9]*.[0-9]*.zip $(Build.ArtifactStagingDirectory)/$artifactName + Copy-Item sdk/${{parameters.ServiceDirectory}}/**/temp/*.api.json $(Build.ArtifactStagingDirectory)/$artifactName if ($${{ parameters.IncludeRelease }} -eq $true) { New-Item -Type Directory -Name documentation -Path $(Build.ArtifactStagingDirectory)/$artifactName > $null @@ -98,3 +94,11 @@ steps: parameters: ArtifactPath: '$(Build.ArtifactStagingDirectory)' ArtifactName: 'packages' + + - template: /eng/common/pipelines/templates/steps/create-apireview.yml + parameters: + Artifacts: ${{ parameters.Artifacts }} + + - template: /eng/common/pipelines/templates/steps/detect-api-changes.yml + parameters: + Artifacts: ${{ parameters.Artifacts }} diff --git a/eng/scripts/Language-Settings.ps1 b/eng/scripts/Language-Settings.ps1 index 8cefb93fe473..7079d800b369 100644 --- a/eng/scripts/Language-Settings.ps1 +++ b/eng/scripts/Language-Settings.ps1 @@ -404,25 +404,22 @@ Removed $($package.name) because of docs package validation failure on $(Get-Dat } # function is used to auto generate API View -function Find-javascript-Artifacts-For-Apireview($artifactDir, $packageName = "") +function Find-javascript-Artifacts-For-Apireview($artifactDir, $packageName) { - # Find api.json file in service temp directory - [regex]$pattern = "azure-" - $pkgName = $pattern.replace($packageName, "", 1) - $packageDir = Join-Path $artifactDir $pkgName "temp" - if (Test-Path $packageDir) + $artifactPath = Join-Path $artifactDir $packageName + if (Test-Path $artifactPath) { - Write-Host "Searching for *.api.json in path $($packageDir)" - $files = Get-ChildItem "${packageDir}" | Where-Object -FilterScript { $_.Name.EndsWith(".api.json") } + Write-Host "Searching for *.api.json in path $($artifactPath)" + $files = Get-ChildItem "${artifactPath}" | Where-Object -FilterScript { $_.Name.EndsWith(".api.json") } if (!$files) { - Write-Host "$($packageDir) does not have api review json for package" + Write-Host "$($artifactPath) does not have api review json for package" Write-Host "API Extractor must be enabled for $($packageName). Please ensure api-extractor.json is present in package directory and api extract script included in build script" return $null } elseif ($files.Count -ne 1) { - Write-Host "$($packageDir) should contain only one api review for $($packageName)" + Write-Host "$($artifactPath) should contain only one api review for $($packageName)" Write-Host "No of Packages $($files.Count)" return $null } @@ -431,8 +428,7 @@ function Find-javascript-Artifacts-For-Apireview($artifactDir, $packageName = "" { Write-Host "$($pkgName) does not have api review json" return $null - } - + } $packages = @{ $files[0].Name = $files[0].FullName } From 91919888bc0645e057da9e8519a206f2e19f5463 Mon Sep 17 00:00:00 2001 From: praveenkuttappan Date: Mon, 27 Sep 2021 13:47:19 -0400 Subject: [PATCH 2/6] Stage api review file to package artofact path and rename to include version info --- eng/pipelines/templates/steps/build.yml | 5 ++- eng/scripts/Language-Settings.ps1 | 4 +- eng/scripts/stage-api-review-file.ps1 | 50 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 eng/scripts/stage-api-review-file.ps1 diff --git a/eng/pipelines/templates/steps/build.yml b/eng/pipelines/templates/steps/build.yml index 7b3b86b7b577..389ce5dbbd12 100644 --- a/eng/pipelines/templates/steps/build.yml +++ b/eng/pipelines/templates/steps/build.yml @@ -81,7 +81,6 @@ steps: New-Item -Type Directory -Name $artifactName -Path $(Build.ArtifactStagingDirectory) > $null Copy-Item sdk/${{parameters.ServiceDirectory}}/**/$artifactName-[0-9]*.[0-9]*.[0-9]*.tgz $(Build.ArtifactStagingDirectory)/$artifactName Copy-Item sdk/${{parameters.ServiceDirectory}}/**/browser/$artifactName-[0-9]*.[0-9]*.[0-9]*.zip $(Build.ArtifactStagingDirectory)/$artifactName - Copy-Item sdk/${{parameters.ServiceDirectory}}/**/temp/*.api.json $(Build.ArtifactStagingDirectory)/$artifactName if ($${{ parameters.IncludeRelease }} -eq $true) { New-Item -Type Directory -Name documentation -Path $(Build.ArtifactStagingDirectory)/$artifactName > $null @@ -90,6 +89,10 @@ steps: } displayName: 'Copy Packages' + - script: | + eng/scripts/stage-api-review-file.ps1 -PackageInfoPath $(Build.ArtifactStagingDirectory)/PackageInfo -StagingDirectory $(Build.ArtifactStagingDirectory) + displayName: 'Copy API extracted files' + - template: /eng/common/pipelines/templates/steps/publish-artifact.yml parameters: ArtifactPath: '$(Build.ArtifactStagingDirectory)' diff --git a/eng/scripts/Language-Settings.ps1 b/eng/scripts/Language-Settings.ps1 index 7079d800b369..9408470e5b89 100644 --- a/eng/scripts/Language-Settings.ps1 +++ b/eng/scripts/Language-Settings.ps1 @@ -413,14 +413,14 @@ function Find-javascript-Artifacts-For-Apireview($artifactDir, $packageName) $files = Get-ChildItem "${artifactPath}" | Where-Object -FilterScript { $_.Name.EndsWith(".api.json") } if (!$files) { - Write-Host "$($artifactPath) does not have api review json for package" + Write-Host "$($packageName) does not have api review json" Write-Host "API Extractor must be enabled for $($packageName). Please ensure api-extractor.json is present in package directory and api extract script included in build script" return $null } elseif ($files.Count -ne 1) { Write-Host "$($artifactPath) should contain only one api review for $($packageName)" - Write-Host "No of Packages $($files.Count)" + Write-Host "No of files $($files.Count)" return $null } } diff --git a/eng/scripts/stage-api-review-file.ps1 b/eng/scripts/stage-api-review-file.ps1 new file mode 100644 index 000000000000..747eea5a1caa --- /dev/null +++ b/eng/scripts/stage-api-review-file.ps1 @@ -0,0 +1,50 @@ +param ( + [Parameter(mandatory = $true)] + $PackageInfoPath, + [Parameter(mandatory = $true)] + $StagingDirectory +) + +if (!((Test-Path $PackageInfoPath) -and (Test-Path $StagingDirectory))) +{ + Write-Error "Invalid parameter values. Pleaes verify values for these parameters." + exit 1 +} + +foreach($pkg in (Get-ChildItem -Path $PackageInfoPath "*.json")) +{ + $info = Get-Content -Path $pkg.FullName | ConvertFrom-Json + $apiFilePath = Join-Path $info.DirectoryPath "temp" + if (Test-Path $apiFilePath) + { + $apiFile = Get-ChildItem -Path $apiFilePath "*.api.json" + if ($apiFile) + { + if ($apiFile.Count -ne 1) + { + # Unlikely, but handling to avoid any issue in the future if more than one api file is present here + Write-Error "Detected more than one api extracted file in $apiFilePath" + exit 1 + } + + $pkgStagingDir = Join-Path $StagingDirectory $info.ArtifactName + if (!(Test-Path $pkgStagingDir)) + { + New-Item -Type Directory -Name $info.ArtifactName -Path $StagingDirectory > $null + } + $sourceFilePath = $apiFile[0].FullName + $targetFilePath = "$($pkgStagingDir)/$($info.ArtifactName)_$($info.Version).api.json" + Write-Host "Copying $($sourceFilePath) to $($targetFilePath)" + Copy-Item $sourceFilePath $targetFilePath + } + else + { + # Not an error is api-extractor is not cofigured/ required for a package + Write-Host "API extracted file is not present for package $($info.Name)" + } + } + else + { + Write-Host "Directory $($apiFilePath) is not present in package root to search for api-extracted file" + } +} From bb6b0022dc0b1c784ac14b46d7c60dcb5b74d71e Mon Sep 17 00:00:00 2001 From: praveenkuttappan Date: Mon, 27 Sep 2021 14:37:49 -0400 Subject: [PATCH 3/6] Fix error in yaml --- eng/pipelines/templates/steps/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/templates/steps/build.yml b/eng/pipelines/templates/steps/build.yml index 389ce5dbbd12..5dbb326f67e2 100644 --- a/eng/pipelines/templates/steps/build.yml +++ b/eng/pipelines/templates/steps/build.yml @@ -89,7 +89,7 @@ steps: } displayName: 'Copy Packages' - - script: | + - pwsh: | eng/scripts/stage-api-review-file.ps1 -PackageInfoPath $(Build.ArtifactStagingDirectory)/PackageInfo -StagingDirectory $(Build.ArtifactStagingDirectory) displayName: 'Copy API extracted files' From ad7f60912a697a5781aeab6fbf3d8aa520ec3122 Mon Sep 17 00:00:00 2001 From: praveenkuttappan Date: Mon, 27 Sep 2021 15:09:06 -0400 Subject: [PATCH 4/6] Dummy change to verify api change detection --- sdk/template/template/src/configurationClient.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/template/template/src/configurationClient.ts b/sdk/template/template/src/configurationClient.ts index 0cae1c9f3c49..418beedfe7d2 100644 --- a/sdk/template/template/src/configurationClient.ts +++ b/sdk/template/template/src/configurationClient.ts @@ -119,7 +119,7 @@ export class ConfigurationClient { * @param options - optional configuration for the operation */ public async getConfigurationSetting( - key: string, + key1: string, options?: GetConfigurationSettingOptions ): Promise; @@ -131,7 +131,7 @@ export class ConfigurationClient { * @param options - optional configuration for the operation */ public async getConfigurationSetting( - setting: ConfigurationSetting, + setting1: ConfigurationSetting, options?: GetConfigurationSettingOptions ): Promise; From 9d72c848d22fc2b4a69725c38aee754f0b683fb8 Mon Sep 17 00:00:00 2001 From: praveenkuttappan Date: Mon, 27 Sep 2021 15:19:20 -0400 Subject: [PATCH 5/6] Dummy change --- sdk/template/template/review/template.api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/template/template/review/template.api.md b/sdk/template/template/review/template.api.md index 3ee61bc94c0a..505ede091302 100644 --- a/sdk/template/template/review/template.api.md +++ b/sdk/template/template/review/template.api.md @@ -11,8 +11,8 @@ import { TokenCredential } from '@azure/core-http'; // @public export class ConfigurationClient { constructor(endpointUrl: string, credential: TokenCredential, options?: ConfigurationClientOptions); - getConfigurationSetting(key: string, options?: GetConfigurationSettingOptions): Promise; - getConfigurationSetting(setting: ConfigurationSetting, options?: GetConfigurationSettingOptions): Promise; + getConfigurationSetting(key1: string, options?: GetConfigurationSettingOptions): Promise; + getConfigurationSetting(setting1: ConfigurationSetting, options?: GetConfigurationSettingOptions): Promise; } // @public From 007d68d5311e30b5b56d617bd6d95739c6bd69c2 Mon Sep 17 00:00:00 2001 From: praveenkuttappan Date: Mon, 27 Sep 2021 15:30:23 -0400 Subject: [PATCH 6/6] Revert dummy change --- sdk/template/template/review/template.api.md | 4 ++-- sdk/template/template/src/configurationClient.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/template/template/review/template.api.md b/sdk/template/template/review/template.api.md index 505ede091302..3ee61bc94c0a 100644 --- a/sdk/template/template/review/template.api.md +++ b/sdk/template/template/review/template.api.md @@ -11,8 +11,8 @@ import { TokenCredential } from '@azure/core-http'; // @public export class ConfigurationClient { constructor(endpointUrl: string, credential: TokenCredential, options?: ConfigurationClientOptions); - getConfigurationSetting(key1: string, options?: GetConfigurationSettingOptions): Promise; - getConfigurationSetting(setting1: ConfigurationSetting, options?: GetConfigurationSettingOptions): Promise; + getConfigurationSetting(key: string, options?: GetConfigurationSettingOptions): Promise; + getConfigurationSetting(setting: ConfigurationSetting, options?: GetConfigurationSettingOptions): Promise; } // @public diff --git a/sdk/template/template/src/configurationClient.ts b/sdk/template/template/src/configurationClient.ts index 418beedfe7d2..0cae1c9f3c49 100644 --- a/sdk/template/template/src/configurationClient.ts +++ b/sdk/template/template/src/configurationClient.ts @@ -119,7 +119,7 @@ export class ConfigurationClient { * @param options - optional configuration for the operation */ public async getConfigurationSetting( - key1: string, + key: string, options?: GetConfigurationSettingOptions ): Promise; @@ -131,7 +131,7 @@ export class ConfigurationClient { * @param options - optional configuration for the operation */ public async getConfigurationSetting( - setting1: ConfigurationSetting, + setting: ConfigurationSetting, options?: GetConfigurationSettingOptions ): Promise;