Skip to content
Open
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
9 changes: 8 additions & 1 deletion build/projects/Apps (W1)/.AL-Go/RunTestsInBcContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ Param(
[Hashtable]$parameters
)

$parameters["returnTrueIfAllPassed"] = $true

$script = Join-Path $PSScriptRoot "../../../scripts/RunTestsInBcContainer.ps1" -Resolve
. $script -parameters $parameters
$AllTestsPassed = (. $script -parameters $parameters)

# run test codeunits with RequiredTestIsolation set to Disabled
$AllTestsPassedIsolation = (. $script -parameters $parameters -DisableTestIsolation)

return $AllTestsPassed -and $AllTestsPassedIsolation
33 changes: 24 additions & 9 deletions build/projects/Apps (W1)/.AL-Go/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"installOnlyReferencedApps": false,
"doNotRunPageScriptingTests": true,
"doNotRunBcptTests": true,
"testType": "IntegrationTest",
"buildModes": [
"AT",
"AU",
Expand All @@ -37,7 +38,9 @@
"NO",
"NZ",
"SE",
"US"
"US",
"UnitTests",
"UncategorizedTests"
],
"ConditionalSettings": [
{
Expand All @@ -53,8 +56,7 @@
"AU"
],
"settings": {
"country": "au",
"doNotRunTests": true
"country": "au"
}
},
{
Expand All @@ -70,8 +72,7 @@
"CA"
],
"settings": {
"country": "ca",
"doNotRunTests": true
"country": "ca"
}
},
{
Expand Down Expand Up @@ -161,8 +162,7 @@
"IT"
],
"settings": {
"country": "it",
"doNotRunTests": true
"country": "it"
}
},
{
Expand Down Expand Up @@ -210,8 +210,7 @@
"US"
],
"settings": {
"country": "us",
"doNotRunTests": true
"country": "us"
}
},
{
Expand All @@ -224,6 +223,22 @@
"doNotPublishApps": true
}
},
{
"buildModes": [
"UnitTests"
],
"settings": {
"testType": "UnitTest"
}
},
{
"buildModes": [
"UncategorizedTests"
],
"settings": {
"testType": "Uncategorized"
}
},
{
"branches": [
"releases/*.[0-5]"
Expand Down
25 changes: 25 additions & 0 deletions build/scripts/EnlistmentHelperFunctions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -611,5 +611,30 @@ function Get-AppsInFolder() {
return $apps
}

<#
.SYNOPSIS
Gets a setting from the AL-Go settings environment variable set during GitHub Actions runs.
.DESCRIPTION
This function retrieves a setting from the AL-Go settings stored in the environment variable 'settings'.
It returns the value of the specified key, or $null if the key does not exist.
.PARAMETER Key
The key of the setting to retrieve.
.OUTPUTS
The value of the specified setting key, or $null if the key does not exist.
#>
function Get-ALGoSetting() {
param(
[Parameter(Mandatory=$true)]
[string] $Key
)
if ($null -ne $env:settings) {
$alGoSettings = $env:settings | ConvertFrom-Json
if ($alGoSettings.PSObject.Properties.Name -contains $Key) {
return $alGoSettings.$Key
}
}
return $null
}

Export-ModuleMember -Function *-*
Export-ModuleMember -Function RunAndCheck
30 changes: 27 additions & 3 deletions build/scripts/ImportTestDataInBcContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ Param(
)

Import-Module $PSScriptRoot\AppExtensionsHelper.psm1
Import-Module $PSScriptRoot\EnlistmentHelperFunctions.psm1

function Invoke-ContosoDemoTool() {
param(
[string]$ContainerName,
[string]$CompanyName = (Get-NavDefaultCompanyName -ContainerName $ContainerName),
[switch]$SetupData = $false
[switch]$SetupData
)
Write-Host "Initializing company in container $ContainerName"
Invoke-NavContainerCodeunit -Codeunitid 2 -containerName $ContainerName -CompanyName $CompanyName
Expand Down Expand Up @@ -45,6 +46,30 @@ function Get-NavDefaultCompanyName
throw "No Cronus company found in container $ContainerName.."
}

function Invoke-DemoDataGeneration
{
param(
[Parameter(Mandatory=$true)]
[string]$ContainerName,
[Parameter(Mandatory=$true)]
[ValidateSet("UnitTest","IntegrationTest","Uncategorized")]
[string]$TestType
)
if ($TestType -eq "UnitTest") {
Write-Host "UnitTest shouldn't have dependency on any Demo Data, skipping demo data generation"
return
} elseif( $TestType -eq "IntegrationTest" ) {
Write-Host "Proceeding with demo data generation (SetupData) as test type is set to IntegrationTest"
Invoke-ContosoDemoTool -ContainerName $ContainerName -SetupData
} elseif( $TestType -eq "Uncategorized" ) {
Write-Host "Proceeding with full demo data generation as test type is set to Uncategorized"
Invoke-ContosoDemoTool -ContainerName $ContainerName
} else {
throw "Unknown test type $TestType."
}

}

# Reinstall all the uninstalled apps in the container
# This is needed to ensure that the various Demo Data apps are installed in the container when we generate demo data
$allUninstalledApps = Get-BcContainerAppInfo -containerName $parameters.ContainerName -tenantSpecificProperties -sort DependenciesFirst | Where-Object { $_.IsInstalled -eq $false }
Expand All @@ -63,5 +88,4 @@ foreach ($app in (Get-BcContainerAppInfo -containerName $ContainerName -tenantSp
Write-Host "App: $($app.Name) ($($app.Version)) - Scope: $($app.Scope) - $($app.IsInstalled) / $($app.IsPublished)"
}

# Generate demo data in the container
Invoke-ContosoDemoTool -ContainerName $parameters.ContainerName
Invoke-DemoDataGeneration -ContainerName $parameters.ContainerName -TestType (Get-ALGoSetting -Key "testType")
6 changes: 6 additions & 0 deletions build/scripts/RunTestsInBcContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ if ($DisableTestIsolation)
$parameters["testRunnerCodeunitId"] = "130451" # Test Runner with disabled test isolation
}

$testType = Get-ALGoSetting -Key "testType"
if ($null -ne $testType) {
Write-Host "Using test type $testType"
$parameters["testType"] = $testType
}

$parameters["disabledTests"] = @(Get-DisabledTests) # Add disabled tests to parameters
$parameters["renewClientContextBetweenTests"] = $true

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"codeunitId": 133508,
"codeunitName": "E-Doc. PO Matching Unit Tests",
"method": "*",
"bug": "610664"
}
Loading