Enhance customALGoFiles feature#2273
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR enhances the customALGoFiles behavior during “Update AL-Go System Files”, adding support for unconditional removals (filesToRemove) and improving custom-template behavior by merging template settings directly and resolving files from the original AL-Go template where applicable.
Changes:
- Add
customALGoFiles.filesToRemovesupport end-to-end (schema, defaults, resolution logic, docs, and release notes). - Update
CheckForUpdatesto read template repo settings viaReadSettingsand merge template settings during file resolution. - Expand automated coverage (unit + e2e) for include/exclude/remove resolution and custom-template propagation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| e2eTests/scenarios/CustomTemplate/runtest.ps1 | Extends e2e scenario to validate custom-template file include/exclude/remove propagation and workflow presence. |
| Tests/CheckForUpdates.Action.Test.ps1 | Adds unit tests for destination-folder resolution and expanded GetFilesToUpdate behaviors (including filesToRemove). |
| Actions/CheckForUpdates/CheckForUpdates.ps1 | Updates settings reading (incl. trigger) and wires template settings + filesToRemove into update/removal flow. |
| Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 | Implements ResolveFilePathsInDestinationFolder and extends GetFilesToUpdate to produce include/exclude/remove lists. |
| Actions/.Modules/settings.schema.json | Extends settings schema with customALGoFiles.filesToRemove and clarifying descriptions. |
| Actions/.Modules/ReadSettings.psm1 | Adds default filesToRemove array under customALGoFiles. |
| Scenarios/settings.md | Documents customALGoFiles.filesToRemove in settings reference. |
| Scenarios/CustomizingALGoForGitHub.md | Adds conceptual docs + examples for original-template resolution and filesToRemove. |
| RELEASENOTES.md | Documents enhanced customALGoFiles behavior and new filesToRemove. |
| if ($file.Keys -contains 'perProject' -and $file.perProject -eq $true) { | ||
| foreach ($project in $projects) { | ||
| if ($project -eq '.') { | ||
| $project = '' # If project is '.', it means the root folder, so we use an empty string | ||
| } | ||
| $projectFolder = Join-Path $destinationFolder $project | ||
| $fullFilePaths += ResolveFilePaths -sourceFolder $projectFolder -destinationFolder $projectFolder -files @($destinationFile) | ||
| } | ||
| } else { | ||
| $fullFilePaths += ResolveFilePaths -sourceFolder $destinationFolder -destinationFolder $destinationFolder -files @($destinationFile) | ||
| } |
There was a problem hiding this comment.
@mazhelez
IMO this issue was already present for all usages of ResolveFilePaths.
I added a fix in function ResolveFilePaths by ensuring the source folder always ends with a directory separator char.
(see 50ad11c#diff-5e08ac55cdd6c0db11d551f356d8f813d74c5a724846be72462c19c3a5ff1ae6R827)
I also added a unit test for this case.
| - `sourceFolder`: A path to a folder, relative to the template, where to look for files. If not specified the root folder is implied. `*` characters are not supported. _Example_: `.github/workflows`. | ||
| - `filter`: A string to use for filtering in the specified source path. It can contain `*` and `?` wildcards. _Example_: `deprecated-*.yaml` or `oldScript.ps1`. | ||
| - `destinationFolder`: A path to a folder, relative to the end repository, where the files are located. If not specified, defaults to the same as the source file folder. _Example_: `.github/workflows`. | ||
| - `perProject`: A boolean that indicates whether the matched files should be removed for all available AL-Go projects. In that case, `destinationFolder` is relative to the project folder. _Example_: `.AL-Go/scripts`. |
There was a problem hiding this comment.
I added the support for destinationName based on the same property of filesToInclude, which is also not documented or defined in the schema.
@mazhelez What do you think about adding the property for filesToInclude and filesToRemove in the documentation and schema?
| "sourceFolder": { | ||
| "type": "string", | ||
| "description": "The source folder from which to remove files, relative to the template repository root." | ||
| }, | ||
| "filter": { | ||
| "type": "string", | ||
| "description": "A filter string to select which files to remove. It can contain '*' and '?' wildcards." | ||
| }, | ||
| "destinationFolder": { | ||
| "type": "string", | ||
| "description": "The destination folder where the files should be removed, relative to the repository root." | ||
| }, | ||
| "perProject": { | ||
| "type": "boolean", | ||
| "description": "Indicates whether the removal should be applied per project. In that case, destinationFolder is relative to each project folder." | ||
| } | ||
| } |
There was a problem hiding this comment.
I added the support for destinationName based on the same property of filesToInclude, which is also not documented or defined in the schema.
@mazhelez What do you think about adding the property for filesToInclude and filesToRemove in the documentation and schema?
|
@mazhelez The failing PS5 tests should be fixed now. |
❔What, Why & How
New file removal feature:
filesToRemovefield to thecustomALGoFilessection in both the in-memory settings and the JSON schema, allowing users to specify files that should always be removed from the repository during updates, regardless of their presence in the template. (Actions/.Modules/ReadSettings.psm1,Actions/.Modules/settings.schema.json) [1] [2]Update logic improvements:
Refactored the logic in
GetFilesToUpdateand related helper functions to mergefilesToInclude,filesToExclude, andfilesToRemovefrom both repository and template settings, propagate removals from upstream templates, and correctly resolve file paths for removal operations. (Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1) [1] [2] [3]Added the
ResolveFilePathsInDestinationFolderfunction to accurately identify files for removal in the target repository, supporting per-project and destination-relative path resolution. (Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1)Telemetry and settings handling:
Enhanced telemetry to track usage of
filesToInclude,filesToExclude, andfilesToRemovefor both repository and template settings, providing better insights into feature adoption. (Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1)Updated the call to
ReadSettingsto include the-triggerparameter, ensuring settings are read with the correct context. (Actions/CheckForUpdates/CheckForUpdates.ps1)Prepared for template settings merging by initializing
$templateRepoSettingsand adjusting template download logic. (Actions/CheckForUpdates/CheckForUpdates.ps1)Related to discussion: #2227
✅ Checklist