diff options
| author | Jakob Lichtenberg (170957) <[email protected]> | 2024-06-28 11:43:03 -0700 |
|---|---|---|
| committer | Jakob Lichtenberg (170957) <[email protected]> | 2024-06-28 11:43:03 -0700 |
| commit | 341564fbc34d7521d03da4e91a0d4c2be9656410 (patch) | |
| tree | eb73dfda8e7c2cd3450c7d1cc8a73beafb914b0e /Build-SampleSet.ps1 | |
| parent | 57d4b2b5143a99d6e3a39100d183e26cac51da5b (diff) | |
| parent | b3af8c8f9bd508f54075da2f2516b31d05cd52c8 (diff) | |
Merge branch 'main' into user/jakobl/add_templatesuser/jakobl/add_templates
Diffstat (limited to 'Build-SampleSet.ps1')
| -rw-r--r-- | Build-SampleSet.ps1 | 90 |
1 files changed, 75 insertions, 15 deletions
diff --git a/Build-SampleSet.ps1 b/Build-SampleSet.ps1 index ffbb9b0b..adae8bb0 100644 --- a/Build-SampleSet.ps1 +++ b/Build-SampleSet.ps1 @@ -9,6 +9,14 @@ param( ) $root = Get-Location + +# launch developer powershell (if necessary to prevent multiple developer sessions) +if (-not $env:VSCMD_VER) { + Import-Module (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*\Common7\Tools\Microsoft.VisualStudio.DevShell.dll") + Enter-VsDevShell -VsInstallPath (Resolve-Path "$env:ProgramFiles\Microsoft Visual Studio\2022\*") + cd $root +} + $ThrottleFactor = 5 $LogicalProcessors = (Get-CIMInstance -Class 'CIM_Processor' -Verbose:$false).NumberOfLogicalProcessors @@ -45,27 +53,34 @@ finally { } # -# Determine build environment: 'GitHub', 'NuGet', 'EWDK', or 'WDK'. Only used to determine build number. +# Determine build environment: 'GitHub', 'NuGet', 'EWDK', or 'WDK'. # Determine build number (used for exclusions based on build number). Five digits. Say, '22621'. +# Determine NuGet package version (if applicable). +# Determine WDK vsix version. # $build_environment="" $build_number=0 +$nuget_package_version=0 +$vsix_version="" # -# WDK NuGet will require presence of a folder 'packages' -# -# -# Hack: In GitHub we do not have an environment variable where we can see WDK build number, so we have it hard coded. +# In Github we build using NuGet and get the version from packages and vsix version from env var set from the install vsix step. # -if (-not $env:GITHUB_REPOSITORY -eq '') { +if ($env:GITHUB_REPOSITORY) { $build_environment="GitHub" - $build_number=22621 + $nuget_package_version=([regex]'(?<=x64\.)(\d+\.)(\d+\.)(\d+\.)(\d+)').Matches((Get-Childitem .\packages\*WDK.x64* -Name)).Value + $build_number=$nuget_package_version.split('.')[2] + $vsix_version = $env:SAMPLES_VSIX_VERSION } # -# Hack: If user has hydrated nuget packages, then use those. That will be indicated by presence of a folder named .\packages. +# WDK NuGet will require presence of a folder 'packages'. The version is sourced from repo .\Env-Vars.ps1. # -elseif(Test-Path(".\packages")) { +# Hack: If user has hydrated nuget packages, then use those. That will be indicated by presence of a folder named '.\packages'. +# Further, we need to test that the directory has been hydrated using '.\packages\*'. +# +elseif(Test-Path(".\packages\*")) { $build_environment=("NuGet") - $build_number=26061 + $nuget_package_version=([regex]'(?<=x64\.)(\d+\.)(\d+\.)(\d+\.)(\d+)').Matches((Get-Childitem .\packages\*WDK.x64* -Name)).Value + $build_number=$nuget_package_version.split('.')[2] } # # EWDK sets environment variable BuildLab. For example 'ni_release_svc_prod1.22621.2428'. @@ -91,7 +106,19 @@ else { Write-Error "Could not determine build environment." exit 1 } - +# +# Get the vsix version from packages if not set +if (-not $vsix_version) { + $vsix_version = ls "${env:ProgramData}\Microsoft\VisualStudio\Packages\Microsoft.Windows.DriverKit,version=*" | Select -ExpandProperty Name + if ($vsix_version) { + $vsix_version = $vsix_version.split('=')[1] + } + else { + Write-Error "No version of the WDK VSIX could be found. The WDK VSIX is not installed." + exit 1 + } +} +# # # InfVerif_AdditionalOptions # @@ -145,6 +172,7 @@ $jresult = @{ SolutionsExcluded = 0 SolutionsUnsupported = 0 SolutionsFailed = 0 + SolutionsSporadic = 0 Results = @() FailSet = @() lock = [System.Threading.Mutex]::new($false) @@ -154,6 +182,8 @@ $SolutionsTotal = $sampleSet.Count * $Configurations.Count * $Platforms.Count Write-Output ("Build Environment: " + $build_environment) Write-Output ("Build Number: " + $build_number) +if (($build_environment -eq "GitHub") -or ($build_environment -eq "NuGet")) { Write-Output ("Nuget Package Version: " + $nuget_package_version) } +Write-Output ("WDK VSIX Version: " + $vsix_version) Write-Output ("Samples: " + $sampleSet.Count) Write-Output ("Configurations: " + $Configurations.Count + " (" + $Configurations + ")") Write-Output ("Platforms: " + $Platforms.Count + " (" + $Platforms + ")") @@ -174,6 +204,7 @@ Write-Output "S: Built and result was 'Succeeded'" Write-Output "E: Built and result was 'Excluded'" Write-Output "U: Built and result was 'Unsupported' (Platform and Configuration combination)" Write-Output "F: Built and result was 'Failed'" +Write-Output "O: Built and result was 'Sporadic'" Write-Output "" Write-Output "Building all combinations..." @@ -200,10 +231,12 @@ $SampleSet.GetEnumerator() | ForEach-Object -ThrottleLimit $ThrottleLimit -Paral foreach ($platform in $Platforms) { $thisunsupported = 0 $thisfailed = 0 + $thissporadic = 0 $thisexcluded = 0 $thissucceeded = 0 $thisresult = "Not run" $thisfailset = @() + $thissporadicset = @() if ($exclusionConfigurations.ContainsKey($sampleName) -and ($exclusionConfigurations[$sampleName].Split(';') | Where-Object { "$configuration|$platform" -like $_ })) { # Verbose @@ -222,8 +255,13 @@ $SampleSet.GetEnumerator() | ForEach-Object -ThrottleLimit $ThrottleLimit -Paral $thisfailed += 1 $thisresult = "Failed" } + elseif ($LASTEXITCODE -eq 2) { + $thissporadicset += "$sampleName $configuration|$platform" + $thissporadic += 1 + $thisresult = "Sporadic" + } else { - # ($LASTEXITCODE -eq 2) + # ($LASTEXITCODE -eq 3) $thisunsupported += 1 $thisresult = "Unsupported" } @@ -237,7 +275,9 @@ $SampleSet.GetEnumerator() | ForEach-Object -ThrottleLimit $ThrottleLimit -Paral ($using:jresult).SolutionsExcluded += $thisexcluded ($using:jresult).SolutionsUnsupported += $thisunsupported ($using:jresult).SolutionsFailed += $thisfailed + ($using:jresult).SolutionsSporadic += $thissporadic ($using:jresult).FailSet += $thisfailset + ($using:jresult).SporadicSet += $thissporadicset $SolutionsTotal = $using:SolutionsTotal $ThrottleLimit = $using:ThrottleLimit $SolutionsBuilt = ($using:jresult).SolutionsBuilt @@ -246,7 +286,7 @@ $SampleSet.GetEnumerator() | ForEach-Object -ThrottleLimit $ThrottleLimit -Paral $SolutionsPending = if ($SolutionsRemaining -ge $ThrottleLimit) { ($SolutionsRemaining - $ThrottleLimit) } else { 0 } $SolutionsBuiltPercent = [Math]::Round(100 * ($SolutionsBuilt / $using:SolutionsTotal)) $TBRP = "T:" + ($SolutionsTotal) + "; B:" + (($using:jresult).SolutionsBuilt) + "; R:" + ($SolutionsRunning) + "; P:" + ($SolutionsPending) - $rstr = "S:" + (($using:jresult).SolutionsSucceeded) + "; E:" + (($using:jresult).SolutionsExcluded) + "; U:" + (($using:jresult).SolutionsUnsupported) + "; F:" + (($using:jresult).SolutionsFailed) + $rstr = "S:" + (($using:jresult).SolutionsSucceeded) + "; E:" + (($using:jresult).SolutionsExcluded) + "; U:" + (($using:jresult).SolutionsUnsupported) + "; F:" + (($using:jresult).SolutionsFailed) + "; O:" + (($using:jresult).SolutionsSporadic) Write-Progress -Activity "Building combinations" -Status "$SolutionsBuilt of $using:SolutionsTotal combinations built ($SolutionsBuiltPercent%) | $TBRP | $rstr" -PercentComplete $SolutionsBuiltPercent } finally { @@ -265,6 +305,8 @@ $SampleSet.GetEnumerator() | ForEach-Object -ThrottleLimit $ThrottleLimit -Paral $sw.Stop() +Write-Output "" + if ($jresult.FailSet.Count -gt 0) { Write-Output "Some combinations were built with errors:" $jresult.FailSet = $jresult.FailSet | Sort-Object @@ -274,10 +316,27 @@ if ($jresult.FailSet.Count -gt 0) { $failConfiguration = $Matches[2] $failPlatform = $Matches[3] Write-Output "Build errors in Sample $failName; Configuration: $failConfiguration; Platform: $failPlatform {" - Get-Content "$LogFilesDirectory\$failName.$failConfiguration.$failPlatform.err" | Write-Output + Get-Content "$LogFilesDirectory\$failName.$failConfiguration.$failPlatform.0.err" | Write-Output Write-Output "} $failedSample" } Write-Error "Some combinations were built with errors." + Write-Output "" +} + +if ($jresult.SporadicSet.Count -gt 0) { + Write-Output "Some combinations were built with sporadic error:" + $jresult.SporadicSet = $jresult.SporadicSet | Sort-Object + foreach ($sporadicSample in $jresult.SporadicSet) { + $sporadicSample -match "^(.*) (\w*)\|(\w*)$" | Out-Null + $sporadicName = $Matches[1] + $sporadicConfiguration = $Matches[2] + $sporadicPlatform = $Matches[3] + Write-Output "Build sporadic errors in Sample $sporadicName; Configuration: $sporadicConfiguration; Platform: $sporadicPlatform {" + Get-Content "$LogFilesDirectory\$sporadicName.$sporadicConfiguration.$sporadicPlatform.0.err" | Write-Output + Write-Output "} $sporadicSample" + } + Write-Error "Some combinations were built with sporadic errors." + Write-Output "" } # Display timer statistics to host @@ -288,9 +347,9 @@ $SolutionsSucceeded = $jresult.SolutionsSucceeded $SolutionsExcluded = $jresult.SolutionsExcluded $SolutionsUnsupported = $jresult.SolutionsUnsupported $SolutionsFailed = $jresult.SolutionsFailed +$SolutionsSporadic = $jresult.SolutionsSporadic $Results = $jresult.Results -Write-Output "" Write-Output "Built all combinations." Write-Output "" Write-Output "Elapsed time: $min minutes, $seconds seconds." @@ -303,6 +362,7 @@ Write-Output "Succeeded: $SolutionsSucceeded" Write-Output "Excluded: $SolutionsExcluded" Write-Output "Unsupported: $SolutionsUnsupported" Write-Output "Failed: $SolutionsFailed" +Write-Output "Sporadic: $SolutionsSporadic" Write-Output "Log files directory: $LogFilesDirectory" Write-Output "Overview report: $reportFilePath" Write-Output "" |
