Skip to content

Commit

Permalink
Summary result added
Browse files Browse the repository at this point in the history
  • Loading branch information
TomKovac committed Jan 8, 2025
1 parent 5d27e17 commit 115d965
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/app-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
}
catch
{
Write-Error "An unexpected error occurred: $_"
Write-Error "An error occurred: $_"
}
shell: powershell
37 changes: 24 additions & 13 deletions scripts/app-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ function Start-DotNetProject {
function BuildAndLoadPlc {
param (
[string]$appYamlFile,
[string]$appName
[string]$appName,
[bool]$summaryResult
)
# Check if the application folder is not empty
if (-Not ($appYamlFile))
Expand Down Expand Up @@ -538,6 +539,7 @@ function BuildAndLoadPlc {
else
{
$textToWrite = ",NOK"
$summaryResult = 0
}
Write-Result -TextToWrite $textToWrite -LogFilePath $logFilePath -AppendToSameLine
# apax swfd
Expand All @@ -550,15 +552,18 @@ function BuildAndLoadPlc {
else
{
$textToWrite = ",NOK"
$summaryResult = 0
}
Write-Result -TextToWrite $textToWrite -LogFilePath $logFilePath -AppendToSameLine
return $summaryResult
}

# Build and start HMI
function BuildAndStartHmi {
param (
[string]$appYamlFile,
[string]$appName
[string]$appName,
[bool]$summaryResult
)
# Check if the application folder is not empty
if (-Not ($appYamlFile))
Expand Down Expand Up @@ -602,6 +607,7 @@ function BuildAndStartHmi {
else
{
$textToWrite = ",NOK"
$summaryResult = 0
}
Write-Result -TextToWrite $textToWrite -LogFilePath $logFilePath -AppendToSameLine
# get blazor projects
Expand All @@ -626,6 +632,7 @@ function BuildAndStartHmi {
else
{
$textToWrite = ",NOK"
$summaryResult = 0
}
$result.output | foreach-object { write-output $_ }
Write-Result -TextToWrite $textToWrite -LogFilePath $logFilePath -AppendToSameLine
Expand All @@ -638,6 +645,7 @@ function BuildAndStartHmi {
}

cd $startDir
return $summaryResult
}

# Function to create the log file
Expand Down Expand Up @@ -772,6 +780,7 @@ if ($appYamls)
$createResult = CreateFile -DirectoryPath $resultPath -FileNamePrefix "test_result"

if ($createResult.Success) {
$SumaryResult = 1
$logFilePath = $createResult.FilePath
Write-Result -TextToWrite "AppName,PlcHw,PlcSw,DotnetBuild,DotnetRun" -LogFilePath $logFilePath
Write-Output "Files with 'type: app':"
Expand All @@ -784,14 +793,14 @@ if ($appYamls)
Write-Output "App Name: $($appYaml.AppName)"
Write-Result -TextToWrite " " -LogFilePath $logFilePath
Write-Result -TextToWrite "$($appYaml.AppName)" -LogFilePath $logFilePath -AppendToSameLine
####### Initialize plcsim instance with default 'fresh' content
#InitializePlcSimInstance -memoryCardPath $plcSimVirtualMemoryCardLocation -instanceName $($appYaml.AppName)
####### Overrite security files
#OverwriteSecurityFiles -appYamlFile $($appYaml.FilePath) -plcName $plcName
####### Build and load PLC
#BuildAndLoadPlc -appYamlFile $($appYaml.FilePath) -appName $($appYaml.AppName) -logFilePath $logFilePath
####### Build and start HMI
#BuildAndStartHmi -appYamlFile $($appYaml.FilePath) -appName $($appYaml.AppName) -logFilePath $logFilePath
###### Initialize plcsim instance with default 'fresh' content
InitializePlcSimInstance -memoryCardPath $plcSimVirtualMemoryCardLocation -instanceName $($appYaml.AppName)
###### Overrite security files
OverwriteSecurityFiles -appYamlFile $($appYaml.FilePath) -plcName $plcName
###### Build and load PLC
$SumaryResult = BuildAndLoadPlc -appYamlFile $($appYaml.FilePath) -appName $($appYaml.AppName) -logFilePath $logFilePath -summaryResult $SumaryResult
###### Build and start HMI
$SumaryResult = BuildAndStartHmi -appYamlFile $($appYaml.FilePath) -appName $($appYaml.AppName) -logFilePath $logFilePath -summaryResult $SumaryResult
}
}

Expand All @@ -801,11 +810,13 @@ if ($appYamls)
Write-Error "Failed to create the log file."
}
Kill-Process -ProcessName "Siemens.Simatic.PlcSim.Advanced.UserInterface"
# Write-Error "I am just curious how this error message impact github action status."
Write-Output "I am just curious how this error message impact github action status."
if($SumaryResult = 0)
{
Write-Error "Some app test failed."
}
}
else
{
Write-Output "No apax yaml files with 'type: app' were found."
Write-Error "No apax yaml files with 'type: app' were found."
}

0 comments on commit 115d965

Please sign in to comment.