Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invokegh #759

Merged
merged 6 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Actions/AL-Go-TestRepoHelper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,22 @@ function Test-JsonFile {
Test-JsonStr -org -jsonStr (Get-Content -Path $jsonFile -Raw -Encoding UTF8) -settingsDescription $settingsFile -type $type
}

function Test-ALGoRepository {
function TestRunnerPrerequisites {
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 TestALGoRepository {
Param(
[string] $baseFolder = $ENV:GITHUB_WORKSPACE
)
Expand Down
17 changes: 5 additions & 12 deletions Actions/Github-Helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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
}
}

Expand Down
4 changes: 3 additions & 1 deletion Actions/WorkflowInitialize/WorkflowInitialize.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ try {

Write-Big -str "a$verstr"

Test-ALGoRepository
TestALGoRepository

DownloadAndImportBcContainerHelper

TestRunnerPrerequisites

import-module (Join-Path -path $PSScriptRoot -ChildPath "..\TelemetryHelper.psm1" -Resolve)
$telemetryScope = CreateScope -eventId $eventId
if ($telemetryScope) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/WorkflowInitialize.Test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading