<# .DESCRIPTION Wrapper for installing dependencies, running and testing the project #> param( [switch]$clean ## clean build, wipe out all build artifacts , [switch]$install ## install mandatory packages ) function Invoke-CommandLine { [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingInvokeExpression', '', Justification = 'Usually this statement must be avoided (https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/avoid-using-invoke-expression?view=powershell-7.3), here it is OK as it does not execute unknown code.')] param ( [Parameter(Mandatory = $true, Position = 0)] [string]$CommandLine, [Parameter(Mandatory = $false, Position = 1)] [bool]$StopAtError = $true, [Parameter(Mandatory = $false, Position = 2)] [bool]$PrintCommand = $true, [Parameter(Mandatory = $false, Position = 3)] [bool]$Silent = $false ) if ($PrintCommand) { Write-Output "Executing: $CommandLine" } $global:LASTEXITCODE = 0 if ($Silent) { # Omit information stream (6) and stdout (1) Invoke-Expression $CommandLine 6>&1 | Out-Null } else { Invoke-Expression $CommandLine } if ($global:LASTEXITCODE -ne 0) { if ($StopAtError) { Write-Error "Command line call `"$CommandLine`" failed with exit code $global:LASTEXITCODE" } else { Write-Output "Command line call `"$CommandLine`" failed with exit code $global:LASTEXITCODE, continuing ..." } } } function Invoke-Bootstrap { # Download bootstrap scripts from external repository Invoke-RestMethod https://raw.githubusercontent.com/avengineers/bootstrap-installer/v1.13.0/install.ps1 | Invoke-Expression # Execute bootstrap script . .\.bootstrap\bootstrap.ps1 } function Remove-Path { param ( [Parameter(Mandatory = $true, Position = 0)] [string]$path ) if (Test-Path -Path $path -PathType Container) { Write-Output "Deleting directory '$path' ..." Remove-Item $path -Force -Recurse } elseif (Test-Path -Path $path -PathType Leaf) { Write-Output "Deleting file '$path' ..." Remove-Item $path -Force } } ## start of script # Always set the $InformationPreference variable to "Continue" globally, # this way it gets printed on execution and continues execution afterwards. $InformationPreference = "Continue" # Stop on first error $ErrorActionPreference = "Stop" Push-Location $PSScriptRoot Write-Output "Running in ${pwd}" try { if ($clean) { Remove-Path ".venv" } # bootstrap environment Invoke-Bootstrap if (-Not $install) { if ($clean) { Remove-Path "build" } # Run pypeline Invoke-CommandLine ".venv\Scripts\pypeline run" } } finally { Pop-Location } ## end of script