From 7cd6b17ff112be40f651055736f810dbe576bc13 Mon Sep 17 00:00:00 2001 From: freddydk Date: Sat, 7 Oct 2023 07:46:58 +0200 Subject: [PATCH 1/6] check size limits --- Actions/Github-Helper.psm1 | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Actions/Github-Helper.psm1 b/Actions/Github-Helper.psm1 index bbb622738..fa20b1e6d 100644 --- a/Actions/Github-Helper.psm1 +++ b/Actions/Github-Helper.psm1 @@ -309,18 +309,16 @@ function invoke-gh { $arguments = "$command " foreach($parameter in $remaining) { if ("$parameter".IndexOf(" ") -ge 0 -or "$parameter".IndexOf('"') -ge 0) { + if ($parameter.length -gt 15000) { + $parameter = "$($parameter.Substring(0,15000))`n`n**Truncated due to size limits!**" + } $arguments += """$($parameter.Replace('"','\"'))"" " } else { $arguments += "$parameter " } } - try { - cmdDo -command gh -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr - } - catch [System.Management.Automation.MethodInvocationException] { - throw "It looks like GitHub CLI is not installed. Please install GitHub CLI from https://cli.github.com/" - } + cmdDo -command gh -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr } } @@ -344,12 +342,7 @@ function invoke-git { $arguments += "$parameter " } } - try { - cmdDo -command git -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr - } - catch [System.Management.Automation.MethodInvocationException] { - throw "It looks like Git is not installed. Please install Git from https://git-scm.com/download" - } + cmdDo -command git -arguments $arguments -silent:$silent -returnValue:$returnValue -inputStr $inputStr } } From 5586b577c6299468b5febdbe47190f76f98929c0 Mon Sep 17 00:00:00 2001 From: freddydk Date: Sat, 7 Oct 2023 07:50:03 +0200 Subject: [PATCH 2/6] dots --- Actions/Github-Helper.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Actions/Github-Helper.psm1 b/Actions/Github-Helper.psm1 index fa20b1e6d..946ac04d6 100644 --- a/Actions/Github-Helper.psm1 +++ b/Actions/Github-Helper.psm1 @@ -310,7 +310,7 @@ function invoke-gh { foreach($parameter in $remaining) { if ("$parameter".IndexOf(" ") -ge 0 -or "$parameter".IndexOf('"') -ge 0) { if ($parameter.length -gt 15000) { - $parameter = "$($parameter.Substring(0,15000))`n`n**Truncated due to size limits!**" + $parameter = "$($parameter.Substring(0,15000))...`n`n**Truncated due to size limits!**" } $arguments += """$($parameter.Replace('"','\"'))"" " } From a977c5445c148078c024d5c9e60ef700bc79b365 Mon Sep 17 00:00:00 2001 From: freddydk Date: Sat, 7 Oct 2023 08:07:01 +0200 Subject: [PATCH 3/6] test runner prereqs --- Actions/AL-Go-TestRepoHelper.ps1 | 15 +++++++++++++++ Actions/WorkflowInitialize/WorkflowInitialize.ps1 | 2 ++ 2 files changed, 17 insertions(+) diff --git a/Actions/AL-Go-TestRepoHelper.ps1 b/Actions/AL-Go-TestRepoHelper.ps1 index 38a6e2643..f67292cb5 100644 --- a/Actions/AL-Go-TestRepoHelper.ps1 +++ b/Actions/AL-Go-TestRepoHelper.ps1 @@ -116,6 +116,21 @@ function Test-JsonFile { Test-JsonStr -org -jsonStr (Get-Content -Path $jsonFile -Raw -Encoding UTF8) -settingsDescription $settingsFile -type $type } +function Test-RunnerPrerequisites { + try { + invoke-gh version + } + catch { + Write-Host "::Warning::GitHub CLI is not installed" + } + try { + invoke-git version + } + catch { + Write-Host "::Warning::Git is not installed" + } +} + function Test-ALGoRepository { Param( [string] $baseFolder = $ENV:GITHUB_WORKSPACE diff --git a/Actions/WorkflowInitialize/WorkflowInitialize.ps1 b/Actions/WorkflowInitialize/WorkflowInitialize.ps1 index c34d25b65..1190dc7f6 100644 --- a/Actions/WorkflowInitialize/WorkflowInitialize.ps1 +++ b/Actions/WorkflowInitialize/WorkflowInitialize.ps1 @@ -27,6 +27,8 @@ try { Test-ALGoRepository + Test-RunnerPrerequisites + DownloadAndImportBcContainerHelper import-module (Join-Path -path $PSScriptRoot -ChildPath "..\TelemetryHelper.psm1" -Resolve) From 11dbf19ca3cfd422e9161e5391fb8196e6b3e0a7 Mon Sep 17 00:00:00 2001 From: freddydk Date: Sat, 7 Oct 2023 08:10:22 +0200 Subject: [PATCH 4/6] move --- Actions/WorkflowInitialize/WorkflowInitialize.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Actions/WorkflowInitialize/WorkflowInitialize.ps1 b/Actions/WorkflowInitialize/WorkflowInitialize.ps1 index 1190dc7f6..85fc40d2e 100644 --- a/Actions/WorkflowInitialize/WorkflowInitialize.ps1 +++ b/Actions/WorkflowInitialize/WorkflowInitialize.ps1 @@ -27,10 +27,10 @@ try { Test-ALGoRepository - Test-RunnerPrerequisites - DownloadAndImportBcContainerHelper + Test-RunnerPrerequisites + import-module (Join-Path -path $PSScriptRoot -ChildPath "..\TelemetryHelper.psm1" -Resolve) $telemetryScope = CreateScope -eventId $eventId if ($telemetryScope) { From f5983bb3569481fb6a3589400287e3d1737a00c5 Mon Sep 17 00:00:00 2001 From: freddydk Date: Sat, 7 Oct 2023 08:15:40 +0200 Subject: [PATCH 5/6] rename --- Actions/AL-Go-TestRepoHelper.ps1 | 4 ++-- Actions/WorkflowInitialize/WorkflowInitialize.ps1 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Actions/AL-Go-TestRepoHelper.ps1 b/Actions/AL-Go-TestRepoHelper.ps1 index f67292cb5..efc05bdf2 100644 --- a/Actions/AL-Go-TestRepoHelper.ps1 +++ b/Actions/AL-Go-TestRepoHelper.ps1 @@ -116,7 +116,7 @@ function Test-JsonFile { Test-JsonStr -org -jsonStr (Get-Content -Path $jsonFile -Raw -Encoding UTF8) -settingsDescription $settingsFile -type $type } -function Test-RunnerPrerequisites { +function TestRunnerPrerequisites { try { invoke-gh version } @@ -131,7 +131,7 @@ function Test-RunnerPrerequisites { } } -function Test-ALGoRepository { +function TestALGoRepository { Param( [string] $baseFolder = $ENV:GITHUB_WORKSPACE ) diff --git a/Actions/WorkflowInitialize/WorkflowInitialize.ps1 b/Actions/WorkflowInitialize/WorkflowInitialize.ps1 index 85fc40d2e..0f34049df 100644 --- a/Actions/WorkflowInitialize/WorkflowInitialize.ps1 +++ b/Actions/WorkflowInitialize/WorkflowInitialize.ps1 @@ -25,11 +25,11 @@ try { Write-Big -str "a$verstr" - Test-ALGoRepository + TestALGoRepository DownloadAndImportBcContainerHelper - Test-RunnerPrerequisites + TestRunnerPrerequisites import-module (Join-Path -path $PSScriptRoot -ChildPath "..\TelemetryHelper.psm1" -Resolve) $telemetryScope = CreateScope -eventId $eventId From 60550f41d3e378712e8dfc8fa726f1b97e10bc7b Mon Sep 17 00:00:00 2001 From: freddydk Date: Sat, 7 Oct 2023 08:19:44 +0200 Subject: [PATCH 6/6] fix test --- Tests/WorkflowInitialize.Test.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/WorkflowInitialize.Test.ps1 b/Tests/WorkflowInitialize.Test.ps1 index 4fab4d6f7..3f3c00289 100644 --- a/Tests/WorkflowInitialize.Test.ps1 +++ b/Tests/WorkflowInitialize.Test.ps1 @@ -51,7 +51,7 @@ Describe "WorkflowInitialize Action Tests" { Set-Content -Path (Join-Path $githubFolder 'AL-Go-Settings.json') -Value $repoSettings -Encoding UTF8 Set-Content -Path (Join-Path $ALGoFolder 'settings.json') -Value $projectSettings -Encoding UTF8 Set-Content -Path (Join-Path $Project1ALGoFolder 'settings.json') -Value $project1Settings -Encoding UTF8 - Test-ALGoRepository -baseFolder $tempDir + TestALGoRepository -baseFolder $tempDir } finally { Remove-Item -Path $tempDir -Recurse -Force