mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-14 13:56:47 +00:00
Implement Software Report Base Module (#6707)
* Implement first version * fix tables rendering * Fix scripts * update test files * implement calculate image diff script * Polish code and make e2e validation * remove test files * render add and removed firstly
This commit is contained in:
48
helpers/software-report-base/Calculate-ImagesDiff.ps1
Normal file
48
helpers/software-report-base/Calculate-ImagesDiff.ps1
Normal file
@@ -0,0 +1,48 @@
|
||||
using module ./SoftwareReport.psm1
|
||||
using module ./SoftwareReport.Comparer.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Calculates the difference between two software reports and saves it to a file.
|
||||
.PARAMETER PreviousJsonReportPath
|
||||
Path to the previous software report.
|
||||
.PARAMETER CurrentJsonReportPath
|
||||
Path to the current software report.
|
||||
.PARAMETER OutputFile
|
||||
Path to the file where the difference will be saved.
|
||||
#>
|
||||
|
||||
Param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $PreviousJsonReportPath,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $CurrentJsonReportPath,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $OutputFile
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$global:ErrorView = "NormalView"
|
||||
|
||||
function Read-SoftwareReport {
|
||||
Param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $JsonReportPath
|
||||
)
|
||||
|
||||
if (-not (Test-Path $JsonReportPath)) {
|
||||
throw "File '$JsonReportPath' does not exist"
|
||||
}
|
||||
|
||||
$jsonReport = Get-Content -Path $JsonReportPath -Raw
|
||||
$report = [SoftwareReport]::FromJson($jsonReport)
|
||||
return $report
|
||||
}
|
||||
|
||||
$previousReport = Read-SoftwareReport -JsonReportPath $PreviousJsonReportPath
|
||||
$currentReport = Read-SoftwareReport -JsonReportPath $CurrentJsonReportPath
|
||||
|
||||
$comparer = [SoftwareReportComparer]::new($previousReport, $currentReport)
|
||||
$comparer.CompareReports()
|
||||
$diff = $comparer.GetMarkdownReport()
|
||||
$diff | Out-File -Path $OutputFile -Encoding utf8NoBOM
|
||||
Reference in New Issue
Block a user