mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 06:08:07 +00:00
[Windows] Stop SoftwareReport script if error (#4801)
* Stop SoftwareReport script if error * Validate blank versions * Fix tables parsing
This commit is contained in:
committed by
GitHub
parent
d4793cf476
commit
7518d04a3a
@@ -122,7 +122,7 @@ function Get-AndroidPlatformVersions {
|
|||||||
|
|
||||||
function Get-AndroidCommandLineToolsVersion {
|
function Get-AndroidCommandLineToolsVersion {
|
||||||
$commandLineTools = Get-AndroidSDKManagerPath
|
$commandLineTools = Get-AndroidSDKManagerPath
|
||||||
(& $commandLineTools --version | Out-String).Trim() -match "(?<version>^(\d+\.){1,}\d+$)" | Out-Null
|
(cmd /c "$commandLineTools --version 2>NUL" | Out-String).Trim() -match "(?<version>^(\d+\.){1,}\d+$)" | Out-Null
|
||||||
$commandLineToolsVersion = $Matches.Version
|
$commandLineToolsVersion = $Matches.Version
|
||||||
return $commandLineToolsVersion
|
return $commandLineToolsVersion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,28 +26,29 @@ function Get-RustVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Get-RustupVersion {
|
function Get-RustupVersion {
|
||||||
$version = [regex]::matches($(rustup --version), "\d+\.\d+\.\d+").Value
|
$rustupInfo = cmd /c "rustup --version 2>NUL"
|
||||||
return $version
|
$version = [regex]::matches($rustupInfo, "\d+\.\d+\.\d+").Value
|
||||||
|
return $version
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-RustCargoVersion {
|
function Get-RustCargoVersion {
|
||||||
$version = [regex]::matches($(cargo --version), "\d+\.\d+\.\d+").Value
|
$version = [regex]::matches($(cargo --version), "\d+\.\d+\.\d+").Value
|
||||||
return $version
|
return $version
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-RustdocVersion {
|
function Get-RustdocVersion {
|
||||||
$version = [regex]::matches($(rustdoc --version), "\d+\.\d+\.\d+").Value
|
$version = [regex]::matches($(rustdoc --version), "\d+\.\d+\.\d+").Value
|
||||||
return $version
|
return $version
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-RustfmtVersion {
|
function Get-RustfmtVersion {
|
||||||
$version = [regex]::matches($(rustfmt --version), "\d+\.\d+\.\d+").Value
|
$version = [regex]::matches($(rustfmt --version), "\d+\.\d+\.\d+").Value
|
||||||
return $version
|
return $version
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-RustClippyVersion {
|
function Get-RustClippyVersion {
|
||||||
$version = [regex]::matches($(cargo clippy --version), "\d+\.\d+\.\d+").Value
|
$version = [regex]::matches($(cargo clippy --version), "\d+\.\d+\.\d+").Value
|
||||||
return $version
|
return $version
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-BindgenVersion {
|
function Get-BindgenVersion {
|
||||||
@@ -122,10 +123,8 @@ function Get-ChocoVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Get-VcpkgVersion {
|
function Get-VcpkgVersion {
|
||||||
($(vcpkg version) | Out-String) -match "version (?<version>\d+\.\d+\.\d+)" | Out-Null
|
|
||||||
$vcpkgVersion = $Matches.Version
|
|
||||||
$commitId = git -C "C:\vcpkg" rev-parse --short HEAD
|
$commitId = git -C "C:\vcpkg" rev-parse --short HEAD
|
||||||
return "Vcpkg $vcpkgVersion (build from master \<$commitId>)"
|
return "Vcpkg (build from master \<$commitId>)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-NPMVersion {
|
function Get-NPMVersion {
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
$global:ErrorActionPreference = "Stop"
|
||||||
|
$global:ProgressPreference = "SilentlyContinue"
|
||||||
|
$ErrorView = "NormalView"
|
||||||
|
Set-StrictMode -Version Latest
|
||||||
|
|
||||||
Import-Module MarkdownPS
|
Import-Module MarkdownPS
|
||||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Android.psm1") -DisableNameChecking
|
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Android.psm1") -DisableNameChecking
|
||||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Browsers.psm1") -DisableNameChecking
|
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Browsers.psm1") -DisableNameChecking
|
||||||
@@ -294,4 +299,5 @@ if ($cachedImages) {
|
|||||||
$markdown += $cachedImages | New-MDTable
|
$markdown += $cachedImages | New-MDTable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Test-BlankElement -Markdown $markdown
|
||||||
$markdown | Out-File -FilePath "C:\InstalledSoftware.md"
|
$markdown | Out-File -FilePath "C:\InstalledSoftware.md"
|
||||||
|
|||||||
@@ -114,3 +114,50 @@ function Get-PathWithLink {
|
|||||||
$link = Get-LinkTarget($inputPath)
|
$link = Get-LinkTarget($inputPath)
|
||||||
return "${inputPath}${link}"
|
return "${inputPath}${link}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Test-BlankElement {
|
||||||
|
param(
|
||||||
|
[string] $Markdown
|
||||||
|
)
|
||||||
|
|
||||||
|
$splitByLines = $Markdown.Split("`n")
|
||||||
|
# Validate entry without version
|
||||||
|
$blankVersions = $splitByLines -match "^-" -notmatch "(OS|Image) Version|WSL|Vcpkg|\d\." | Out-String
|
||||||
|
|
||||||
|
# Validate tables with blank rows
|
||||||
|
$blankRows = ""
|
||||||
|
for($i = 0; $i -lt $splitByLines.Length; $i++) {
|
||||||
|
$addRows= $false
|
||||||
|
$table = @()
|
||||||
|
if ($splitByLines[$i].StartsWith("#") -and $splitByLines[$i+1].StartsWith("|")) {
|
||||||
|
$table += $splitByLines[$i,($i+1),($i+2)]
|
||||||
|
$i += 3
|
||||||
|
$current = $splitByLines[$i]
|
||||||
|
while ($current.StartsWith("|")) {
|
||||||
|
$isBlankRow = $current.Substring(1, $current.LastIndexOf("|") - 2).Split("|").Trim() -contains ""
|
||||||
|
if ($isBlankRow) {
|
||||||
|
$table += $current
|
||||||
|
$addRows = $true
|
||||||
|
}
|
||||||
|
$current = $splitByLines[++$i]
|
||||||
|
}
|
||||||
|
if ($addRows) {
|
||||||
|
$blankRows += $table | Out-String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display report
|
||||||
|
$isReport = $false
|
||||||
|
if ($blankVersions) {
|
||||||
|
Write-Host "Software list with blank version:`n${blankVersions}"
|
||||||
|
$isReport = $true
|
||||||
|
}
|
||||||
|
if ($blankRows) {
|
||||||
|
Write-Host "Tables with blank rows:`n${blankRows}"
|
||||||
|
$isReport = $true
|
||||||
|
}
|
||||||
|
if ($isReport) {
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user