Skip to content

Commit

Permalink
improve output to match build system (#3430)
Browse files Browse the repository at this point in the history
github actions and azure pipelines use different environment variables
we could use to identify the running system.
we should use this possibility to output formatting commands for the
given system.

---------

Co-authored-by: Christoph Blank <[email protected]>
Co-authored-by: Freddy Kristiansen <[email protected]>
  • Loading branch information
3 people authored Aug 26, 2024
1 parent 2eb7de4 commit 4c9b21a
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 57 deletions.
4 changes: 2 additions & 2 deletions AppHandling/Compile-AppInNavContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ function Compile-AppInBcContainer {
[switch] $CopyAppToSymbolsFolder,
[ValidateSet('Yes','No','NotSpecified')]
[string] $GenerateReportLayout = 'NotSpecified',
[switch] $AzureDevOps,
[switch] $gitHubActions,
[switch] $AzureDevOps = $bcContainerHelperConfig.IsAzureDevOps,
[switch] $gitHubActions = $bcContainerHelperConfig.IsGitHubActions,
[switch] $EnableCodeCop,
[switch] $EnableAppSourceCop,
[switch] $EnablePerTenantExtensionCop,
Expand Down
2 changes: 1 addition & 1 deletion AppHandling/Convert-ALCOutputToAzureDevOps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Function Convert-AlcOutputToDevOps {
[Parameter(Position=1)]
[ValidateSet('none','error','warning')]
[string] $FailOn,
[switch] $gitHubActions,
[switch] $gitHubActions = $bcContainerHelperConfig.IsGitHubActions,
[switch] $doNotWriteToHost,
[string] $basePath = ''
)
Expand Down
99 changes: 49 additions & 50 deletions AppHandling/Run-AlPipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ Param(
[switch] $installPerformanceToolkit,
[switch] $CopySymbolsFromContainer,
[switch] $UpdateDependencies,
[switch] $azureDevOps,
[switch] $gitLab,
[switch] $gitHubActions,
[switch] $azureDevOps = $bcContainerHelperConfig.IsAzureDevOps,
[switch] $gitLab = $bcContainerHelperConfig.IsGitLab,
[switch] $gitHubActions = $bcContainerHelperConfig.IsGitHubActions,
[ValidateSet('none','error','warning')]
[string] $failOn = "none",
[switch] $treatTestFailuresAsWarnings,
Expand Down Expand Up @@ -470,12 +470,12 @@ function GetInstalledAppIds {
else {
$installedApps = @()
}
Write-Host "::group::Installed Apps"
Write-GroupStart -Message "Installed Apps"
$installedApps | ForEach-Object {
Write-Host "- $($_.AppId):$($_.Name)"
"$($_.AppId)"
}
Write-Host "::endgroup::"
Write-GroupEnd
}

$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
Expand Down Expand Up @@ -662,7 +662,7 @@ else {

$escapeFromCops = $escapeFromCops -and ($enableCodeCop -or $enableAppSourceCop -or $enableUICop -or $enablePerTenantExtensionCop)

if ($gitHubActions) { Write-Host "::group::Parameters" }
Write-GroupStart -Message "Parameters"
Write-Host -ForegroundColor Yellow @'
_____ _
| __ \ | |
Expand Down Expand Up @@ -920,14 +920,14 @@ else {
if ($InstallMissingDependencies) {
Write-Host -ForegroundColor Yellow "InstallMissingDependencies override"; Write-Host $InstallMissingDependencies.ToString()
}
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd

$signApps = ($codeSignCertPfxFile -ne "")

Measure-Command {

if ( $artifactUrl -and !$reUseContainer -and $createContainer) {
if ($gitHubActions) { Write-Host "::group::Pulling generic image" }
Write-GroupStart -Message "Pulling generic image"
Measure-Command {
Write-Host -ForegroundColor Yellow @'
Expand All @@ -953,7 +953,7 @@ Write-Host "Pulling $useGenericImage"

Invoke-Command -ScriptBlock $DockerPull -ArgumentList $useGenericImage
} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nPulling generic image took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}

$err = $null
Expand All @@ -967,7 +967,7 @@ $testCountry = $_.Trim()
$testToolkitInstalled = $false

if ($useCompilerFolder) {
if ($gitHubActions) { Write-Host "::group::Creating CompilerFolder" }
Write-GroupStart -Message "Creating container"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _____ _ _ ______ _ _
Expand All @@ -978,7 +978,6 @@ if ($useCompilerFolder) {
\_____|_| \___|\__,_|\__|_|_| |_|\__, | \_____\___/|_| |_| |_| .__/|_|_|\___|_| |_| \___/|_|\__,_|\___|_|
__/ | | |
|___/ |_|
'@
}
else {
Expand Down Expand Up @@ -1117,9 +1116,9 @@ Measure-Command {
}

} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nCreating container took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd

if ($gitHubActions) { Write-Host "::group::Resolving dependencies" }
Write-GroupStart -Message "Resolving dependencies"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _
Expand Down Expand Up @@ -1196,10 +1195,10 @@ if ($previousApps) {
}
}

if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd

if ($installApps) {
if ($gitHubActions) { Write-Host "::group::Installing apps" }
Write-GroupStart -Message "Installing apps"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _
Expand Down Expand Up @@ -1298,7 +1297,7 @@ Measure-Command {
}

} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nInstalling apps took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}

if ($InstallMissingDependencies) {
Expand All @@ -1309,7 +1308,7 @@ $Parameters = @{
$installedAppIds = @(GetInstalledAppIds -useCompilerFolder $useCompilerFolder -filesOnly $filesOnly -compilerFolder $compilerFolder -packagesFolder $packagesFolder -Parameters $Parameters)
$missingAppDependencies = @($missingAppDependencies | Where-Object { $installedAppIds -notcontains $_ })
if ($missingAppDependencies) {
if ($gitHubActions) { Write-Host "::group::Installing app dependencies" }
Write-GroupStart -Message "Installing app dependencies"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _ _ _
|_ _| | | | | (_) | | | | (_)
Expand Down Expand Up @@ -1344,12 +1343,12 @@ Measure-Command {
}
Invoke-Command -ScriptBlock $InstallMissingDependencies -ArgumentList $Parameters
} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nInstalling app dependencies took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}
}

if ((($testCountry) -or !($appFolders -or $testFolders -or $bcptTestFolders)) -and !$doNotPublishApps -and ($installTestRunner -or $installTestFramework -or $installTestLibraries -or $installPerformanceToolkit)) {
if ($gitHubActions) { Write-Host "::group::Importing test toolkit" }
Write-GroupStart -Message "Importing test toolkit"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _ _ _ _ _
|_ _| | | (_) | | | | | | | | | (_) |
Expand Down Expand Up @@ -1384,10 +1383,10 @@ Measure-Command {
}
Invoke-Command -ScriptBlock $ImportTestToolkitToBcContainer -ArgumentList $Parameters
} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nImporting Test Toolkit took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd

if ($installTestApps) {
if ($gitHubActions) { Write-Host "::group::Installing test apps" }
Write-GroupStart -Message "Installing test apps"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _ _
|_ _| | | | | (_) | | | |
Expand Down Expand Up @@ -1449,7 +1448,7 @@ Measure-Command {
}

} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nInstalling test apps took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}
}

Expand All @@ -1462,7 +1461,7 @@ $Parameters = @{
$installedAppIds = @(GetInstalledAppIds -useCompilerFolder $useCompilerFolder -filesOnly $filesOnly -compilerFolder $compilerFolder -packagesFolder $packagesFolder -Parameters $Parameters)
$missingTestAppDependencies = @($missingTestAppDependencies | Where-Object { $installedAppIds -notcontains $_ })
if ($missingTestAppDependencies) {
if ($gitHubActions) { Write-Host "::group::Installing test app dependencies" }
Write-GroupStart -Message "Installing test app dependencies"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _ _ _ _ _
|_ _| | | | | (_) | | | | | | | | (_)
Expand Down Expand Up @@ -1492,13 +1491,13 @@ Measure-Command {
}
Invoke-Command -ScriptBlock $InstallMissingDependencies -ArgumentList $Parameters
} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nInstalling testapp dependencies took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}
}

if (-not $testCountry) {
if ($appFolders -or $testFolders -or $bcptTestFolders) {
if ($gitHubActions) { Write-Host "::group::Compiling apps" }
Write-GroupStart -Message "Compiling apps"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _
Expand Down Expand Up @@ -1528,8 +1527,8 @@ $sortedAppFolders+$sortedTestAppFolders | Select-Object -Unique | ForEach-Object
$app = $appFolders.Contains($folder)
if (($testApp -or $bcptTestApp) -and !$testToolkitInstalled -and !$doNotPublishApps -and ($installTestRunner -or $installTestFramework -or $installTestLibraries -or $installPerformanceToolkit)) {

if ($gitHubActions) { Write-Host "::endgroup::" }
if ($gitHubActions) { Write-Host "::group::Importing test toolkit" }
Write-GroupEnd
Write-GroupStart -Message "Importing test toolkit"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _ _ _ _ _
|_ _| | | (_) | | | | | | | | | (_) |
Expand Down Expand Up @@ -1567,8 +1566,8 @@ Measure-Command {
} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nImporting Test Toolkit took $([int]$_.TotalSeconds) seconds" }

if ($installTestApps) {
if ($gitHubActions) { Write-Host "::endgroup::" }
if ($gitHubActions) { Write-Host "::group::Installing test apps" }
Write-GroupEnd
Write-GroupStart -Message "Installing test apps"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _ _
|_ _| | | | | (_) | | | |
Expand Down Expand Up @@ -1631,7 +1630,7 @@ Measure-Command {

} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nInstalling test apps took $([int]$_.TotalSeconds) seconds" }
}
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd

if ($InstallMissingDependencies) {
$Parameters = @{
Expand All @@ -1641,7 +1640,7 @@ $Parameters = @{
$installedAppIds = @(GetInstalledAppIds -useCompilerFolder $useCompilerFolder -filesOnly $filesOnly -compilerFolder $compilerFolder -packagesFolder $packagesFolder -Parameters $Parameters)
$missingTestAppDependencies = @($missingTestAppDependencies | Where-Object { $installedAppIds -notcontains $_ })
if ($missingTestAppDependencies) {
if ($gitHubActions) { Write-Host "::group::Installing test app dependencies" }
Write-GroupStart -Message "Installing test app dependencies"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _ _ _ _ _
|_ _| | | | | (_) | | | | | | | | (_)
Expand Down Expand Up @@ -1671,11 +1670,11 @@ Measure-Command {
}
Invoke-Command -ScriptBlock $InstallMissingDependencies -ArgumentList $Parameters
} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nInstalling testapp dependencies took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}
}

if ($gitHubActions) { Write-Host "::group::Compiling test apps" }
Write-GroupStart -Message "Compiling test apps"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _
/ ____| (_) (_) | | | |
Expand Down Expand Up @@ -2134,10 +2133,10 @@ Write-Host -ForegroundColor Yellow @'
}
}
} | ForEach-Object { if ($appFolders -or $testFolders -or $bcptTestFolders) { Write-Host -ForegroundColor Yellow "`nCompiling apps$measureText took $([int]$_.TotalSeconds) seconds" } }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd

if ($signApps -and !$useDevEndpoint -and !$useCompilerFolder) {
if ($gitHubActions) { Write-Host "::group::Signing apps" }
Write-GroupStart -Message "Signing apps"
Write-Host -ForegroundColor Yellow @'
_____ _ _
/ ____(_) (_)
Expand All @@ -2163,15 +2162,15 @@ $apps | ForEach-Object {

}
} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nSigning apps took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}
}

$previousAppsInstalled = @()
if (!$useDevEndpoint) {

if ((!$doNotPerformUpgrade) -and ($previousApps)) {
if ($gitHubActions) { Write-Host "::group::Installing previous apps" }
Write-GroupStart -Message "Installing previous apps"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _
|_ _| | | | | (_) (_)
Expand Down Expand Up @@ -2216,11 +2215,11 @@ Measure-Command {
}

} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nInstalling apps took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}

if ((!$doNotPublishApps) -and ($apps+$testApps+$bcptTestApps)) {
if ($gitHubActions) { Write-Host "::group::Publishing apps" }
Write-GroupStart -Message "Publishing apps"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _
| __ \ | | | (_) | | (_)
Expand Down Expand Up @@ -2327,13 +2326,13 @@ $testApps+$bcptTestApps | ForEach-Object {
}

} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nPublishing apps took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}
}

if (!($doNotRunTests -and $doNotRunBcptTests)) {
if ($ImportTestDataInBcContainer) {
if ($gitHubActions) { Write-Host "::group::Importing test data" }
Write-GroupStart -Message "Importing test data"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _ _
|_ _| | | (_) | | | | | | | |
Expand Down Expand Up @@ -2372,13 +2371,13 @@ if (!$enableTaskScheduler) {
}
}
}
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}
$allPassed = $true
$resultsFile = Join-Path ([System.IO.Path]::GetDirectoryName($testResultsFile)) "$([System.IO.Path]::GetFileNameWithoutExtension($testResultsFile))$testCountry.xml"
$bcptResultsFile = Join-Path ([System.IO.Path]::GetDirectoryName($bcptTestResultsFile)) "$([System.IO.Path]::GetFileNameWithoutExtension($bcptTestResultsFile))$testCountry.json"
if (!$doNotRunTests -and (($testFolders) -or ($installTestApps))) {
if ($gitHubActions) { Write-Host "::group::Running tests" }
Write-GroupStart -Message "Running tests"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _
| __ \ (_) | | | |
Expand Down Expand Up @@ -2513,11 +2512,11 @@ if ($buildArtifactFolder -and (Test-Path $resultsFile)) {
Write-Host "Copying test results to output"
Copy-Item -Path $resultsFile -Destination $buildArtifactFolder -Force
}
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}

if (!$doNotRunBcptTests -and $bcptTestSuites) {
if ($gitHubActions) { Write-Host "::group::Running BCPT tests" }
Write-GroupStart -Message "Running BCPT tests"
Write-Host -ForegroundColor Yellow @'
_____ _ ____ _____ _____ _______ _ _
| __ \ (_) | _ \ / ____| __ \__ __| | | | |
Expand Down Expand Up @@ -2557,7 +2556,7 @@ if ($buildArtifactFolder -and (Test-Path $bcptResultsFile)) {
Write-Host "Copying bcpt test results to output"
Copy-Item -Path $bcptResultsFile -Destination $buildArtifactFolder -Force
}
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}

if (($gitLab -or $gitHubActions) -and !$allPassed) {
Expand All @@ -2569,7 +2568,7 @@ if (($gitLab -or $gitHubActions) -and !$allPassed) {
}

if ($buildArtifactFolder) {
if ($gitHubActions) { Write-Host "::group::Copy to build artifacts" }
Write-GroupStart -Message "Copy to build artifacts"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _ _ _ _ _ __ _
/ ____| | | | | (_) | | | | | (_)/ _| | |
Expand Down Expand Up @@ -2644,7 +2643,7 @@ Write-Host "Files in build artifacts folder:"
Get-ChildItem $buildArtifactFolder -Recurse | Where-Object {!$_.PSIsContainer} | ForEach-Object { Write-Host "$($_.FullName.Substring($buildArtifactFolder.Length+1)) ($($_.Length) bytes)" }

} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nCopying to Build Artifacts took $([int]$_.TotalSeconds) seconds" }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}

} catch {
Expand All @@ -2659,7 +2658,7 @@ if ($useCompilerFolder -and $compilerFolder) {
}

if ($createContainer -and !$keepContainer) {
if ($gitHubActions) { Write-Host "::group::Removing container" }
Write-GroupStart -Message "Removing container"
if (!($err)) {
Write-Host -ForegroundColor Yellow @'
_____ _ _ _
Expand Down Expand Up @@ -2694,7 +2693,7 @@ Measure-Command {
Invoke-Command -ScriptBlock $RemoveBcContainer -ArgumentList $Parameters
}
} | ForEach-Object { if (!($err)) { Write-Host -ForegroundColor Yellow "`nRemoving container took $([int]$_.TotalSeconds) seconds" } }
if ($gitHubActions) { Write-Host "::endgroup::" }
Write-GroupEnd
}

if ($warningsToShow) {
Expand Down
Loading

0 comments on commit 4c9b21a

Please sign in to comment.