From a2418a2ecc3fdddbdcf3d021a24c083c53bace7f Mon Sep 17 00:00:00 2001 From: grobyns Date: Thu, 19 Sep 2024 14:43:29 +0200 Subject: [PATCH 01/19] add CLEANSCHEMA symbols --- .../Legacy/ObsoleteSourceCodeExt.TableExt.al | 2 ++ .../ObsoleteSourceCodeSetupExt.TableExt.al | 18 ++++++++++++++++++ .../Legacy/NoSeriesLineObsolete.TableExt.al | 4 +++- .../src/Legacy/NoSeriesLinePurchase.Table.al | 2 ++ .../src/Legacy/NoSeriesLineSales.Table.al | 2 ++ .../src/Legacy/NoSeriesObsolete.TableExt.al | 2 ++ .../Message/EmailMessageAttachment.Table.al | 2 ++ .../src/AzureOpenAiSettings.Table.al | 2 ++ .../AggregatedAssistedSetup.Table.al | 3 ++- .../src/Assisted Setup/AssistedSetup.Table.al | 3 ++- .../Assisted Setup/AssistedSetupIcons.Table.al | 3 ++- .../Assisted Setup/AssistedSetupLog.Table.al | 3 ++- .../ProductVideoCategory.Table.al | 3 ++- .../Manual Setup/BusinessSetupIcon.Table.al | 3 ++- .../src/Manual Setup/ManualSetup.Table.al | 2 ++ .../src/NetPromoterScoreSetup.Table.al | 2 ++ .../src/QueryNavigationValidation.Table.al | 2 ++ .../src/SmartListDesignerHandler.Table.al | 4 +++- .../User Settings/src/ExtraSettings.Table.al | 4 +++- .../App/Video/src/ProductVideoBuffer.Table.al | 2 ++ 20 files changed, 59 insertions(+), 9 deletions(-) diff --git a/src/Business Foundation/App/AuditCodes/src/Legacy/ObsoleteSourceCodeExt.TableExt.al b/src/Business Foundation/App/AuditCodes/src/Legacy/ObsoleteSourceCodeExt.TableExt.al index 01b823edd9..2131880597 100644 --- a/src/Business Foundation/App/AuditCodes/src/Legacy/ObsoleteSourceCodeExt.TableExt.al +++ b/src/Business Foundation/App/AuditCodes/src/Legacy/ObsoleteSourceCodeExt.TableExt.al @@ -18,6 +18,7 @@ tableextension 230 ObsoleteSourceCodeExt extends "Source Code" MovedTo = '437dbf0e-84ff-417a-965d-ed2bb9650972'; ObsoleteTag = '25.0'; } +#if not CLEANSCHEMA15 field(10620; "SAFT Source Code"; Code[9]) { Caption = 'SAF-T Source Code'; @@ -28,6 +29,7 @@ tableextension 230 ObsoleteSourceCodeExt extends "Source Code" ObsoleteTag = '15.0'; #pragma warning restore AS0072 } +#endif field(28160; Simulation; Boolean) { Caption = 'Simulation'; diff --git a/src/Business Foundation/App/AuditCodes/src/Legacy/ObsoleteSourceCodeSetupExt.TableExt.al b/src/Business Foundation/App/AuditCodes/src/Legacy/ObsoleteSourceCodeSetupExt.TableExt.al index 6a8b1a0698..d1bbc321ab 100644 --- a/src/Business Foundation/App/AuditCodes/src/Legacy/ObsoleteSourceCodeSetupExt.TableExt.al +++ b/src/Business Foundation/App/AuditCodes/src/Legacy/ObsoleteSourceCodeSetupExt.TableExt.al @@ -839,6 +839,7 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '25.0'; MovedTo = '437dbf0e-84ff-417a-965d-ed2bb9650972'; } +#if not CLEANSCHEMA15 field(11200; "Inward Registration"; Code[10]) { Caption = 'Inward Registration'; @@ -849,6 +850,7 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '15.0'; #pragma warning restore AS0072 } +#endif field(11307; "Financial Journal"; Code[10]) { Caption = 'Financial Journal'; @@ -879,6 +881,7 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '25.0'; MovedTo = '437dbf0e-84ff-417a-965d-ed2bb9650972'; } +#if not CLEANSCHEMA20 field(11760; "Purchase VAT Delay"; Code[10]) { Caption = 'Purchase VAT Delay'; @@ -901,6 +904,8 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '20.0'; #pragma warning restore AS0072 } +#endif +#if not CLEANSCHEMA18 field(11762; "VAT Coefficient"; Code[10]) { Caption = 'VAT Coefficient'; @@ -912,6 +917,8 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '18.0'; #pragma warning restore AS0072 } +#endif +#if not CLEANSCHEMA22 field(11764; "Close Balance Sheet"; Code[10]) { Caption = 'Close Balance Sheet'; @@ -934,6 +941,8 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '22.0'; #pragma warning restore AS0072 } +#endif +#if not CLEANSCHEMA20 field(11766; "Cash Desk"; Code[10]) { Caption = 'Cash Desk'; @@ -945,6 +954,7 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '20.0'; #pragma warning restore AS0072 } +#endif field(12400; "Advance Statements"; Code[10]) { Caption = 'Advance Statements'; @@ -1065,6 +1075,7 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '25.0'; MovedTo = '437dbf0e-84ff-417a-965d-ed2bb9650972'; } +#if not CLEANSCHEMA21 field(12450; "Item Receipt"; Code[10]) { Caption = 'Item Receipt'; @@ -1087,6 +1098,7 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '21.0'; #pragma warning restore AS0072 } +#endif field(12470; "FA Release"; Code[10]) { Caption = 'FA Release'; @@ -1147,6 +1159,7 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '25.0'; MovedTo = '437dbf0e-84ff-417a-965d-ed2bb9650972'; } +#if not CLEANSCHEMA18 field(31041; "Maintenance Adjustment"; Code[10]) { Caption = 'Maintenance Adjustment'; @@ -1158,6 +1171,8 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '18.0'; #pragma warning restore AS0072 } +#endif +#if not CLEANSCHEMA21 field(31050; Credit; Code[10]) { Caption = 'Credit'; @@ -1169,6 +1184,7 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '21.0'; #pragma warning restore AS0072 } +#endif #pragma warning disable AS0013 field(2000020; "Domiciliation Journal"; Code[10]) { @@ -1190,6 +1206,7 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '25.0'; MovedTo = '437dbf0e-84ff-417a-965d-ed2bb9650972'; } +#if not CLEANSCHEMA24 field(5005350; "Phys. Invt. Order"; Code[10]) { Caption = 'Phys. Invt. Order'; @@ -1201,6 +1218,7 @@ tableextension 242 ObsoleteSourceCodeSetupExt extends "Source Code Setup" ObsoleteTag = '24.0'; #pragma warning restore AS0072 } +#endif field(7000000; "Cartera Journal"; Code[10]) { Caption = 'Cartera Journal'; diff --git a/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLineObsolete.TableExt.al b/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLineObsolete.TableExt.al index e63148c063..89d2b150f1 100644 --- a/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLineObsolete.TableExt.al +++ b/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLineObsolete.TableExt.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA27 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -183,4 +184,5 @@ tableextension 309 NoSeriesLineObsolete extends "No. Series Line" end; #endif -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLinePurchase.Table.al b/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLinePurchase.Table.al index a96ff1ab44..aa984c2a8d 100644 --- a/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLinePurchase.Table.al +++ b/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLinePurchase.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA27 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -149,3 +150,4 @@ table 12146 "No. Series Line Purchase" } } } +#endif \ No newline at end of file diff --git a/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLineSales.Table.al b/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLineSales.Table.al index 51d298860c..099cc9abcd 100644 --- a/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLineSales.Table.al +++ b/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesLineSales.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA27 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -149,3 +150,4 @@ table 12145 "No. Series Line Sales" } } } +#endif \ No newline at end of file diff --git a/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesObsolete.TableExt.al b/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesObsolete.TableExt.al index a3032ddc99..93240995e0 100644 --- a/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesObsolete.TableExt.al +++ b/src/Business Foundation/App/NoSeries/src/Legacy/NoSeriesObsolete.TableExt.al @@ -12,6 +12,7 @@ tableextension 308 NoSeriesObsolete extends "No. Series" { fields { +#if not CLEANSCHEMA18 field(11790; Mask; Text[20]) // CZ Functionality { Caption = 'Mask'; @@ -20,6 +21,7 @@ tableextension 308 NoSeriesObsolete extends "No. Series" ObsoleteState = Removed; ObsoleteTag = '18.0'; } +#endif #pragma warning disable AL0432 field(12100; "No. Series Type"; Integer) #pragma warning restore AL0432 diff --git a/src/System Application/App/Email/src/Message/EmailMessageAttachment.Table.al b/src/System Application/App/Email/src/Message/EmailMessageAttachment.Table.al index 3dd2032ea4..4cf14fc363 100644 --- a/src/System Application/App/Email/src/Message/EmailMessageAttachment.Table.al +++ b/src/System Application/App/Email/src/Message/EmailMessageAttachment.Table.al @@ -25,6 +25,7 @@ table 8904 "Email Message Attachment" DataClassification = SystemMetadata; TableRelation = "Email Message".Id; } +#if not CLEANSCHEMA18 field(3; Attachment; Blob) { DataClassification = CustomerContent; @@ -32,6 +33,7 @@ table 8904 "Email Message Attachment" ObsoleteReason = 'Field has been replaced with the media field, Data.'; ObsoleteTag = '18.1'; } +#endif field(4; "Attachment Name"; Text[250]) { DataClassification = CustomerContent; diff --git a/src/System Application/App/Entity Text/src/AzureOpenAiSettings.Table.al b/src/System Application/App/Entity Text/src/AzureOpenAiSettings.Table.al index 24e83bec7b..e6bce7af18 100644 --- a/src/System Application/App/Entity Text/src/AzureOpenAiSettings.Table.al +++ b/src/System Application/App/Entity Text/src/AzureOpenAiSettings.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA27 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -370,3 +371,4 @@ table 2010 "Azure OpenAi Settings" TelemetryTotalIslandsInvalidTxt: Label 'The total islands config key is not set or is not a number.', Locked = true; #endif } +#endif \ No newline at end of file diff --git a/src/System Application/App/Guided Experience/src/Assisted Setup/AggregatedAssistedSetup.Table.al b/src/System Application/App/Guided Experience/src/Assisted Setup/AggregatedAssistedSetup.Table.al index 18a1e88411..b20676bede 100644 --- a/src/System Application/App/Guided Experience/src/Assisted Setup/AggregatedAssistedSetup.Table.al +++ b/src/System Application/App/Guided Experience/src/Assisted Setup/AggregatedAssistedSetup.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA19 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -91,4 +92,4 @@ table 1808 "Aggregated Assisted Setup" } } } - +#endif \ No newline at end of file diff --git a/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetup.Table.al b/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetup.Table.al index 625366ed02..a65f04202a 100644 --- a/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetup.Table.al +++ b/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetup.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA23 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -194,4 +195,4 @@ table 1803 "Assisted Setup" Translation.Delete(Rec); end; } - +#endif \ No newline at end of file diff --git a/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetupIcons.Table.al b/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetupIcons.Table.al index 6abd3d12d4..9487a79a4e 100644 --- a/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetupIcons.Table.al +++ b/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetupIcons.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA19 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -42,4 +43,4 @@ table 1810 "Assisted Setup Icons" } } } - +#endif \ No newline at end of file diff --git a/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetupLog.Table.al b/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetupLog.Table.al index 72c4de1b69..81f0493a11 100644 --- a/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetupLog.Table.al +++ b/src/System Application/App/Guided Experience/src/Assisted Setup/AssistedSetupLog.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA23 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -56,4 +57,4 @@ table 1807 "Assisted Setup Log" } } - +#endif \ No newline at end of file diff --git a/src/System Application/App/Guided Experience/src/Assisted Setup/ProductVideoCategory.Table.al b/src/System Application/App/Guided Experience/src/Assisted Setup/ProductVideoCategory.Table.al index d0668d6728..f53199d29b 100644 --- a/src/System Application/App/Guided Experience/src/Assisted Setup/ProductVideoCategory.Table.al +++ b/src/System Application/App/Guided Experience/src/Assisted Setup/ProductVideoCategory.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA19 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -52,4 +53,4 @@ table 1471 "Product Video Category" } } - +#endif \ No newline at end of file diff --git a/src/System Application/App/Guided Experience/src/Manual Setup/BusinessSetupIcon.Table.al b/src/System Application/App/Guided Experience/src/Manual Setup/BusinessSetupIcon.Table.al index 8dba446ed2..e62ac36bee 100644 --- a/src/System Application/App/Guided Experience/src/Manual Setup/BusinessSetupIcon.Table.al +++ b/src/System Application/App/Guided Experience/src/Manual Setup/BusinessSetupIcon.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA23 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -45,4 +46,4 @@ table 1876 "Business Setup Icon" } } - +#endif \ No newline at end of file diff --git a/src/System Application/App/Guided Experience/src/Manual Setup/ManualSetup.Table.al b/src/System Application/App/Guided Experience/src/Manual Setup/ManualSetup.Table.al index aebf573560..f1c21a7b96 100644 --- a/src/System Application/App/Guided Experience/src/Manual Setup/ManualSetup.Table.al +++ b/src/System Application/App/Guided Experience/src/Manual Setup/ManualSetup.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA23 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -77,3 +78,4 @@ table 3700 "Manual Setup" } } #pragma warning restore AS0039 +#endif \ No newline at end of file diff --git a/src/System Application/App/Satisfaction Survey/src/NetPromoterScoreSetup.Table.al b/src/System Application/App/Satisfaction Survey/src/NetPromoterScoreSetup.Table.al index 5f0e39842c..0a0abb1b25 100644 --- a/src/System Application/App/Satisfaction Survey/src/NetPromoterScoreSetup.Table.al +++ b/src/System Application/App/Satisfaction Survey/src/NetPromoterScoreSetup.Table.al @@ -27,6 +27,7 @@ table 1432 "Net Promoter Score Setup" { DataClassification = SystemMetadata; } +#if not CLEANSCHEMA18 field(4; "Time Between Requests"; Integer) { DataClassification = SystemMetadata; @@ -34,6 +35,7 @@ table 1432 "Net Promoter Score Setup" ObsoleteState = Removed; ObsoleteTag = '18.0'; } +#endif field(5; "Request Timeout"; Integer) { DataClassification = SystemMetadata; diff --git a/src/System Application/App/SmartList Designer Subscribers/src/QueryNavigationValidation.Table.al b/src/System Application/App/SmartList Designer Subscribers/src/QueryNavigationValidation.Table.al index 387e796bfc..44552b8385 100644 --- a/src/System Application/App/SmartList Designer Subscribers/src/QueryNavigationValidation.Table.al +++ b/src/System Application/App/SmartList Designer Subscribers/src/QueryNavigationValidation.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA23 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -47,3 +48,4 @@ table 2889 "Query Navigation Validation" } } } +#endif \ No newline at end of file diff --git a/src/System Application/App/SmartList Designer Subscribers/src/SmartListDesignerHandler.Table.al b/src/System Application/App/SmartList Designer Subscribers/src/SmartListDesignerHandler.Table.al index f8dc6c15eb..f232641780 100644 --- a/src/System Application/App/SmartList Designer Subscribers/src/SmartListDesignerHandler.Table.al +++ b/src/System Application/App/SmartList Designer Subscribers/src/SmartListDesignerHandler.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA23 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -51,4 +52,5 @@ table 2888 "SmartList Designer Handler" Clustered = true; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/System Application/App/User Settings/src/ExtraSettings.Table.al b/src/System Application/App/User Settings/src/ExtraSettings.Table.al index 07b0a77b96..7f1c52f3f8 100644 --- a/src/System Application/App/User Settings/src/ExtraSettings.Table.al +++ b/src/System Application/App/User Settings/src/ExtraSettings.Table.al @@ -1,3 +1,4 @@ +#if not CLEANSCHEMA23 // ------------------------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -39,4 +40,5 @@ table 9173 "Extra Settings" Clustered = true; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/System Application/App/Video/src/ProductVideoBuffer.Table.al b/src/System Application/App/Video/src/ProductVideoBuffer.Table.al index ad7471592a..f8df4c3fbd 100644 --- a/src/System Application/App/Video/src/ProductVideoBuffer.Table.al +++ b/src/System Application/App/Video/src/ProductVideoBuffer.Table.al @@ -40,6 +40,7 @@ table 1470 "Product Video Buffer" DataClassification = SystemMetadata; Editable = false; } +#if not CLEANSCHEMA18 field(4; "Assisted Setup ID"; Integer) { Caption = 'Assisted Setup ID'; @@ -56,6 +57,7 @@ table 1470 "Product Video Buffer" ObsoleteReason = 'Product videos are no more grouped.'; ObsoleteTag = '18.0'; } +#endif field(6; "Table Num"; Integer) { DataClassification = SystemMetadata; From eac961b6522ab49d71aa0f3759a5a07178637280 Mon Sep 17 00:00:00 2001 From: mazhelez Date: Thu, 19 Sep 2024 23:27:22 +0200 Subject: [PATCH 02/19] Port the gate for testing app clean symbols --- .../TestPreprocessorSymbols.ps1 | 168 ++++++++++++++++++ .github/actions/VerifyAppChanges/action.yaml | 13 ++ .github/workflows/VerifyAppChanges.yaml | 21 +++ 3 files changed, 202 insertions(+) create mode 100644 .github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 create mode 100644 .github/actions/VerifyAppChanges/action.yaml create mode 100644 .github/workflows/VerifyAppChanges.yaml diff --git a/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 b/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 new file mode 100644 index 0000000000..b6621eaaac --- /dev/null +++ b/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 @@ -0,0 +1,168 @@ +# Current path is .github/actions/VerifyAppChanges +# Import EnlistmentHelperFunctions module from build/scripts +Import-Module "$PSScriptRoot\..\..\..\build\scripts\EnlistmentHelperFunctions.psm1" -DisableNameChecking + +<# +.SYNOPSIS + Verifies preprocessor symbols in a given file. + +.DESCRIPTION + This function checks for the following in the specified file: + - Ensures preprocessor symbols are lowercased. + - Ensures preprocessor symbols match the specified patterns. + - Ensures preprocessor symbols have uppercase stems. + - Ensures there is no space after the '#' character. + +.PARAMETER filePath + The path to the file to be checked. + +.PARAMETER symbolStems + An array of symbol stems to be checked. + +.PARAMETER lowerBound + The lower bound for the CLEANxx pattern. + +.PARAMETER upperBound + The upper bound for the CLEANxx pattern. + +.EXAMPLE + $alfiles = Get-ChildItem -Recurse -Filter *.al -Path .\App\ + foreach ($alfile in $alfiles) { + Test-PreprocessorSymbols -filePath $alfile.FullName -symbolStems @("CLEAN", "CLEANSCHEMA") -lowerBound 22 -upperBound 26 + } + +.NOTES + Author: Gert Robyns + Date: 2024-09-03 +#> +function Test-PreprocessorSymbols { + param ( + [Parameter(Mandatory=$true)] + [string]$filePath, + [Parameter(Mandatory=$true)] + [string[]]$symbolStems, + [Parameter(Mandatory=$true)] + [int]$lowerBound, + [Parameter(Mandatory=$true)] + [int]$upperBound + ) + + # check if extension is .al, else return $null + if ('.al' -ne [system.io.path]::GetExtension($filePath)) { + return $null + } + + # Generate the regex pattern for the CLEANxx range + $rangePattern = "$($lowerBound..$upperBound -join '|')" + + # Define the regex patterns for the preprocessor symbols and the configurable stems + # Define the regex pattern for disallowing a space after # + $noSpaceAfterHashPattern = "^#\s" + $lowercasePattern = "^#(if|elseif|else\b|endif)" + $lowercaseNotPattern = "^#if not " + $symbolPattern = @() + + foreach ($stem in $symbolStems) { + $upperStem = $stem.ToUpper() + $symbolPattern += "^#if\s${upperStem}($rangePattern)" + $symbolPattern += "^#if\snot\s${upperStem}($rangePattern)" + $symbolPattern += "^#elseif\s${upperStem}($rangePattern)" + } + + # Add #endif to the symbol pattern but not to the strict pattern + $symbolPattern += "#else\b" + $symbolPattern += "#endif" + + # Read the content of the file + $content = Get-Content -Path $filePath + + # Initialize lists to store any invalid preprocessor symbols with line numbers + $invalidLowercaseSymbols = @() + $invalidPatternSymbols = @() + $invalidStemSymbols = @() + + # Iterate through each line in the file content with line numbers + for ($i = 0; $i -lt $content.Count; $i++) { + $line = $content[$i] + $lineNumber = $i + 1 + + # Check for space after # + if ($line -cmatch $noSpaceAfterHashPattern) { + $invalidPatternSymbols += "${filePath}:${lineNumber}: $line" + } + + # Check for lowercase + if (($line -match $lowercasePattern) -and ($line -cnotmatch $lowercasePattern)) { + $invalidLowercaseSymbols += "${filePath}:${lineNumber}: $line" + } + + # Check for lowercase not + if (($line -match $lowercaseNotPattern) -and ($line -cnotmatch $lowercaseNotPattern)) { + $invalidLowercaseSymbols += "${filePath}:${lineNumber}: $line" + } + + # Check for strict pattern match + $isValidPattern = $false + foreach ($pattern in $symbolPattern) { + if ($line -match $pattern) { + $isValidPattern = $true + break + } + } + if ($line -match $lowercasePattern -and -not $isValidPattern -and $line -notmatch "^#endif") { + $invalidPatternSymbols += "${filePath}:${lineNumber}: $line" + } + + # Check for uppercase stem + foreach ($stem in $symbolStems) { + $upperStem = $stem.ToUpper() + if ($line -match "#(if|if not|elseif)\s+${stem}($rangePattern)" -and $line -cnotmatch "#((?i)(if|if not|elseif))\s+${upperStem}($rangePattern)") { + $invalidStemSymbols += "${filePath}:${lineNumber}: $line" + } + } + } + + if (($invalidLowercaseSymbols.Count -gt 0) -or ($invalidPatternSymbols -gt 0) -or ($invalidStemSymbols -gt 0)) { + return @{ "invalidLowercaseSymbols" = $invalidLowercaseSymbols; "invalidPatternSymbols" = $invalidPatternSymbols; "invalidStemSymbols" = $invalidStemSymbols } + } else { + return $null + } +} + +$baseFolder = Get-BaseFolder + +# Get the version from the main branch +Push-Location $baseFolder +$majorVerionOnMain = $(git show main:.github\AL-Go-Settings.json) | ConvertFrom-Json | Select-Object -ExpandProperty repoVersion +Pop-Location + +# Get the current major version +$currentMajorVerion = (Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go) -split '.' | Select-Object -First 1 + +$symbolStems = @("CLEAN") + +# Set the upper bound to the major version on the main branch +$upperBound = $majorVerionOnMain +# Set the lower bound to the current version minus 4 +$lowerBound = $currentMajorVerion - 4 + +#initialize arrays to store any invalid preprocessor symbols with line numbers +$invalidLowercaseSymbols = @() +$invalidPatternSymbols = @() +$invalidStemSymbols = @() + +$alfiles = (Get-ChildItem -Filter '*.al' -Recurse) | Select-Object -ExpandProperty LocalPath +foreach ($file in $alfiles) { + # Call the Test-PreprocessorSymbols function with the file path and calculated version bounds + $result = Test-PreprocessorSymbols -filePath $file -symbolStems $symbolStems -lowerBound $lowerBound -upperBound $upperBound + if ($null -ne $result) { + $invalidLowercaseSymbols += $result.invalidLowercaseSymbols + $invalidPatternSymbols += $result.invalidPatternSymbols + $invalidStemSymbols += $result.invalidStemSymbols + } +} + +$symbolErrors = $invalidLowercaseSymbols + $invalidPatternSymbols + $invalidStemSymbols +if ($symbolErrors.Count -gt 0) { + throw "Errors found in preprocessor symbols:`n $symbolErrors" +} \ No newline at end of file diff --git a/.github/actions/VerifyAppChanges/action.yaml b/.github/actions/VerifyAppChanges/action.yaml new file mode 100644 index 0000000000..d55544909f --- /dev/null +++ b/.github/actions/VerifyAppChanges/action.yaml @@ -0,0 +1,13 @@ +name: VerifY App Changes +author: Microsoft Corporation +description: Verifies the changes on AL files changed in a PR +runs: + using: composite + steps: + - name: Test Preprocessor Symbols + shell: pwsh + run: | + ${{ github.action_path }}/TestPreprocessorSymbols.ps1 +branding: + icon: terminal + color: blue diff --git a/.github/workflows/VerifyAppChanges.yaml b/.github/workflows/VerifyAppChanges.yaml new file mode 100644 index 0000000000..bd654399c6 --- /dev/null +++ b/.github/workflows/VerifyAppChanges.yaml @@ -0,0 +1,21 @@ +name: 'Verify App Changes' + +on: + pull_request: + branches: [ 'main', 'releases/*'] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + VerifyAppChanges: + runs-on: windows-latest + name: Verify App Changes + steps: + - name: checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.sha }} + + - uses: microsoft/BCApps/.github/actions/VerifyAppChanges@main From 4eda538268efdac63d59bfceb876b8d941b03ae9 Mon Sep 17 00:00:00 2001 From: mazhelez Date: Thu, 19 Sep 2024 23:29:26 +0200 Subject: [PATCH 03/19] Fix typo --- .github/actions/VerifyAppChanges/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/VerifyAppChanges/action.yaml b/.github/actions/VerifyAppChanges/action.yaml index d55544909f..56468f2936 100644 --- a/.github/actions/VerifyAppChanges/action.yaml +++ b/.github/actions/VerifyAppChanges/action.yaml @@ -1,4 +1,4 @@ -name: VerifY App Changes +name: Verify App Changes author: Microsoft Corporation description: Verifies the changes on AL files changed in a PR runs: From ce43d16402c11f9b2fb2e5173ba9e218d5dec557 Mon Sep 17 00:00:00 2001 From: Maria Zhelezova <43066499+mazhelez@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:35:57 +0200 Subject: [PATCH 04/19] Adapt script to BCApps (#2072) --- .../TestPreprocessorSymbols.ps1 | 21 +++++++------------ .github/workflows/VerifyAppChanges.yaml | 2 +- build/scripts/GuardingV2ExtensionsHelper.psm1 | 4 ++-- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 b/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 index b6621eaaac..24939231a4 100644 --- a/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 +++ b/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 @@ -1,6 +1,7 @@ # Current path is .github/actions/VerifyAppChanges -# Import EnlistmentHelperFunctions module from build/scripts + Import-Module "$PSScriptRoot\..\..\..\build\scripts\EnlistmentHelperFunctions.psm1" -DisableNameChecking +Import-Module "$PSScriptRoot\..\..\..\build\scripts\GuardingV2ExtensionsHelper.psm1" -DisableNameChecking <# .SYNOPSIS @@ -129,29 +130,23 @@ function Test-PreprocessorSymbols { } } -$baseFolder = Get-BaseFolder - -# Get the version from the main branch -Push-Location $baseFolder -$majorVerionOnMain = $(git show main:.github\AL-Go-Settings.json) | ConvertFrom-Json | Select-Object -ExpandProperty repoVersion -Pop-Location - -# Get the current major version -$currentMajorVerion = (Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go) -split '.' | Select-Object -First 1 $symbolStems = @("CLEAN") +# Get the current major version +$currentMajorVerion = (Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go) -split '\.' | Select-Object -First 1 -# Set the upper bound to the major version on the main branch -$upperBound = $majorVerionOnMain +$upperBound = Get-MaxAllowedObsoleteVersion # Set the lower bound to the current version minus 4 $lowerBound = $currentMajorVerion - 4 +Write-Host "Checking preprocessor symbols $symbolStems with a lower bound of $lowerBound and an upper bound of $upperBound" + #initialize arrays to store any invalid preprocessor symbols with line numbers $invalidLowercaseSymbols = @() $invalidPatternSymbols = @() $invalidStemSymbols = @() -$alfiles = (Get-ChildItem -Filter '*.al' -Recurse) | Select-Object -ExpandProperty LocalPath +$alfiles = (Get-ChildItem -Filter '*.al' -Recurse) | Select-Object -ExpandProperty FullName foreach ($file in $alfiles) { # Call the Test-PreprocessorSymbols function with the file path and calculated version bounds $result = Test-PreprocessorSymbols -filePath $file -symbolStems $symbolStems -lowerBound $lowerBound -upperBound $upperBound diff --git a/.github/workflows/VerifyAppChanges.yaml b/.github/workflows/VerifyAppChanges.yaml index bd654399c6..cc9e0a2d11 100644 --- a/.github/workflows/VerifyAppChanges.yaml +++ b/.github/workflows/VerifyAppChanges.yaml @@ -18,4 +18,4 @@ jobs: with: ref: ${{ github.sha }} - - uses: microsoft/BCApps/.github/actions/VerifyAppChanges@main + - uses: mazhelez/BCApps/.github/actions/VerifyAppChanges@main diff --git a/build/scripts/GuardingV2ExtensionsHelper.psm1 b/build/scripts/GuardingV2ExtensionsHelper.psm1 index 69c55ac3e8..fc3b233cfd 100644 --- a/build/scripts/GuardingV2ExtensionsHelper.psm1 +++ b/build/scripts/GuardingV2ExtensionsHelper.psm1 @@ -205,7 +205,7 @@ function Update-AppSourceCopVersion # All major versions greater than current but less or equal to main should be allowed $currentBuildVersion = [int] $buildVersion.Split('.')[0] - $maxAllowedObsoleteVersion = [int] (GetMaxAllowedObsoleteVersion) + $maxAllowedObsoleteVersion = [int] (Get-MaxAllowedObsoleteVersion) $obsoleteTagAllowedVersions = @() # Add 3 versions for tasks built with CLEANpreProcessorSymbols @@ -257,7 +257,7 @@ function Test-IsStrictModeEnabled return $false } -function GetMaxAllowedObsoleteVersion() { +function Get-MaxAllowedObsoleteVersion() { git fetch origin main $alGoSettings = $(git show origin/main:.github/AL-Go-Settings.json) | ConvertFrom-Json if (-not $alGoSettings.repoVersion) { From 8fe9f6ba466bc57dc41001ce2ab905556122c98d Mon Sep 17 00:00:00 2001 From: grobyns Date: Fri, 20 Sep 2024 14:42:16 +0200 Subject: [PATCH 05/19] script changes --- .../TestPreprocessorSymbols.ps1 | 150 ++---------------- build/scripts/TestPreprocessorSymbols.psm1 | 122 ++++++++++++++ 2 files changed, 139 insertions(+), 133 deletions(-) create mode 100644 build/scripts/TestPreprocessorSymbols.psm1 diff --git a/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 b/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 index 24939231a4..2a69ef09d3 100644 --- a/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 +++ b/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 @@ -2,144 +2,28 @@ Import-Module "$PSScriptRoot\..\..\..\build\scripts\EnlistmentHelperFunctions.psm1" -DisableNameChecking Import-Module "$PSScriptRoot\..\..\..\build\scripts\GuardingV2ExtensionsHelper.psm1" -DisableNameChecking +Import-Module "$PSScriptRoot\..\..\..\build\scripts\TestPreprocessorSymbols.psm1" -Force -<# -.SYNOPSIS - Verifies preprocessor symbols in a given file. +# Get the major build version from the main branch +$mainVersion = Get-MaxAllowedObsoleteVersion -.DESCRIPTION - This function checks for the following in the specified file: - - Ensures preprocessor symbols are lowercased. - - Ensures preprocessor symbols match the specified patterns. - - Ensures preprocessor symbols have uppercase stems. - - Ensures there is no space after the '#' character. +# Get the major build version from the current branch +$currentVersion = (Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go) -split '\.' | Select-Object -First 1 -.PARAMETER filePath - The path to the file to be checked. - -.PARAMETER symbolStems - An array of symbol stems to be checked. - -.PARAMETER lowerBound - The lower bound for the CLEANxx pattern. - -.PARAMETER upperBound - The upper bound for the CLEANxx pattern. - -.EXAMPLE - $alfiles = Get-ChildItem -Recurse -Filter *.al -Path .\App\ - foreach ($alfile in $alfiles) { - Test-PreprocessorSymbols -filePath $alfile.FullName -symbolStems @("CLEAN", "CLEANSCHEMA") -lowerBound 22 -upperBound 26 - } - -.NOTES - Author: Gert Robyns - Date: 2024-09-03 -#> -function Test-PreprocessorSymbols { - param ( - [Parameter(Mandatory=$true)] - [string]$filePath, - [Parameter(Mandatory=$true)] - [string[]]$symbolStems, - [Parameter(Mandatory=$true)] - [int]$lowerBound, - [Parameter(Mandatory=$true)] - [int]$upperBound - ) - - # check if extension is .al, else return $null - if ('.al' -ne [system.io.path]::GetExtension($filePath)) { - return $null - } - - # Generate the regex pattern for the CLEANxx range - $rangePattern = "$($lowerBound..$upperBound -join '|')" - - # Define the regex patterns for the preprocessor symbols and the configurable stems - # Define the regex pattern for disallowing a space after # - $noSpaceAfterHashPattern = "^#\s" - $lowercasePattern = "^#(if|elseif|else\b|endif)" - $lowercaseNotPattern = "^#if not " - $symbolPattern = @() - - foreach ($stem in $symbolStems) { - $upperStem = $stem.ToUpper() - $symbolPattern += "^#if\s${upperStem}($rangePattern)" - $symbolPattern += "^#if\snot\s${upperStem}($rangePattern)" - $symbolPattern += "^#elseif\s${upperStem}($rangePattern)" - } - - # Add #endif to the symbol pattern but not to the strict pattern - $symbolPattern += "#else\b" - $symbolPattern += "#endif" - - # Read the content of the file - $content = Get-Content -Path $filePath - - # Initialize lists to store any invalid preprocessor symbols with line numbers - $invalidLowercaseSymbols = @() - $invalidPatternSymbols = @() - $invalidStemSymbols = @() - - # Iterate through each line in the file content with line numbers - for ($i = 0; $i -lt $content.Count; $i++) { - $line = $content[$i] - $lineNumber = $i + 1 - - # Check for space after # - if ($line -cmatch $noSpaceAfterHashPattern) { - $invalidPatternSymbols += "${filePath}:${lineNumber}: $line" - } - - # Check for lowercase - if (($line -match $lowercasePattern) -and ($line -cnotmatch $lowercasePattern)) { - $invalidLowercaseSymbols += "${filePath}:${lineNumber}: $line" - } - - # Check for lowercase not - if (($line -match $lowercaseNotPattern) -and ($line -cnotmatch $lowercaseNotPattern)) { - $invalidLowercaseSymbols += "${filePath}:${lineNumber}: $line" - } - - # Check for strict pattern match - $isValidPattern = $false - foreach ($pattern in $symbolPattern) { - if ($line -match $pattern) { - $isValidPattern = $true - break - } - } - if ($line -match $lowercasePattern -and -not $isValidPattern -and $line -notmatch "^#endif") { - $invalidPatternSymbols += "${filePath}:${lineNumber}: $line" - } - - # Check for uppercase stem - foreach ($stem in $symbolStems) { - $upperStem = $stem.ToUpper() - if ($line -match "#(if|if not|elseif)\s+${stem}($rangePattern)" -and $line -cnotmatch "#((?i)(if|if not|elseif))\s+${upperStem}($rangePattern)") { - $invalidStemSymbols += "${filePath}:${lineNumber}: $line" - } - } - } - - if (($invalidLowercaseSymbols.Count -gt 0) -or ($invalidPatternSymbols -gt 0) -or ($invalidStemSymbols -gt 0)) { - return @{ "invalidLowercaseSymbols" = $invalidLowercaseSymbols; "invalidPatternSymbols" = $invalidPatternSymbols; "invalidStemSymbols" = $invalidStemSymbols } - } else { - return $null - } +# CLEANSCHEMA is on a 5y cycle starting from 26 +if ($CurrentVersion -le 26) { + $schemaLowerBound = 15 +} else { + $schemaLowerBound = ([math]::Floor(($CurrentVersion - 2) / 5) * 5) - 2 } +# Define the preprocessor symbols to check for +$symbolConfigs = @( + @{stem = "CLEAN"; lowerBound = ($CurrentVersion - 4); upperBound = $mainVersion}, + @{stem = "CLEANSCHEMA"; lowerBound = $schemaLowerBound; upperBound = $mainVersion + 3} # next lowerbound, after cleanup should be 25, then +) -$symbolStems = @("CLEAN") -# Get the current major version -$currentMajorVerion = (Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go) -split '\.' | Select-Object -First 1 - -$upperBound = Get-MaxAllowedObsoleteVersion -# Set the lower bound to the current version minus 4 -$lowerBound = $currentMajorVerion - 4 - -Write-Host "Checking preprocessor symbols $symbolStems with a lower bound of $lowerBound and an upper bound of $upperBound" +Write-Host "Checking preprocessor symbols with $symbolConfigs" #initialize arrays to store any invalid preprocessor symbols with line numbers $invalidLowercaseSymbols = @() @@ -149,7 +33,7 @@ $invalidStemSymbols = @() $alfiles = (Get-ChildItem -Filter '*.al' -Recurse) | Select-Object -ExpandProperty FullName foreach ($file in $alfiles) { # Call the Test-PreprocessorSymbols function with the file path and calculated version bounds - $result = Test-PreprocessorSymbols -filePath $file -symbolStems $symbolStems -lowerBound $lowerBound -upperBound $upperBound + $result = Test-PreprocessorSymbols -filePath $file -symbolConfigs $symbolConfigs if ($null -ne $result) { $invalidLowercaseSymbols += $result.invalidLowercaseSymbols $invalidPatternSymbols += $result.invalidPatternSymbols diff --git a/build/scripts/TestPreprocessorSymbols.psm1 b/build/scripts/TestPreprocessorSymbols.psm1 new file mode 100644 index 0000000000..4be8f89953 --- /dev/null +++ b/build/scripts/TestPreprocessorSymbols.psm1 @@ -0,0 +1,122 @@ +<# +- Ensures preprocessor symbols have uppercase stems. +- Ensures there is no space after the '#' character. + +.PARAMETER filePath + The path to the file to be checked. + +.PARAMETER symbolConfigs + An array of hash tables where each entry has a stem, an upper, and a lower bound. + +.EXAMPLE + $alfiles = Get-ChildItem -Recurse -Filter *.al -Path .\App\ + foreach ($alfile in $alfiles) { + $symbolConfigs = @( + @{stem="CLEAN"; lowerBound=22; upperBound=26}, + @{stem="CLEANSCHEMA"; lowerBound=22; upperBound=26} + ) + Test-PreprocessorSymbols -filePath $alfile.FullName -symbolConfigs $symbolConfigs + } + +.NOTES + Author: Gert Robyns + Date: 2024-09-03 + + Updated by: Gert Robyns + Date: 2024-09-20 +#> +function Test-PreprocessorSymbols { + param ( + [Parameter(Mandatory=$true)] + [string]$filePath, + [Parameter(Mandatory=$true)] + [hashtable[]]$symbolConfigs + ) + + # check if extension is .al, else return $null + if ('.al' -ne [system.io.path]::GetExtension($filePath)) { + return $null + } + + # Define the regex pattern for disallowing a space after # + $noSpaceAfterHashPattern = "^#\s" + $lowercasePattern = "^#(if|elseif|else\b|endif)" + $lowercaseNotPattern = "^#if not " + $symbolPattern = @() + + foreach ($config in $symbolConfigs) { + $stem = $config.stem + $lowerBound = $config.lowerBound + $upperBound = $config.upperBound + + # Generate the regex pattern for the SymbolStem range + $rangePattern = "$($lowerBound..$upperBound -join '|')" + + $upperStem = $stem.ToUpper() + $symbolPattern += "^#if\s${upperStem}($rangePattern)" + $symbolPattern += "^#if\snot\s${upperStem}($rangePattern)" + $symbolPattern += "^#elseif\s${upperStem}($rangePattern)" + } + + # Add #endif to the symbol pattern but not to the strict pattern + $symbolPattern += "#else\b" + $symbolPattern += "#endif" + + # Read the content of the file + $content = Get-Content -Path $filePath + + # Initialize lists to store any invalid preprocessor symbols with line numbers + $invalidLowercaseSymbols = @() + $invalidPatternSymbols = @() + $invalidStemSymbols = @() + + # Iterate through each line in the file content with line numbers + for ($i = 0; $i -lt $content.Count; $i++) { + $line = $content[$i] + $lineNumber = $i + 1 + + # Check for space after # + if ($line -cmatch $noSpaceAfterHashPattern) { + $invalidPatternSymbols += "${filePath}:${lineNumber}: $line" + } + + # Check for lowercase + if (($line -match $lowercasePattern) -and ($line -cnotmatch $lowercasePattern)) { + $invalidLowercaseSymbols += "${filePath}:${lineNumber}: $line" + } + + # Check for lowercase not + if (($line -match $lowercaseNotPattern) -and ($line -cnotmatch $lowercaseNotPattern)) { + $invalidLowercaseSymbols += "${filePath}:${lineNumber}: $line" + } + + # Check for strict pattern match + $isValidPattern = $false + foreach ($pattern in $symbolPattern) { + if ($line -match $pattern) { + $isValidPattern = $true + break + } + } + if ($line -match $lowercasePattern -and -not $isValidPattern -and $line -notmatch "^#endif") { + $invalidPatternSymbols += "${filePath}:${lineNumber}: $line" + } + + # Check for uppercase stem + foreach ($config in $symbolConfigs) { + $stem = $config.stem + $upperStem = $stem.ToUpper() + if ($line -match "#(if|if not|elseif)\s+${stem}($rangePattern)" -and $line -cnotmatch "#((?i)(if|if not|elseif))\s+${upperStem}($rangePattern)") { + $invalidStemSymbols += "${filePath}:${lineNumber}: $line" + } + } + } + + if (($invalidLowercaseSymbols.Count -gt 0) -or ($invalidPatternSymbols -gt 0) -or ($invalidStemSymbols -gt 0)) { + return @{ "invalidLowercaseSymbols" = $invalidLowercaseSymbols; "invalidPatternSymbols" = $invalidPatternSymbols; "invalidStemSymbols" = $invalidStemSymbols } + } else { + return $null + } +} + +Export-ModuleMember -Function Test-PreprocessorSymbols \ No newline at end of file From 18003a3632ae0336e18dce65d74d1100e1552ae1 Mon Sep 17 00:00:00 2001 From: grobyns Date: Fri, 20 Sep 2024 14:45:14 +0200 Subject: [PATCH 06/19] review comment --- .github/workflows/VerifyAppChanges.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/VerifyAppChanges.yaml b/.github/workflows/VerifyAppChanges.yaml index cc9e0a2d11..bd654399c6 100644 --- a/.github/workflows/VerifyAppChanges.yaml +++ b/.github/workflows/VerifyAppChanges.yaml @@ -18,4 +18,4 @@ jobs: with: ref: ${{ github.sha }} - - uses: mazhelez/BCApps/.github/actions/VerifyAppChanges@main + - uses: microsoft/BCApps/.github/actions/VerifyAppChanges@main From bd00fbeaa5e3ca3498d73df8218429f91c5df70b Mon Sep 17 00:00:00 2001 From: grobyns Date: Fri, 20 Sep 2024 14:47:29 +0200 Subject: [PATCH 07/19] fix whitespace --- .../actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 b/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 index 2a69ef09d3..d2b56e0451 100644 --- a/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 +++ b/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 @@ -2,12 +2,12 @@ Import-Module "$PSScriptRoot\..\..\..\build\scripts\EnlistmentHelperFunctions.psm1" -DisableNameChecking Import-Module "$PSScriptRoot\..\..\..\build\scripts\GuardingV2ExtensionsHelper.psm1" -DisableNameChecking -Import-Module "$PSScriptRoot\..\..\..\build\scripts\TestPreprocessorSymbols.psm1" -Force +Import-Module "$PSScriptRoot\..\..\..\build\scripts\TestPreprocessorSymbols.psm1" -Force -# Get the major build version from the main branch +# Get the major build version from the main branch $mainVersion = Get-MaxAllowedObsoleteVersion -# Get the major build version from the current branch +# Get the major build version from the current branch $currentVersion = (Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go) -split '\.' | Select-Object -First 1 # CLEANSCHEMA is on a 5y cycle starting from 26 From 0913524b5c722a2eeef96bca90deeac4642c7ba2 Mon Sep 17 00:00:00 2001 From: grobyns Date: Fri, 20 Sep 2024 15:07:30 +0200 Subject: [PATCH 08/19] comments --- build/scripts/TestPreprocessorSymbols.psm1 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/build/scripts/TestPreprocessorSymbols.psm1 b/build/scripts/TestPreprocessorSymbols.psm1 index 4be8f89953..146a2b064f 100644 --- a/build/scripts/TestPreprocessorSymbols.psm1 +++ b/build/scripts/TestPreprocessorSymbols.psm1 @@ -1,6 +1,11 @@ <# -- Ensures preprocessor symbols have uppercase stems. -- Ensures there is no space after the '#' character. +.DESCRIPTION + This script checks the preprocessor symbols in an AL file for the following: + - Ensures there is no space after the '#' character. + - Ensures preprocessor symbols have uppercase stems. + - Ensures preprocessor symbols are within a specified range. + - Ensures preprocessor symbols are in the correct format. + - Ensures preprocessor symbols are not in lowercase. .PARAMETER filePath The path to the file to be checked. @@ -36,7 +41,7 @@ function Test-PreprocessorSymbols { # check if extension is .al, else return $null if ('.al' -ne [system.io.path]::GetExtension($filePath)) { return $null - } + } # Define the regex pattern for disallowing a space after # $noSpaceAfterHashPattern = "^#\s" @@ -89,7 +94,7 @@ function Test-PreprocessorSymbols { if (($line -match $lowercaseNotPattern) -and ($line -cnotmatch $lowercaseNotPattern)) { $invalidLowercaseSymbols += "${filePath}:${lineNumber}: $line" } - + # Check for strict pattern match $isValidPattern = $false foreach ($pattern in $symbolPattern) { @@ -116,7 +121,7 @@ function Test-PreprocessorSymbols { return @{ "invalidLowercaseSymbols" = $invalidLowercaseSymbols; "invalidPatternSymbols" = $invalidPatternSymbols; "invalidStemSymbols" = $invalidStemSymbols } } else { return $null - } + } } Export-ModuleMember -Function Test-PreprocessorSymbols \ No newline at end of file From 0b1c1b9b174e55b540374cc75c725c6d50dca0f6 Mon Sep 17 00:00:00 2001 From: grobyns Date: Fri, 20 Sep 2024 15:33:09 +0200 Subject: [PATCH 09/19] cuz maria said so --- .github/workflows/VerifyAppChanges.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/VerifyAppChanges.yaml b/.github/workflows/VerifyAppChanges.yaml index bd654399c6..ddbbad19e5 100644 --- a/.github/workflows/VerifyAppChanges.yaml +++ b/.github/workflows/VerifyAppChanges.yaml @@ -18,4 +18,4 @@ jobs: with: ref: ${{ github.sha }} - - uses: microsoft/BCApps/.github/actions/VerifyAppChanges@main + - uses: microsoft/BCApps/.github/actions/VerifyAppChanges@features/549296 From 9e3000ab0b8cb0e1562a8f8aba69fa4cd1586f2b Mon Sep 17 00:00:00 2001 From: grobyns Date: Fri, 20 Sep 2024 16:07:25 +0200 Subject: [PATCH 10/19] review comment --- build/scripts/TestPreprocessorSymbols.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/scripts/TestPreprocessorSymbols.psm1 b/build/scripts/TestPreprocessorSymbols.psm1 index 146a2b064f..1e91a7e81d 100644 --- a/build/scripts/TestPreprocessorSymbols.psm1 +++ b/build/scripts/TestPreprocessorSymbols.psm1 @@ -11,7 +11,7 @@ The path to the file to be checked. .PARAMETER symbolConfigs - An array of hash tables where each entry has a stem, an upper, and a lower bound. + An array of objects where each entry has a stem, an upper, and a lower bound. .EXAMPLE $alfiles = Get-ChildItem -Recurse -Filter *.al -Path .\App\ From e97ff84bd33d612f7af3be012db9bdedffcee6eb Mon Sep 17 00:00:00 2001 From: grobyns Date: Fri, 20 Sep 2024 16:16:51 +0200 Subject: [PATCH 11/19] move pester tests --- build/scripts/TestPreprocessorSymbols.psm1 | 3 + .../tests/TestPreprocessorSymbols.Test.ps1 | 318 ++++++++++++++++++ 2 files changed, 321 insertions(+) create mode 100644 build/scripts/tests/TestPreprocessorSymbols.Test.ps1 diff --git a/build/scripts/TestPreprocessorSymbols.psm1 b/build/scripts/TestPreprocessorSymbols.psm1 index 1e91a7e81d..c113a0169e 100644 --- a/build/scripts/TestPreprocessorSymbols.psm1 +++ b/build/scripts/TestPreprocessorSymbols.psm1 @@ -1,4 +1,7 @@ <# +.SYNOPSIS + This script checks the preprocessor symbols in an AL file. + .DESCRIPTION This script checks the preprocessor symbols in an AL file for the following: - Ensures there is no space after the '#' character. diff --git a/build/scripts/tests/TestPreprocessorSymbols.Test.ps1 b/build/scripts/tests/TestPreprocessorSymbols.Test.ps1 new file mode 100644 index 0000000000..c64d483768 --- /dev/null +++ b/build/scripts/tests/TestPreprocessorSymbols.Test.ps1 @@ -0,0 +1,318 @@ +Describe "Test-PreprocessorSymbols" { + BeforeAll { + Import-Module "$PSScriptRoot\..\..\..\build\scripts\TestPreprocessorSymbols.psm1" -Force + } + + It 'returns $null when the filepath extension is not .al' { + $result = Test-PreprocessorSymbols -filePath 'Dummy.txt' -symbolConfigs @(@{'stem' = "CLEAN"; 'lowerBound' = 1; 'upperBound' = 1}) + $result | Should -Be $null + } + + It 'returns empty invalidLowercaseSymbols, invalidPatternSymbols and invalidStemSymbols when the file contains lowercase preprocessors with correct symbols and versions' { + $alcontent = @( +'codeunit 123 TestPreprocessors +{ +#if CLEAN1 +#endif + +#if not CLEAN2 +#endif + +#if CLEAN3 +#else +#endif + +#if CLEAN4 +#elseif CLEAN5 +#endif +}') + Set-Content -Path TestDrive:\Dummy.al -Value $alcontent + Mock -CommandName Get-Content { return Get-Content TestDrive:\dummy.al} + + $result = Test-PreprocessorSymbols -filePath 'TestDrive:\dummy.al' -symbolConfigs @(@{'stem' = "CLEAN"; 'lowerBound' = 1; 'upperBound' = 5}) + + $result.count | Should -Be 0 + $result.invalidLowercaseSymbols.Count | Should -Be 0 + $result.invalidPatternSymbols.Count | Should -Be 0 + $result.invalidStemSymbols.Count | Should -Be 0 + + $result.invalidLowercaseSymbols | Should -Be @(). + $result.invalidPatternSymbols | Should -Be @(). + $result.invalidStemSymbols | Should -Be @(). + } + + It 'returns empty invalidLowercaseSymbols, invalidPatternSymbols and invalidStemSymbols when the file contains lowercase preprocessors with multiple correct symbolstems and versions' { + $alcontent = @( +'codeunit 123 TestPreprocessors +{ +#if CLEAN1 +#endif + +#if not CLEANSCHEMA2 +#endif + +#if MYSPECIALCASE3 +#else +#endif +}') + Set-Content -Path TestDrive:\Dummy.al -Value $alcontent + Mock -CommandName Get-Content { return Get-Content TestDrive:\dummy.al} + + $symbolConfigs = @( + @{stem="CLEAN"; lowerBound=1; upperBound=3}, + @{stem="CLEANSCHEMA"; lowerBound=1; upperBound=3}, + @{stem="MYSPECIALCASE"; lowerBound=1; upperBound=3} + ) + $result = Test-PreprocessorSymbols -filePath 'TestDrive:\dummy.al' -symbolConfigs $symbolConfigs + + $result.count | Should -Be 0 + $result.invalidLowercaseSymbols.Count | Should -Be 0 + $result.invalidPatternSymbols.Count | Should -Be 0 + $result.invalidStemSymbols.Count | Should -Be 0 + + $result.invalidLowercaseSymbols | Should -Be @(). + $result.invalidPatternSymbols | Should -Be @(). + $result.invalidStemSymbols | Should -Be @(). + } + + It 'returns invalidLowercaseSymbols when the file contains not lowercase preprocessor symbols' { + $alcontent = @( +'codeunit 123 TestPreprocessors +{ +#IF CLEAN1 +#endif + +#if NOT CLEAN2 +#endif + +#if CLEAN3 +#ELSE +#endif + +#if CLEAN4 +#elseif CLEAN5 +#ENDIF + +#If CLEAN6 +#EnDiF + +#iF CLEAN7 +#Else +#EndIf +}') + Set-Content -Path TestDrive:\Dummy.al -Value $alcontent + Mock -CommandName Get-Content { return Get-Content TestDrive:\dummy.al} + + $result = Test-PreprocessorSymbols -filePath 'TestDrive:\dummy.al' -symbolConfigs @(@{'stem' = "CLEAN"; 'lowerBound' = 1; 'upperBound' = 7}) + + $result.count | Should -Be 3 + $result.invalidLowercaseSymbols.Count | Should -Be 9 + $result.invalidPatternSymbols.Count | Should -Be 0 + $result.invalidStemSymbols.Count | Should -Be 0 + + $result.invalidLowercaseSymbols | Should -Be @('TestDrive:\dummy.al:3: #IF CLEAN1', 'TestDrive:\dummy.al:6: #if NOT CLEAN2', 'TestDrive:\dummy.al:10: #ELSE', 'TestDrive:\dummy.al:15: #ENDIF', 'TestDrive:\dummy.al:17: #If CLEAN6', 'TestDrive:\dummy.al:18: #EnDiF', 'TestDrive:\dummy.al:20: #iF CLEAN7', 'TestDrive:\dummy.al:21: #Else', 'TestDrive:\dummy.al:22: #EndIf'). + $result.invalidPatternSymbols | Should -Be @(). + $result.invalidStemSymbols | Should -Be @(). + } + + It 'returns invalidPatternSymbols when the spacing is not correct' { + $alcontent = @( +'codeunit 123 TestPreprocessors +{ +# if CLEAN1 +#endif + +#if not CLEAN2 +#endif + +#if not CLEAN3 +#endif + +#if CLEAN4 +# endif + +#if CLEAN4 +# else +#endif + +#if CLEAN5 +# elseif CLEAN6 +#endif + +#if CLEAN7 +#endif +}') + Set-Content -Path TestDrive:\Dummy.al -Value $alcontent + Mock -CommandName Get-Content { return Get-Content TestDrive:\dummy.al} + + $result = Test-PreprocessorSymbols -filePath 'TestDrive:\dummy.al' -symbolConfigs @(@{'stem' = "CLEAN"; 'lowerBound' = 1; 'upperBound' = 7}) + + $result.count | Should -Be 3 + $result.invalidLowercaseSymbols.Count | Should -Be 0 + $result.invalidPatternSymbols.Count | Should -Be 7 + $result.invalidStemSymbols.Count | Should -Be 0 + + $result.invalidLowercaseSymbols | Should -Be @(). + $result.invalidPatternSymbols | Should -Be @('TestDrive:\dummy.al:3: # if CLEAN1', 'TestDrive:\dummy.al:6: #if not CLEAN2', 'TestDrive:\dummy.al:9: #if not CLEAN3', 'TestDrive:\dummy.al:13: # endif', 'TestDrive:\dummy.al:16: # else', 'TestDrive:\dummy.al:20: # elseif CLEAN6', 'TestDrive:\dummy.al:23: #if CLEAN7'). + $result.invalidStemSymbols | Should -Be @(). + } + + It 'returns invalidPatternSymbols when the version is not correct' { + $alcontent = @( +'codeunit 123 TestPreprocessors +{ +#if CLEAN +#endif + +#if CLEAN1 +#endif + +#if not CLEAN2 +#endif + +#if CLEAN3 +#elseif CLEAN4 +#endif + +#if CLEAN8 +#endif + +#if CLEAN12 +#endif + +#if not CLEAN13 +#endif + +#if CLEAN14 +#elseif CLEAN15 +#endif + +}') + Set-Content -Path TestDrive:\Dummy.al -Value $alcontent + Mock -CommandName Get-Content { return Get-Content TestDrive:\dummy.al} + + $result = Test-PreprocessorSymbols -filePath 'TestDrive:\dummy.al' -symbolConfigs @(@{'stem' = "CLEAN"; 'lowerBound' = 5; 'upperBound' = 11}) + + $result.count | Should -Be 3 + $result.invalidLowercaseSymbols.Count | Should -Be 0 + $result.invalidPatternSymbols.Count | Should -Be 9 + $result.invalidStemSymbols.Count | Should -Be 0 + + $result.invalidLowercaseSymbols | Should -Be @(). + $result.invalidPatternSymbols | Should -Be @('TestDrive:\dummy.al:3: #if CLEAN', 'TestDrive:\dummy.al:6: #if CLEAN1', 'TestDrive:\dummy.al:9: #if not CLEAN2', 'TestDrive:\dummy.al:12: #if CLEAN3', 'TestDrive:\dummy.al:13: #elseif CLEAN4', 'TestDrive:\dummy.al:19: #if CLEAN12', 'TestDrive:\dummy.al:22: #if not CLEAN13', 'TestDrive:\dummy.al:25: #if CLEAN14', 'TestDrive:\dummy.al:26: #elseif CLEAN15') + $result.invalidStemSymbols | Should -Be @(). + } + + It 'returns invalidPatternSymbols when the symbol stem is not correct' { + $alcontent = @( +'codeunit 123 TestPreprocessors +{ +#if CLEANT1 +#endif + +#if not SCLEAN2 +#endif + +#if SUPERCLEAN3 +#elseif CLEANMORE4 +#endif + +#if FUBAR +#endif + +#if CLEAN7 +#endif + +#if RELEASE +#endif + +#if not RELEASE12 +#endif +}') + Set-Content -Path TestDrive:\Dummy.al -Value $alcontent + Mock -CommandName Get-Content { return Get-Content TestDrive:\dummy.al} + + $result = Test-PreprocessorSymbols -filePath 'TestDrive:\dummy.al' -symbolConfigs @(@{'stem' = "CLEAN"; 'lowerBound' = 5; 'upperBound' = 11}) + + $result.count | Should -Be 3 + $result.invalidLowercaseSymbols.Count | Should -Be 0 + $result.invalidPatternSymbols.Count | Should -Be 7 + $result.invalidStemSymbols.Count | Should -Be 0 + + $result.invalidLowercaseSymbols | Should -Be @(). + $result.invalidPatternSymbols | Should -Be @('TestDrive:\dummy.al:3: #if CLEANT1', 'TestDrive:\dummy.al:6: #if not SCLEAN2', 'TestDrive:\dummy.al:9: #if SUPERCLEAN3', 'TestDrive:\dummy.al:10: #elseif CLEANMORE4', 'TestDrive:\dummy.al:13: #if FUBAR', 'TestDrive:\dummy.al:19: #if RELEASE', 'TestDrive:\dummy.al:22: #if not RELEASE12') + $result.invalidStemSymbols | Should -Be @(). + } + + It 'returns invalidStemSymbols when the symbol is not all uppercase' { + $alcontent = @( +'codeunit 123 TestPreprocessors +{ +#if clean1 +#endif + +#if not Clean2 +#endif + +#if ClEaN3 +#else +#endif + +#if cleaN4 +#elseif CleaN5 +#endif +}') + Set-Content -Path TestDrive:\Dummy.al -Value $alcontent + Mock -CommandName Get-Content { return Get-Content TestDrive:\dummy.al} + + $result = Test-PreprocessorSymbols -filePath 'TestDrive:\dummy.al' -symbolConfigs @(@{'stem' = "CLEAN"; 'lowerBound' = 1; 'upperBound' = 5}) + + $result.count | Should -Be 3 + $result.invalidLowercaseSymbols.Count | Should -Be 0 + $result.invalidPatternSymbols.Count | Should -Be 0 + $result.invalidStemSymbols.Count | Should -Be 5 + + $result.invalidLowercaseSymbols | Should -Be @(). + $result.invalidPatternSymbols | Should -Be @(). + $result.invalidStemSymbols | Should -Be @('TestDrive:\dummy.al:3: #if clean1', 'TestDrive:\dummy.al:6: #if not Clean2', 'TestDrive:\dummy.al:9: #if ClEaN3', 'TestDrive:\dummy.al:13: #if cleaN4', 'TestDrive:\dummy.al:14: #elseif CleaN5'). + } + + + It 'returns errors' { + $alcontent = @( +'codeunit 123 TestPreprocessors +{ +#if not CLEAN18 +#endif + +# if CLEAN25 +#ELSE +#endif + +#if not CLEANschema22 +#endif + +#if CLEANUP12 +#elseif CLEANSCHEMA34 +#endif +}') + Set-Content -Path TestDrive:\Dummy.al -Value $alcontent + Mock -CommandName Get-Content { return Get-Content TestDrive:\dummy.al} + + $symbolConfigs = @( + @{stem = "CLEAN"; lowerBound = 22; upperBound = 26}, + @{stem = "CLEANSCHEMA"; lowerBound = 15; upperBound = 29} + ) + + $result = Test-PreprocessorSymbols -filePath 'TestDrive:\dummy.al' -symbolConfigs $symbolConfigs + + $result.count | Should -Be 3 + $result.invalidLowercaseSymbols.Count | Should -Be 1 + $result.invalidPatternSymbols.Count | Should -Be 4 + $result.invalidStemSymbols.Count | Should -Be 1 + + $result.invalidLowercaseSymbols | Should -Be @('TestDrive:\dummy.al:7: #ELSE'). + $result.invalidPatternSymbols | Should -Be @('TestDrive:\dummy.al:3: #if not CLEAN18', 'TestDrive:\dummy.al:6: # if CLEAN25', 'TestDrive:\dummy.al:13: #if CLEANUP12', 'TestDrive:\dummy.al:14: #elseif CLEANsCHEMA34'). + $result.invalidStemSymbols | Should -Be @('TestDrive:\dummy.al:10: #if not CLEANschema22'). + } +} From 8095f7be8299ab08b899b1f39aae9d3ee35f61e6 Mon Sep 17 00:00:00 2001 From: mazhelez Date: Fri, 20 Sep 2024 16:18:36 +0200 Subject: [PATCH 12/19] Add job to run PS tests --- .github/workflows/powershell.yaml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/powershell.yaml b/.github/workflows/powershell.yaml index 86df1b6ec2..2094ef903a 100644 --- a/.github/workflows/powershell.yaml +++ b/.github/workflows/powershell.yaml @@ -1,8 +1,4 @@ -# https://github.com/microsoft/action-psscriptanalyzer -# For more information on PSScriptAnalyzer in general, see -# https://github.com/PowerShell/PSScriptAnalyzer - -name: PSScriptAnalyzer +name: 'PS Goodies' on: push: @@ -16,8 +12,11 @@ permissions: contents: read jobs: - build: - name: PSScriptAnalyzer + PSScriptAnalyzer: + # https://github.com/microsoft/action-psscriptanalyzer + # For more information on PSScriptAnalyzer in general, see + # https://github.com/PowerShell/PSScriptAnalyzer + name: Run PSScriptAnalyzer runs-on: ubuntu-latest permissions: security-events: write # for github/codeql-action/upload-sarif to upload SARIF results @@ -37,3 +36,13 @@ jobs: uses: github/codeql-action/upload-sarif@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7 with: sarif_file: results.sarif + + RunTests: + name: Run PS Tests + runs-on: windows-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Run PS Tests + run: | + . (Join-Path "." "build/scripts/tests/runTests.ps1") \ No newline at end of file From 8fa24f1bd6c71651ba3056dc2f0d22701e1968ce Mon Sep 17 00:00:00 2001 From: mazhelez Date: Fri, 20 Sep 2024 16:28:13 +0200 Subject: [PATCH 13/19] Add runTests.ps1 --- build/scripts/tests/runTests.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 build/scripts/tests/runTests.ps1 diff --git a/build/scripts/tests/runTests.ps1 b/build/scripts/tests/runTests.ps1 new file mode 100644 index 0000000000..0ca5ebd449 --- /dev/null +++ b/build/scripts/tests/runTests.ps1 @@ -0,0 +1,7 @@ +$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + +$result = Invoke-Pester @(Get-ChildItem -Path (Join-Path $PSScriptRoot "*.Test.ps1")) -passthru + +if ($result.FailedCount -gt 0) { + throw "$($result.FailedCount) tests are failing" +} \ No newline at end of file From c22aad09f70401d0931ebcecdf94d1a5ee4e7eab Mon Sep 17 00:00:00 2001 From: mazhelez Date: Fri, 20 Sep 2024 16:33:03 +0200 Subject: [PATCH 14/19] Fix failing tests --- .../tests/TestPreprocessorSymbols.Test.ps1 | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/build/scripts/tests/TestPreprocessorSymbols.Test.ps1 b/build/scripts/tests/TestPreprocessorSymbols.Test.ps1 index c64d483768..de5d6b1413 100644 --- a/build/scripts/tests/TestPreprocessorSymbols.Test.ps1 +++ b/build/scripts/tests/TestPreprocessorSymbols.Test.ps1 @@ -8,7 +8,7 @@ Describe "Test-PreprocessorSymbols" { $result | Should -Be $null } - It 'returns empty invalidLowercaseSymbols, invalidPatternSymbols and invalidStemSymbols when the file contains lowercase preprocessors with correct symbols and versions' { + It 'returns $null when the file contains lowercase preprocessors with correct symbols and versions' { $alcontent = @( 'codeunit 123 TestPreprocessors { @@ -31,17 +31,10 @@ Describe "Test-PreprocessorSymbols" { $result = Test-PreprocessorSymbols -filePath 'TestDrive:\dummy.al' -symbolConfigs @(@{'stem' = "CLEAN"; 'lowerBound' = 1; 'upperBound' = 5}) - $result.count | Should -Be 0 - $result.invalidLowercaseSymbols.Count | Should -Be 0 - $result.invalidPatternSymbols.Count | Should -Be 0 - $result.invalidStemSymbols.Count | Should -Be 0 - - $result.invalidLowercaseSymbols | Should -Be @(). - $result.invalidPatternSymbols | Should -Be @(). - $result.invalidStemSymbols | Should -Be @(). + $result | Should -Be $null } - It 'returns empty invalidLowercaseSymbols, invalidPatternSymbols and invalidStemSymbols when the file contains lowercase preprocessors with multiple correct symbolstems and versions' { + It 'returns $null when the file contains lowercase preprocessors with multiple correct symbolstems and versions' { $alcontent = @( 'codeunit 123 TestPreprocessors { @@ -65,14 +58,7 @@ Describe "Test-PreprocessorSymbols" { ) $result = Test-PreprocessorSymbols -filePath 'TestDrive:\dummy.al' -symbolConfigs $symbolConfigs - $result.count | Should -Be 0 - $result.invalidLowercaseSymbols.Count | Should -Be 0 - $result.invalidPatternSymbols.Count | Should -Be 0 - $result.invalidStemSymbols.Count | Should -Be 0 - - $result.invalidLowercaseSymbols | Should -Be @(). - $result.invalidPatternSymbols | Should -Be @(). - $result.invalidStemSymbols | Should -Be @(). + $result | Should -Be $null } It 'returns invalidLowercaseSymbols when the file contains not lowercase preprocessor symbols' { From 3e3f7f0f0ab408b3fc55e09366b486200bdc4553 Mon Sep 17 00:00:00 2001 From: Gert Robyns Date: Mon, 23 Sep 2024 08:20:27 +0000 Subject: [PATCH 15/19] review comments --- .github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 | 2 +- .github/actions/VerifyAppChanges/action.yaml | 4 ++-- .github/workflows/VerifyAppChanges.yaml | 4 ++-- .github/workflows/powershell.yaml | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 b/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 index d2b56e0451..97f45fbddf 100644 --- a/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 +++ b/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 @@ -14,7 +14,7 @@ $currentVersion = (Get-ConfigValue -Key "repoVersion" -ConfigType AL-Go) -split if ($CurrentVersion -le 26) { $schemaLowerBound = 15 } else { - $schemaLowerBound = ([math]::Floor(($CurrentVersion - 2) / 5) * 5) - 2 + $schemaLowerBound = ([math]::Floor(($CurrentVersion - 2) / 5) * 5) - 2 # makes a series: 23, 28, 33, 38, 43 etc. This is the version is which we clean up (26, 31, 36, etc.) - 3. } # Define the preprocessor symbols to check for diff --git a/.github/actions/VerifyAppChanges/action.yaml b/.github/actions/VerifyAppChanges/action.yaml index 56468f2936..af8ca6d7ad 100644 --- a/.github/actions/VerifyAppChanges/action.yaml +++ b/.github/actions/VerifyAppChanges/action.yaml @@ -1,6 +1,6 @@ -name: Verify App Changes +name: Test Preprocessor Symbols author: Microsoft Corporation -description: Verifies the changes on AL files changed in a PR +description: Verifies the preprocessor symbols on .al files changed in a PR runs: using: composite steps: diff --git a/.github/workflows/VerifyAppChanges.yaml b/.github/workflows/VerifyAppChanges.yaml index ddbbad19e5..ce8a08d471 100644 --- a/.github/workflows/VerifyAppChanges.yaml +++ b/.github/workflows/VerifyAppChanges.yaml @@ -14,8 +14,8 @@ jobs: name: Verify App Changes steps: - name: checkout - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: ref: ${{ github.sha }} - - uses: microsoft/BCApps/.github/actions/VerifyAppChanges@features/549296 + - uses: microsoft/BCApps/.github/actions/VerifyAppChanges@main diff --git a/.github/workflows/powershell.yaml b/.github/workflows/powershell.yaml index 2094ef903a..0c1e9617c6 100644 --- a/.github/workflows/powershell.yaml +++ b/.github/workflows/powershell.yaml @@ -1,4 +1,4 @@ -name: 'PS Goodies' +name: 'PowerShell tests' on: push: @@ -13,7 +13,7 @@ permissions: jobs: PSScriptAnalyzer: - # https://github.com/microsoft/action-psscriptanalyzer + # https://github.com/microsoft/psscriptanalyzer-action # For more information on PSScriptAnalyzer in general, see # https://github.com/PowerShell/PSScriptAnalyzer name: Run PSScriptAnalyzer From 1550886435ad031ea36bd9e6f60ebea8b075ab57 Mon Sep 17 00:00:00 2001 From: Gert Robyns Date: Mon, 23 Sep 2024 10:58:42 +0200 Subject: [PATCH 16/19] let's see if this works --- .github/workflows/VerifyAppChanges.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/VerifyAppChanges.yaml b/.github/workflows/VerifyAppChanges.yaml index ce8a08d471..8329501cd6 100644 --- a/.github/workflows/VerifyAppChanges.yaml +++ b/.github/workflows/VerifyAppChanges.yaml @@ -18,4 +18,4 @@ jobs: with: ref: ${{ github.sha }} - - uses: microsoft/BCApps/.github/actions/VerifyAppChanges@main + - uses: microsoft/BCApps/.github/actions/VerifyAppChanges@3e3f7f0f0ab408b3fc55e09366b486200bdc4553 From cedb78a7972da09fcdaf9ccaa86aef0ded2b5da7 Mon Sep 17 00:00:00 2001 From: mazhelez Date: Mon, 23 Sep 2024 11:48:24 +0200 Subject: [PATCH 17/19] Rename action folder --- .../action.ps1} | 0 .../{VerifyAppChanges => TestPreprocessorSymbols}/action.yaml | 4 ++-- .github/workflows/VerifyAppChanges.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename .github/actions/{VerifyAppChanges/TestPreprocessorSymbols.ps1 => TestPreprocessorSymbols/action.ps1} (100%) rename .github/actions/{VerifyAppChanges => TestPreprocessorSymbols}/action.yaml (59%) diff --git a/.github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 b/.github/actions/TestPreprocessorSymbols/action.ps1 similarity index 100% rename from .github/actions/VerifyAppChanges/TestPreprocessorSymbols.ps1 rename to .github/actions/TestPreprocessorSymbols/action.ps1 diff --git a/.github/actions/VerifyAppChanges/action.yaml b/.github/actions/TestPreprocessorSymbols/action.yaml similarity index 59% rename from .github/actions/VerifyAppChanges/action.yaml rename to .github/actions/TestPreprocessorSymbols/action.yaml index af8ca6d7ad..6a4901c90a 100644 --- a/.github/actions/VerifyAppChanges/action.yaml +++ b/.github/actions/TestPreprocessorSymbols/action.yaml @@ -1,13 +1,13 @@ name: Test Preprocessor Symbols author: Microsoft Corporation -description: Verifies the preprocessor symbols on .al files changed in a PR +description: Verifies the preprocessor symbols on .al files runs: using: composite steps: - name: Test Preprocessor Symbols shell: pwsh run: | - ${{ github.action_path }}/TestPreprocessorSymbols.ps1 + ${{ github.action_path }}/action.ps1 branding: icon: terminal color: blue diff --git a/.github/workflows/VerifyAppChanges.yaml b/.github/workflows/VerifyAppChanges.yaml index 8329501cd6..08086a1785 100644 --- a/.github/workflows/VerifyAppChanges.yaml +++ b/.github/workflows/VerifyAppChanges.yaml @@ -18,4 +18,4 @@ jobs: with: ref: ${{ github.sha }} - - uses: microsoft/BCApps/.github/actions/VerifyAppChanges@3e3f7f0f0ab408b3fc55e09366b486200bdc4553 + - uses: microsoft/BCApps/.github/actions/TestPreprocessorSymbols@features/549296 From 07fac421f0de19cc2fecb557d602c3d1523b3522 Mon Sep 17 00:00:00 2001 From: Maria Zhelezova <43066499+mazhelez@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:54:02 +0200 Subject: [PATCH 18/19] Use SHA for action ref (to be changed to main afterwards) --- .github/workflows/VerifyAppChanges.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/VerifyAppChanges.yaml b/.github/workflows/VerifyAppChanges.yaml index 08086a1785..9b606d3006 100644 --- a/.github/workflows/VerifyAppChanges.yaml +++ b/.github/workflows/VerifyAppChanges.yaml @@ -18,4 +18,4 @@ jobs: with: ref: ${{ github.sha }} - - uses: microsoft/BCApps/.github/actions/TestPreprocessorSymbols@features/549296 + - uses: microsoft/BCApps/.github/actions/TestPreprocessorSymbols@cedb78a7972da09fcdaf9ccaa86aef0ded2b5da7 From a35a643392e580e9a2ffe2f79b08e95248bf4862 Mon Sep 17 00:00:00 2001 From: Maria Zhelezova <43066499+mazhelez@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:54:58 +0200 Subject: [PATCH 19/19] Rename workflow --- .github/workflows/{powershell.yaml => PowerShell.yaml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{powershell.yaml => PowerShell.yaml} (94%) diff --git a/.github/workflows/powershell.yaml b/.github/workflows/PowerShell.yaml similarity index 94% rename from .github/workflows/powershell.yaml rename to .github/workflows/PowerShell.yaml index 0c1e9617c6..31e8436971 100644 --- a/.github/workflows/powershell.yaml +++ b/.github/workflows/PowerShell.yaml @@ -1,4 +1,4 @@ -name: 'PowerShell tests' +name: 'PowerShell' on: push: @@ -45,4 +45,4 @@ jobs: - name: Run PS Tests run: | - . (Join-Path "." "build/scripts/tests/runTests.ps1") \ No newline at end of file + . (Join-Path "." "build/scripts/tests/runTests.ps1")