Skip to content

Commit

Permalink
just check for file under pkg folder
Browse files Browse the repository at this point in the history
  • Loading branch information
scbedd authored and azure-sdk committed Jul 17, 2024
1 parent a7fce41 commit 7d8c8f7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ steps:
inputs:
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1
arguments: >
-ServiceInput ${{parameters.ServiceDirectory}}
-ServiceDirectory ${{parameters.ServiceDirectory}}
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
pwsh: true
workingDirectory: $(Pipeline.Workspace)
Expand Down
18 changes: 4 additions & 14 deletions eng/common/scripts/Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,20 @@ function Get-PkgProperties
return $null
}

function Get-PackageFolderFromPath($file) {
$parts = $file -split "/"

if ($parts.Length -lt 3) {
return ""
}
return [System.IO.Path]::Combine($parts[0], $parts[1], $parts[2])
}

# Takes an input diff json file generated from eng/common/scripts/Generate-PR-Diff.ps1
# On PR builds, this function should be utilized instead of Get-AllPkgProperties.
function Get-PrPkgProperties([string]$InputDiffJson) {
$packagesWithChanges = @()

$allPackageProperties = Get-AllPkgProperties
$allPackageProperties = Get-AllPkgProperties -ServiceDirectory media
$diff = Get-Content $InputDiffJson | ConvertFrom-Json
$targetedFiles = $diff.ChangedFiles

foreach($pkg in $allPackageProperties)
{
foreach($file in $targetedFiles)
{
$pkgFolder = Get-PackageFolderFromPath($file)
if ($pkgFolder.EndsWith($pkg.ArtifactName)) {
$filePath = Resolve-Path (Join-Path $RepoRoot $file)
$shouldInclude = $filePath -like "$($pkg.DirectoryPath)*"
if ($shouldInclude) {
$packagesWithChanges += $pkg
}
}
Expand Down
17 changes: 10 additions & 7 deletions eng/common/scripts/Save-Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ In cases of collisions where track 2 packages (IsNewSdk = true) have the same
filename as track 1 packages (e.g. same artifact name or package name), the
track 2 package properties will be written.
.PARAMETER serviceInput
Service directory in which to search for packages, or file path ending in diff.json.
.PARAMETER serviceDirectory
Service directory in which to search for packages.
.PARAMETER prDiff
A file path leading to a file generated from Generate-PR-Diff.json. This parameter takes precedence over serviceDirectory, do not provide both.
.PARAMETER outDirectory
Output location (generally a package artifact directory in DevOps) for JSON
Expand All @@ -32,10 +35,10 @@ Verison property in that file.

[CmdletBinding()]
Param (
[Parameter(Mandatory=$True)]
[string] $serviceInput,
[string] $serviceDirectory,
[Parameter(Mandatory=$True)]
[string] $outDirectory,
[string] $prDiff,
[switch] $addDevVersion
)

Expand Down Expand Up @@ -95,11 +98,11 @@ $exportedPaths = @{}

$allPackageProperties = @()

if ($serviceInput.endswith("diff.json")) {
$allPackageProperties = Get-PrPkgProperties $serviceInput
if ($prDiff) {
$allPackageProperties = Get-PrPkgProperties $prDiff
}
else {
$allPackageProperties = Get-AllPkgProperties $serviceInput
$allPackageProperties = Get-AllPkgProperties $serviceDirectory
}

if ($allPackageProperties)
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/Verify-RestApiSpecLocation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function Verify-PackageVersion() {
if (-not (Test-Path -Path $PackageInfoDirectory)) {
# Call Save-Package-Properties.ps1 script to generate package info json files
$savePropertiesScriptPath = Join-Path -Path $PSScriptRoot "Save-Package-Properties.ps1"
& $savePropertiesScriptPath -serviceInput $ServiceDirectory -outDirectory $PackageInfoDirectory
& $savePropertiesScriptPath -serviceDirectory $ServiceDirectory -outDirectory $PackageInfoDirectory
}
}
$pkgPropPath = Join-Path -Path $PackageInfoDirectory "$PackageName.json"
Expand Down

0 comments on commit 7d8c8f7

Please sign in to comment.