Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync eng/common directory with azure-sdk-tools for PR 9699 #1787

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ parameters:
- name: PRMatrixIndirectFilters
type: object
default: []
- name: PRMatrixSparseIndirect
type: boolean
default: true
# Mappings to OS name required at template compile time by 1es pipeline templates
- name: Pools
type: object
Expand Down Expand Up @@ -142,7 +145,8 @@ jobs:
-Filters '${{ join(''',''', parameters.MatrixFilters) }}', 'container=^$', 'SupportedClouds=^$|${{ parameters.CloudConfig.Cloud }}', 'Pool=${{ pool.filter }}' `
-IndirectFilters '${{ join(''',''', parameters.PRMatrixIndirectFilters) }}' `
-Replace '${{ join(''',''', parameters.MatrixReplace) }}' `
-PackagesPerPRJob ${{ parameters.PRJobBatchSize }}
-PackagesPerPRJob ${{ parameters.PRJobBatchSize }} `
-SparseIndirect $${{ parameters.PRMatrixSparseIndirect }}
displayName: Create ${{ pool.name }} PR Matrix
name: vm_job_matrix_pr_${{ pool.name }}

Expand Down
18 changes: 11 additions & 7 deletions eng/common/scripts/job-matrix/Create-PrJobMatrix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ param (
[Parameter(Mandatory = $False)][array] $Filters,
[Parameter(Mandatory = $False)][array] $IndirectFilters,
[Parameter(Mandatory = $False)][array] $Replace,
[Parameter(Mandatory = $False)][bool] $SparseIndirect = $true,
[Parameter(Mandatory = $False)][int] $PackagesPerPRJob = 10,
[Parameter()][switch] $CI = ($null -ne $env:SYSTEM_TEAMPROJECTID)
)
Expand Down Expand Up @@ -72,7 +73,8 @@ function QueuePop([ref]$queue) {

function GeneratePRMatrixForBatch {
param (
[Parameter(Mandatory = $true)][array] $Packages
[Parameter(Mandatory = $true)][array] $Packages,
[Parameter(Mandatory = $false)][bool] $FullSparseMatrix = $false
)

$OverallResult = @()
Expand All @@ -85,6 +87,8 @@ function GeneratePRMatrixForBatch {
$directBatch = $Packages[0].IncludedForValidation -eq $false
Write-Host "Generating matrix for $($directBatch ? 'direct' : 'indirect') packages"

$batchNamePrefix = $($directBatch ? 'b' : 'ib')

# The key here is that after we group the packages by the matrix config objects, we can use the first item's MatrixConfig
# to generate the matrix for the group, no reason to have to parse the key value backwards to get the matrix config.
$matrixBatchesByConfig = Group-ByObjectKey $Packages "CIMatrixConfigs"
Expand Down Expand Up @@ -134,10 +138,10 @@ function GeneratePRMatrixForBatch {
# we only need to modify the generated job name if there is more than one matrix config + batch
$matrixSuffixNecessary = $matrixBatchesByConfig.Keys.Count -gt 1

# if we are doing direct packages, we need to walk the batches and duplicate the matrix config for each batch, fully assigning
# if we are doing direct packages (or a full indirect matrix), we need to walk the batches and duplicate the matrix config for each batch, fully assigning
# the each batch's packages to the matrix config. This will generate a _non-sparse_ matrix for the incoming packages
if ($directBatch) {
$batchSuffixNecessary = $packageBatches.Length -gt 1
if ($directBatch -or $FullSparseMatrix) {
$batchSuffixNecessary = $packageBatches.Length -gt $($directBatch ? 1 : 0)
$batchCounter = 1

foreach ($batch in $packageBatches) {
Expand All @@ -155,7 +159,7 @@ function GeneratePRMatrixForBatch {
}

if ($batchSuffixNecessary) {
$outputItem["name"] = $outputItem["name"] + "_b$batchCounter"
$outputItem["name"] = $outputItem["name"] + "$batchNamePrefix$batchCounter"
}

$OverallResult += $outputItem
Expand All @@ -180,7 +184,7 @@ function GeneratePRMatrixForBatch {
}

if ($batchSuffixNecessary) {
$outputItem["name"] = $outputItem["name"] + "_ib$batchCounter"
$outputItem["name"] = $outputItem["name"] + "_$batchNamePrefix$batchCounter"
}
# now we need to take an item from the front of the matrix results, clone it, and add it to the back of the matrix results
# we will add the cloned version to OverallResult
Expand Down Expand Up @@ -236,7 +240,7 @@ if ($indirectPackages) {
foreach($artifact in $indirectPackages) {
Write-Host "-> $($artifact.ArtifactName)"
}
$OverallResult += GeneratePRMatrixForBatch -Packages $indirectPackages
$OverallResult += GeneratePRMatrixForBatch -Packages $indirectPackages -FullSparseMatrix (-not $SparseIndirect)
}
$serialized = SerializePipelineMatrix $OverallResult

Expand Down
Loading