Skip to content
Open
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
35 changes: 29 additions & 6 deletions .azure/reusable-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,45 @@ jobs:
displayName: 'Install ProcDump'

- powershell: |
$ErrorActionPreference = 'Stop'
$curlDependencies = Get-Content "$(Build.SourcesDirectory)\.github\curl-dependencies.json" | ConvertFrom-Json
$version = $curlDependencies.opencppcoverage.version
$expectedHash = $curlDependencies.opencppcoverage.hash
$versionNumber = $version -replace '^release-', ''
$url = "https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/$version/OpenCppCoverageSetup-x64-$versionNumber.exe"
$setupPath = "$(Build.SourcesDirectory)\OpenCppCoverageSetup.exe"
& $(Build.SourcesDirectory)\scripts\Download-AndVerify.ps1 -Url $url -DestinationPath $setupPath -ExpectedHash $expectedHash
$process = Start-Process -FilePath $setupPath -ArgumentList '/VERYSILENT','/SUPPRESSMSGBOXES','/NORESTART' -Wait -PassThru
if ($process.ExitCode -ne 0) { throw "OpenCppCoverage installer failed with exit code $($process.ExitCode)" }
Remove-Item -Path $setupPath -Force
echo '##vso[task.prependpath]C:\Program Files\OpenCppCoverage'
if (-not (Test-Path "C:\Program Files\OpenCppCoverage\OpenCppCoverage.exe")) { throw "OpenCppCoverage install failed" }
$installDir = "C:\Program Files\OpenCppCoverage"
$installExe = Join-Path $installDir "OpenCppCoverage.exe"
$maxInstallAttempts = 3
$installed = $false
for ($attempt = 1; $attempt -le $maxInstallAttempts; $attempt++) {
Write-Host "OpenCppCoverage install attempt $attempt of $maxInstallAttempts"
& $(Build.SourcesDirectory)\scripts\Download-AndVerify.ps1 -Url $url -DestinationPath $setupPath -ExpectedHash $expectedHash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with $ErrorActionPreference set to stop, failures in any of the iterations would result in termination. Consider adding try catch to ensure actual retires.

$process = Start-Process -FilePath $setupPath -ArgumentList '/VERYSILENT','/SUPPRESSMSGBOXES','/NORESTART','/SP-' -Wait -PassThru
if ($null -eq $process) {
Write-Warning "OpenCppCoverage installer did not start (attempt $attempt)"
} elseif ($process.ExitCode -ne 0) {
Write-Warning "OpenCppCoverage installer exit code $($process.ExitCode) (attempt $attempt)"
}
if (Test-Path $installExe) {
$installed = $true
break
}
if ($attempt -lt $maxInstallAttempts) {
Start-Sleep -Seconds (5 * $attempt)
}
}
if (Test-Path $setupPath) { Remove-Item -Path $setupPath -Force -ErrorAction SilentlyContinue }
if (-not $installed) {
throw "OpenCppCoverage install failed after $maxInstallAttempts attempt(s): $installExe not found"
}
echo "##vso[task.prependpath]$installDir"
Write-Host "OpenCppCoverage installed at $installExe"
condition: and(eq('${{parameters.code_coverage}}', 'true'), ne('${{parameters.environment}}', 'ebpf_cicd_tests'))
name: set_up_opencppcoverage
displayName: 'Set up OpenCppCoverage and add to PATH'


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra line

- bash: |
echo "*** All environment variables ***"
env | sort
Expand Down
35 changes: 29 additions & 6 deletions .github/workflows/reusable-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,42 @@ jobs:
- name: Set up OpenCppCoverage and add to PATH
id: set_up_opencppcoverage
if: (inputs.code_coverage == true) && (!contains(inputs.environment, 'ebpf_cicd') && !contains(inputs.environment, '1ES')) && (steps.skip_check.outputs.should_skip != 'true')
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$curlDependencies = Get-Content "${{github.workspace}}\.github\curl-dependencies.json" | ConvertFrom-Json
$version = $curlDependencies.opencppcoverage.version
$expectedHash = $curlDependencies.opencppcoverage.hash
$versionNumber = $version -replace '^release-', ''
$url = "https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/$version/OpenCppCoverageSetup-x64-$versionNumber.exe"
$setupPath = "${{github.workspace}}\OpenCppCoverageSetup.exe"
& ${{github.workspace}}\scripts\Download-AndVerify.ps1 -Url $url -DestinationPath $setupPath -ExpectedHash $expectedHash
$process = Start-Process -FilePath $setupPath -ArgumentList '/VERYSILENT','/SUPPRESSMSGBOXES','/NORESTART' -Wait -PassThru
if ($process.ExitCode -ne 0) { throw "OpenCppCoverage installer failed with exit code $($process.ExitCode)" }
Remove-Item -Path $setupPath -Force
echo "C:\Program Files\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
if (-not (Test-Path "C:\Program Files\OpenCppCoverage\OpenCppCoverage.exe")) { throw "OpenCppCoverage install failed" }
$installDir = "C:\Program Files\OpenCppCoverage"
$installExe = Join-Path $installDir "OpenCppCoverage.exe"
$maxInstallAttempts = 3
$installed = $false
for ($attempt = 1; $attempt -le $maxInstallAttempts; $attempt++) {
Write-Host "OpenCppCoverage install attempt $attempt of $maxInstallAttempts"
& ${{github.workspace}}\scripts\Download-AndVerify.ps1 -Url $url -DestinationPath $setupPath -ExpectedHash $expectedHash
$process = Start-Process -FilePath $setupPath -ArgumentList '/VERYSILENT','/SUPPRESSMSGBOXES','/NORESTART','/SP-' -Wait -PassThru
if ($null -eq $process) {
Write-Warning "OpenCppCoverage installer did not start (attempt $attempt)"
} elseif ($process.ExitCode -ne 0) {
Write-Warning "OpenCppCoverage installer exit code $($process.ExitCode) (attempt $attempt)"
}
if (Test-Path $installExe) {
$installed = $true
break
}
if ($attempt -lt $maxInstallAttempts) {
Start-Sleep -Seconds (5 * $attempt)
}
}
if (Test-Path $setupPath) { Remove-Item -Path $setupPath -Force -ErrorAction SilentlyContinue }
if (-not $installed) {
throw "OpenCppCoverage install failed after $maxInstallAttempts attempt(s): $installExe not found"
}
echo $installDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Write-Host "OpenCppCoverage installed at $installExe"

- name: Configure Windows Error Reporting to make a local copy of any crashes that occur.
id: configure_windows_error_reporting
Expand Down
Loading