Skip to content

Commit

Permalink
[CI] Move the step that sets the vsts labels. (#21151)
Browse files Browse the repository at this point in the history
Keep working towards simplifying the configuration script.
  • Loading branch information
mandel-macaque authored Sep 3, 2024
1 parent 3b6a5c2 commit 87f28d5
Showing 1 changed file with 38 additions and 21 deletions.
59 changes: 38 additions & 21 deletions tools/devops/automation/scripts/VSTS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,41 @@ class BuildConfiguration {
}
}

static [string[]] $labelsOfInterest = $(
"build-package",
"skip-packages",
"skip-nugets",
"skip-signing",
"run-sample-tests",
"skip-packaged-macos-tests",
"run-packaged-macos-tests",
"skip-api-comparison",
"run-windows-tests",
"skip-windows-tests",
"skip-all-tests"
)

[void] SetLabelsFromPR ([PSCustomObject] $prInfo, [bool]$isPR) {
if ($prInfo) {
Write-Deubg "Setting VSTS labels from $($prInfo.labels)"
foreach ($l in [BuildConfiguration]::labelsOfInterest) {
$labelPresent = 1 -eq ($prInfo.labels | Where-Object { $_.name -eq "$l"}).Count
# We need to replace dashes with underscores, because bash can't access an environment variable with a dash in the name.
$lbl = $l.Replace('-', '_')
Write-Host "##vso[task.setvariable variable=$lbl;isOutput=true]$labelPresent"
}
} else {
Write-Debug "Not setting PR labels because there was not info provided."
}

# set if the build is a PR or not
if ($isPR) {
Write-Host "##vso[task.setvariable variable=prBuild;isOutput=true]True"
} else {
Write-Host "##vso[task.setvariable variable=prBuild;isOutput=true]False"
}
}

[PSCustomObject] Import([string] $configFile) {
if (-not (Test-Path -Path $configFile -PathType Leaf)) {
throw [System.InvalidOperationException]::new("Configuration file $configFile is missing")
Expand Down Expand Up @@ -459,29 +494,11 @@ class BuildConfiguration {
$tags.Add("$ref")

# set output variables based on the git labels
$labelsOfInterest = @(
"build-package",
"skip-packages",
"skip-nugets",
"skip-signing",
"run-sample-tests",
"skip-packaged-macos-tests",
"run-packaged-macos-tests",
"skip-api-comparison",
"run-windows-tests",
"skip-windows-tests",
"skip-all-tests"
)

foreach ($l in $labelsOfInterest) {
$labelPresent = 1 -eq ($prInfo.labels | Where-Object { $_.name -eq "$l"}).Count
# We need to replace dashes with underscores, because bash can't access an environment variable with a dash in the name.
$lbl = $l.Replace('-', '_')
Write-Host "##vso[task.setvariable variable=$lbl;isOutput=true]$labelPresent"
}
$this.SetLabelsFromPR($prInfo, $true)

Write-Host "##vso[task.setvariable variable=prBuild;isOutput=true]True"
} else {
# thee are not labels to add in a CI build and we will set the build as a ci build.
$this.SetLabelsFromPR($null, $false)
if ($tags.Contains("cronjob")) {
# debug so that we do know why we do not have ciBuild
Write-Debug "Skipping the tag 'ciBuild' because we are dealing with a translation build."
Expand Down

3 comments on commit 87f28d5

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.