Skip to content

Commit

Permalink
Update go Language Settings and Detect-Api-Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Jan 30, 2025
1 parent 127671c commit 86b795c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
23 changes: 15 additions & 8 deletions eng/common/scripts/Detect-Api-Changes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,37 +104,44 @@ if (!($FindArtifactForApiReviewFn -and (Test-Path "Function:$FindArtifactForApiR
$responses = @{}

$packageProperties = Get-ChildItem -Recurse -Force "$configFileDir" `
| Where-Object { $_.Extension -eq '.json' }
| Where-Object { $_.Extension -eq '.json' -and $_.FullName -notmatch '\\_.*?\\' }

Write-Host "Package Properties: $($packageProperties.Count)"
Write-Host "$packageProperties"

foreach ($packagePropFile in $packageProperties)
{
$packageMetadata = Get-Content $packagePropFile | ConvertFrom-Json
Write-Host "Processing $($packageMetadata.ArtifactName)"
Write-Host "Package Metadata"
Write-Host $packageMetadata

$artifactOrModuleName = $packageMetadata.ArtifactName ?? $packageMetadata.Name
Write-Host "Processing $($artifactOrModuleName)"

$packages = &$FindArtifactForApiReviewFn $ArtifactPath $packageMetadata.ArtifactName
$packages = &$FindArtifactForApiReviewFn $ArtifactPath $artifactOrModuleName

if ($packages)
{
$pkgPath = $packages.Values[0]
$isRequired = Should-Process-Package -pkgPath $pkgPath -packageName $($packageMetadata.ArtifactName)
$isRequired = Should-Process-Package -pkgPath $pkgPath -packageName $($artifactOrModuleName)
Write-Host "Is API change detect required for $($packages.ArtifactName):$($isRequired)"
if ($isRequired -eq $True)
{
$filePath = $pkgPath.Replace($ArtifactPath , "").Replace("\", "/")
$respCode = Submit-Request -filePath $filePath -packageName $($packageMetadata.ArtifactName)
$respCode = Submit-Request -filePath $filePath -packageName $($artifactOrModuleName)
if ($respCode -ne '200')
{
$responses[$($packageMetadata.ArtifactName)] = $respCode
$responses[$($artifactOrModuleName)] = $respCode
}
}
else
{
Write-Host "Pull request does not have any change for $($packageMetadata.ArtifactName)). Skipping API change detect."
Write-Host "Pull request does not have any change for $($artifactOrModuleName)). Skipping API change detect."
}
}
else
{
Write-Host "No package is found in artifact path to find API changes for $($packageMetadata.ArtifactName)"
Write-Host "No package is found in artifact path to find API changes for $($artifactOrModuleName)"
}
}

Expand Down
1 change: 1 addition & 0 deletions eng/common/scripts/Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class PackageProps {
[string]$SdkType
[boolean]$IsNewSdk
[string]$ArtifactName
[string]$ModuleName
[string]$ReleaseStatus
# was this package purely included because other packages included it as an AdditionalValidationPackage?
[boolean]$IncludedForValidation
Expand Down
1 change: 1 addition & 0 deletions eng/common/scripts/Save-Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ foreach ($pkg in $allPackageProperties)
Write-Host "Package Version: $($pkg.Version)"
Write-Host "Package SDK Type: $($pkg.SdkType)"
Write-Host "Artifact Name: $($pkg.ArtifactName)"
Write-Host "Module Name: $($pkg.ModuleName)"
Write-Host "Release date: $($pkg.ReleaseStatus)"
$configFilePrefix = $pkg.Name

Expand Down
10 changes: 4 additions & 6 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function Get-GoModuleProperties($goModPath)
$pkgProp.SdkType = $sdkType

$pkgProp | Add-Member -NotePropertyName "VersionFile" -NotePropertyValue $versionFile
$pkgProp | Add-Member -NotePropertyName "ModuleName" -NotePropertyValue $modName
$pkgProp.ModuleName = $modName

return $pkgProp
}
Expand Down Expand Up @@ -101,13 +101,11 @@ function Get-AllPackageInfoFromRepo($serviceDirectory)
$searchPath = Join-Path $RepoRoot "sdk"
$pkgFiles = @()
if ($serviceDirectory) {
$searchPath = Join-Path $searchPath $serviceDirectory "go.mod"
[array]$pkgFiles = @(Get-ChildItem $searchPath)
} else {
# If service directory is not passed in, find all modules
[array]$pkgFiles = Get-ChildItem -Path $searchPath -Include "go.mod" -Recurse
$searchPath = Join-Path $searchPath $serviceDirectory
}

[array]$pkgFiles = Get-ChildItem -Path $searchPath -Include "go.mod" -Recurse

foreach ($pkgFile in $pkgFiles)
{
$modPropertes = Get-GoModuleProperties $pkgFile.DirectoryName
Expand Down

0 comments on commit 86b795c

Please sign in to comment.