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
157 changes: 137 additions & 20 deletions .github/actions/TestObjectIdsAndManifests/action.ps1
Original file line number Diff line number Diff line change
@@ -1,29 +1,146 @@
Import-Module "$PSScriptRoot\..\..\..\build\scripts\AppObjectValidation.psm1" -Force
Import-Module "$PSScriptRoot\..\..\..\build\scripts\BuildOptimization.psm1" -Force
Import-Module "$PSScriptRoot\..\..\..\build\scripts\EnlistmentHelperFunctions.psm1" -DisableNameChecking

$sourceCodeFolder = Join-Path (Get-BaseFolder) "src" -Resolve

# Test that all test object IDs are within the valid range
Test-ObjectIDsAreValid -SourceCodePaths $sourceCodeFolder

# Test that all application IDs are unique
Test-ApplicationIds -SourceCodePaths $sourceCodeFolder

# That that test objects are categorized correctly
$allowedUncategorizedTests = @(
139504, # Data Archive Tests
133502,139624,139628, # E-Document Core Tests"
148191, # E-Document Connector - Avalara Tests
139621,139622, # Error Messages with Recommendations Tests
139600, # Essential Business Headlines Test
139876,139877,139878,139879,139880,139881,139875, # PowerBI Reports Tests
139636,139568,139695,139608,139609,139611,139648,139567,139546,139551, # Shopify Connector Test
139686,139687,139688,139689,139690,139691,139692,139693,148155,148152,139912,139913,139914,139915,139916,148160,148156,139884,139885,148157,139887,139888,139889,148158,148153,148159,139694,139895,148154, # Subscription Billing
139610 # Send remittance advice by email Tests
# Base folders (everything except Apps and Layers)
$baseFolders = @(Get-ChildItem -Path $sourceCodeFolder -Directory -Exclude "Apps", "Layers" | Select-Object -ExpandProperty FullName)
# W1 Folders (For Apps and Layers)
$w1Apps = @(Join-Path $sourceCodeFolder "Apps\W1")
$w1Layers = @(Join-Path $sourceCodeFolder "Layers\W1")
# All Folders (For Apps)
$allApps = @(Join-Path $sourceCodeFolder "Apps")
# The 'Layers' folder only exists on main and on release branches from 29.0 onwards.
# Guard the Get-ChildItem call so it does not fail when the folder is missing.
$layersFolder = Join-Path $sourceCodeFolder 'Layers'
$allBaseApps = @(
if (Test-Path -Path $layersFolder) {
Get-ChildItem -Path $layersFolder -Directory |
ForEach-Object { Join-Path $_.FullName 'BaseApp' } |
Where-Object { Test-Path -Path $_ }
}
)
Test-ApplicationTestTypes -SourceCodePaths $sourceCodeFolder -Exceptions $allowedUncategorizedTests

# Build path sets for different validations
# Some folders (e.g. Layers) only exist on main and not on release branches, so filter out
# any paths that do not exist to avoid Get-ChildItem failing on missing directories.
[string[]] $w1OnlyPaths = @($baseFolders + $w1Apps + $w1Layers | Where-Object { Test-Path -Path $_ })
[string[]] $allPaths = @($baseFolders + $allApps + $w1Layers | Where-Object { Test-Path -Path $_ })
[string[]] $objectIdValidationPaths = @(
$allBaseApps
(Join-Path $sourceCodeFolder 'Business Foundation\App')
(Join-Path $sourceCodeFolder 'System Application\App')
$allApps
) | Where-Object { Test-Path -Path $_ }

# Define exceptions
$AllowedDuplicateObjects = @(
"table 230", # Source Code
"table 231", # Reason Code
"table 242", # Source Code Setup
"table 308", # No. Series
"table 309", # No. Series Line
"table 310", # No. Series Relationship
"table 1263", # No. Series Tenant
"table 6635", # Return Reason
"table 12145", # No. Series Line Sales
"table 12146" # No. Series Line Purchase
)

# Test that all application IDs are unique (Base Folders + All Apps and W1 Layer)
$duplicateApplicationIds = @(
"bd16d8dd-8faf-45d3-b733-3ddc6b9cfabf", # Bug 592283
"f3e4e6f8-2ba7-4202-834d-141ed9b89192"
)

# Exception - Out of range test object IDs
$outOfRangeTestObjects = @(
13918,13922,13923,13924,13925,13926, # E-Document for Germany Tests
10505, # Intrastat GB Tests
18649, # Fixed Asset Depreciation Tests
18078,18427,18428,18429,18460,18488, # GST Base Tests
18271,18272,18273, # GST On Payments Tests
18125,18126,18127,18128,18131,18132, # GST Purchase Automation
18133,18134,18135,18136,18137,18138,18139, # GST Purchase Automation (cont.)
18191,18192,18193,18194,18196,18197,18198, # GST Sales Automation
18479, # GST Subcontracting Automation
18345,18346,18480,18481, # India GST Tests
18044,18045,18046,18047, # India Reports Tests
18990,18991, # India Charge Group Tests
18628,18629,18630, # India Gate Entry Tests
18996,18998,18999, # India Voucher Interface Tests
18912, # TCS Base Test Automation
18925,18927,18928, # TCS On Receipt Automation
18914,18916,18917,18918,18919, # TCS on Sales Test Automation
18921, # TCS Return and Settlement Automation
18800, # TDS Base Tests
18682,18683, # TDS On Customer Tests
18790,18802,18803,18804,18805,18806, # TDS on Payments Tests
18791,18792,18793,18794, # TDS on Purchase Tests
18797 # TDS Return and Settlement Tests
)

# Test that object IDs don't clash and test objects are in valid range (W1 only)
Test-ObjectIDsAreValid -SourceCodePaths $w1OnlyPaths -AllowedDuplicateObjects $AllowedDuplicateObjects

# Test that all test object IDs are within the valid range (all apps - country test objects excepted)
Test-ObjectIDsAreValid -SourceCodePaths $allPaths -AllowedOutOfRangeTestObjects $outOfRangeTestObjects -SkipDuplicateCheck

# Test that all application IDs are unique (all paths)
Test-ApplicationIds -SourceCodePaths $allPaths -Exceptions $duplicateApplicationIds

# Test that all manifests are valid
$currentMajorMinor = Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go
$expectedPlatformVersion = "$($currentMajorMinor).0.0" # This can be hardcoded to a specific platform version if needed during version updates
Test-ApplicationManifests -Path $sourceCodeFolder -ExpectedAppVersion "$($currentMajorMinor).0.0" -ExpectedPlatformVersion $expectedPlatformVersion
$currentMajor = [int]($currentMajorMinor -split '\.')[0]
$expectedPlatformVersionCurrent = "$currentMajor.0.0.0"
$expectedPlatformVersionPrevious = "$($currentMajor - 1).0.0.0"
Test-ApplicationManifests -Path $allPaths -ExpectedAppVersion "$($currentMajorMinor).0.0" -ExpectedPlatformVersions @($expectedPlatformVersionCurrent, $expectedPlatformVersionPrevious)

# Test that we are not adding new uncategorized tests (W1 only) - Disabled for now
# Test-ApplicationTestTypes -SourceCodePaths $w1OnlyPaths -Exceptions $allowedUncategorizedTests

# Test object IDs declared in newly added production AL files.
$AllowedObjectIdRanges = @(
[PSCustomObject]@{ From = 1; To = 49999 },
[PSCustomObject]@{ From = 2000000; To = 2000059 },
[PSCustomObject]@{ From = 3005000; To = 3011499 },
[PSCustomObject]@{ From = 5000000; To = 5000099 },
[PSCustomObject]@{ From = 5000250; To = 5055999 },
[PSCustomObject]@{ From = 5001900; To = 5001999 },
[PSCustomObject]@{ From = 5005100; To = 5005399 },
[PSCustomObject]@{ From = 7000000; To = 7000099 },
[PSCustomObject]@{ From = 11000000; To = 11000499 },
[PSCustomObject]@{ From = 15000000; To = 15000499 },
[PSCustomObject]@{ From = 31000000; To = 31000099 },
[PSCustomObject]@{ From = 32000000; To = 32000199 },
[PSCustomObject]@{ From = 99000750; To = 99001048 }
)

# '@($null)' has a Count of 1, so filter empties to make the guard below work.
$addedFiles = @(Get-ChangedFilesForCI -DiffFilter 'A' -CompareFromMergeBase -RequireChangeDetection | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
if ($addedFiles.Count -eq 0) {
Write-Host "No newly added files were found; skipping the production object ID range validation."
}
else {
$repositoryRoot = (Resolve-Path -Path (Get-BaseFolder)).Path
$addedFilePaths = @($addedFiles | ForEach-Object { Join-Path -Path $repositoryRoot -ChildPath $_ })

# 'build\projects.json' is absent on some branches; pass it only when present.
$projectsJsonPath = Join-Path -Path $repositoryRoot -ChildPath 'build\projects.json'
$getALGoTestFoldersParams = @{
ProjectsPath = Join-Path -Path $repositoryRoot -ChildPath 'build\projects'
RepositoryRoot = $repositoryRoot
}
if (Test-Path -LiteralPath $projectsJsonPath) {
$getALGoTestFoldersParams['ProjectsJsonPath'] = $projectsJsonPath
}
else {
Write-Host "No 'build\projects.json' found at '$projectsJsonPath'; deriving test folders from project settings only."
}
$testFolderPaths = Get-ALGoTestFolders @getALGoTestFoldersParams
$allowedRangesText = ($AllowedObjectIdRanges | ForEach-Object { "$($_.From)..$($_.To)" }) -join ', '
Write-Host "Validating object IDs in newly added production AL files (allowed ranges: $allowedRangesText)."

Test-ObjectIDsInAddedALFilesAreInAllowedRange -FilePaths $addedFilePaths -SourceCodePaths $objectIdValidationPaths -TestFolderPaths $testFolderPaths -AllowedRanges $AllowedObjectIdRanges
}
10 changes: 8 additions & 2 deletions .github/workflows/SubmitStabilityJobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ jobs:
outputs:
officialBranches: ${{ steps.getOfficialBranches.outputs.branchesJson }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Get Official Branches
id: getOfficialBranches
uses: microsoft/BCApps/.github/actions/GetGitBranches@main
uses: ./.github/actions/GetGitBranches
with:
include: "['releases/*']"

Expand All @@ -38,10 +41,13 @@ jobs:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}

- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Submit Stability Job
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
uses: microsoft/BCApps/.github/actions/RunAutomation@main
uses: ./.github/actions/RunAutomation
with:
automations: SubmitStabilityJob
targetBranch: ${{ matrix.branch }}
15 changes: 13 additions & 2 deletions .github/workflows/UpdateALGoProjects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ jobs:
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Get Official Branches
id: getOfficialBranches
uses: microsoft/BCApps/.github/actions/GetGitBranches@main
uses: ./.github/actions/GetGitBranches
with:
include: "['main', 'releases/*']"

Expand Down Expand Up @@ -54,10 +57,18 @@ jobs:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}

- name: Checkout actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: _actions
sparse-checkout: |
.github/actions
build/scripts

- name: Update AL-Go Project Dependencies
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
uses: microsoft/BCApps/.github/actions/RunAutomation@main
uses: ./_actions/.github/actions/RunAutomation
with:
automations: UpdateUseProjectDependencies
targetBranch: ${{ matrix.branch }}
15 changes: 13 additions & 2 deletions .github/workflows/UpdateBCArtifactVersion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ jobs:
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Get Official Branches
id: getOfficialBranches
uses: microsoft/BCApps/.github/actions/GetGitBranches@main
uses: ./.github/actions/GetGitBranches
with:
include: "['main', 'releases/*']"

Expand Down Expand Up @@ -54,10 +57,18 @@ jobs:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}

- name: Checkout actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: _actions
sparse-checkout: |
.github/actions
build/scripts

- name: Update BC Artifact Version
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
uses: microsoft/BCApps/.github/actions/RunAutomation@main
uses: ./_actions/.github/actions/RunAutomation

with:
automations: UpdateBCArtifact
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/UpdatePackageVersions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ jobs:
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Get Official Branches
id: getOfficialBranches
uses: microsoft/BCApps/.github/actions/GetGitBranches@main
uses: ./.github/actions/GetGitBranches
with:
include: "['main', 'releases/*']"

Expand Down Expand Up @@ -54,10 +57,18 @@ jobs:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}

- name: Checkout actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: _actions
sparse-checkout: |
.github/actions
build/scripts

- name: Update Package Versions
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
uses: microsoft/BCApps/.github/actions/RunAutomation@main
uses: ./_actions/.github/actions/RunAutomation
with:
automations: UpdateAppBaselines,UpdateAppTranslations
targetBranch: ${{ matrix.branch }}
4 changes: 2 additions & 2 deletions .github/workflows/VerifyAppChanges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
ref: ${{ github.sha }}
fetch-depth: 0

- uses: microsoft/BCApps/.github/actions/TestPreprocessorSymbols@main
- uses: ./.github/actions/TestPreprocessorSymbols

- uses: microsoft/BCApps/.github/actions/TestObjectIdsAndManifests@main
- uses: ./.github/actions/TestObjectIdsAndManifests
Loading
Loading