mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-10-19 11:09:03 +02:00
ci: expand Windows feature fixtures and test Server 2022 (#2503)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
72e10af92d
commit
56137ffdc1
@@ -0,0 +1,64 @@
|
||||
param([int]$TestExitCode)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$prefix = "github.com/prometheus-community/windows_exporter/internal/collector/"
|
||||
$required = @($env:WINDOWS_EXPORTER_TEST_COLLECTORS.Split(','))
|
||||
$results = @{}
|
||||
$text = [System.Text.StringBuilder]::new()
|
||||
|
||||
$lines = if (Test-Path test-results.jsonl) { Get-Content test-results.jsonl } else { @() }
|
||||
foreach ($line in $lines) {
|
||||
try {
|
||||
$event = $line | ConvertFrom-Json -ErrorAction Stop
|
||||
} catch {
|
||||
[void]$text.AppendLine($line)
|
||||
continue
|
||||
}
|
||||
if ($event.Output) { [void]$text.Append($event.Output) }
|
||||
if (-not $event.Package -or -not $event.Package.StartsWith($prefix) -or $event.Test -ne "TestCollector") {
|
||||
continue
|
||||
}
|
||||
$name = $event.Package.Substring($prefix.Length)
|
||||
if (-not $results.ContainsKey($name)) {
|
||||
$results[$name] = @{ State = "not completed"; Notes = @() }
|
||||
}
|
||||
if ($event.Action -in @("pass", "skip", "fail")) {
|
||||
$results[$name].State = $event.Action
|
||||
}
|
||||
if ($event.Output -match 'collector \S+ (?:is not supported|has empty optional instance groups): (.+)') {
|
||||
$results[$name].Notes += $Matches[1].Trim()
|
||||
}
|
||||
}
|
||||
$text.ToString() | Set-Content test-output.txt -NoNewline -Encoding utf8
|
||||
|
||||
# Aborted tests must leave required fixtures visible as not run.
|
||||
foreach ($name in $required) {
|
||||
if (-not $results.ContainsKey($name)) {
|
||||
$results[$name] = @{ State = "not run"; Notes = @() }
|
||||
}
|
||||
}
|
||||
$testState = if (-not $lines) { "not run" } elseif ($TestExitCode -eq 0) { "passed" } else { "failed" }
|
||||
$summary = @(
|
||||
"### Windows feature tests: $env:WINDOWS_TEST_OS"
|
||||
""
|
||||
"Go suite: **$testState**. Required fixtures cannot skip. Empty optional instance groups remain listed below."
|
||||
""
|
||||
"| Collector | Required | Live test | Unavailable features / notes |"
|
||||
"| --- | --- | --- | --- |"
|
||||
)
|
||||
foreach ($name in $results.Keys | Sort-Object) {
|
||||
$fixture = if ($name -in $required) { "yes" } else { "no" }
|
||||
$state = switch ($results[$name].State) {
|
||||
"pass" { "passed" }
|
||||
"skip" { "unavailable" }
|
||||
"fail" { "failed" }
|
||||
default { $results[$name].State }
|
||||
}
|
||||
$notes = ($results[$name].Notes | Sort-Object -Unique) -join '; '
|
||||
$notes = $notes.Replace('|', '\|')
|
||||
$summary += "| $name | $fixture | $state | $notes |"
|
||||
}
|
||||
$summary | Set-Content feature-summary.md -Encoding utf8
|
||||
if ($env:GITHUB_STEP_SUMMARY) {
|
||||
$summary | Add-Content $env:GITHUB_STEP_SUMMARY
|
||||
}
|
||||
Reference in New Issue
Block a user