Skip to content

Commit 65ff245

Browse files
Freddy Kristiansenfreddydk
andauthored
Remove thisbuild artifacts and support preprocessor symbols (#1374)
This is a proposed fix for https://github.com/orgs/microsoft/projects/521/views/1?pane=issue&itemId=91449371 and will greatly improve the capabilities of build modes (as requested by partners during our roundtable at Directions EMEA).   ### New Repository Settings - [`shortLivedArtifactsRetentionDays`](https://aka.ms/algosettings#shortLivedArtifactsRetentionDays) determines the number of days to keep short lived build artifacts (f.ex build artifacts from pull request builds, next minor or next major builds). 1 is default. 0 means use GitHub default. - [`preProcessorSymbols`](https://aka.ms/algosettings#preProcessorSymbols) is a list of preprocessor symbols to use when building the apps. This setting can be specified in workflow specific settings files or in conditional settings. ### Change in published artifacts When using `useProjectDependencies` in a multi-project repository, AL-Go for GitHub used to generate short lived build artifacts called `thisBuild-<projectnaame>-<type>-...`. This is no longer the case. Instead, normal build artifacts will be published and used by depending projects. The retention period for the artifacts generated are controlled by a settings called [`shortLivedArtifactsRetentionDays`](https://aka.ms/algosettings#shortLivedArtifactsRetentionDays). ### Preprocessor symbols It is now possible to define preprocessor symbols, which will be used when building your apps using the [`preProcessorSymbols`](https://aka.ms/algosettings#preProcessorSymbols) setting. This setting can be specified in workflow specific settings file or it can be used in conditional settings. --------- Co-authored-by: freddydk <[email protected]>
1 parent 9564abf commit 65ff245

27 files changed

+167
-171
lines changed

Actions/AL-Go-Helper.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ function ReadSettings {
522522
[string] $baseFolder = "$ENV:GITHUB_WORKSPACE",
523523
[string] $repoName = "$ENV:GITHUB_REPOSITORY",
524524
[string] $project = '.',
525+
[string] $buildMode = "Default",
525526
[string] $workflowName = "$ENV:GITHUB_WORKFLOW",
526527
[string] $userName = "$ENV:GITHUB_ACTOR",
527528
[string] $branchName = "$ENV:GITHUB_REF_NAME",
@@ -686,6 +687,7 @@ function ReadSettings {
686687
}
687688
"useGitSubmodules" = "false"
688689
"gitSubmodulesTokenSecretName" = "gitSubmodulesToken"
690+
"shortLivedArtifactsRetentionDays" = 1 # 0 means use GitHub default
689691
}
690692

691693
# Read settings from files and merge them into the settings object
@@ -730,6 +732,10 @@ function ReadSettings {
730732
if ("$conditionalSetting" -ne "") {
731733
$conditionMet = $true
732734
$conditions = @()
735+
if ($conditionalSetting.PSObject.Properties.Name -eq "buildModes") {
736+
$conditionMet = $conditionMet -and ($conditionalSetting.buildModes | Where-Object { $buildMode -like $_ })
737+
$conditions += @("buildMode: $buildMode")
738+
}
733739
if ($conditionalSetting.PSObject.Properties.Name -eq "branches") {
734740
$conditionMet = $conditionMet -and ($conditionalSetting.branches | Where-Object { $branchName -like $_ })
735741
$conditions += @("branchName: $branchName")

Actions/CalculateArtifactNames/CalculateArtifactNames.ps1

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,3 @@ else {
5454
$value = "$($projectName)-$($branchName)-$buildMode$_-$suffix"
5555
Set-OutputVariable -name $name -value $value
5656
}
57-
58-
# Set this build artifacts name
59-
'Apps', 'Dependencies', 'TestApps' | ForEach-Object {
60-
$name = "ThisBuild$($_)ArtifactsName"
61-
$value = "thisbuild-$($projectName)-$($buildMode)$($_)"
62-
Set-OutputVariable -name $name -value $value
63-
}

Actions/CalculateArtifactNames/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ none
2929

3030
| Name | Description |
3131
| :-- | :-- |
32-
| ThisBuildAppsArtifactsName | Artifact name for apps being built in the current workflow run |
33-
| ThisBuildDependenciesArtifactsName | Artifact name for dependencies of apps being built in the current workflow run |
34-
| ThisBuildTestAppsArtifactsName | Artifact name for test apps being built in the current workflow run |
3532
| AppsArtifactsName | Artifacts name for Apps |
3633
| PowerPlatformSolutionArtifactsName | Artifacts name for PowerPlatform Solution |
3734
| DependenciesArtifactsName | Artifacts name for Dependencies |

Actions/CalculateArtifactNames/action.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ inputs:
1616
required: false
1717
default: ''
1818
outputs:
19-
ThisBuildAppsArtifactsName:
20-
description: Artifact name for apps being built in the current workflow run
21-
value: ${{ steps.calculateartifactnames.outputs.ThisBuildAppsArtifactsName }}
22-
ThisBuildDependenciesArtifactsName:
23-
description: Artifact name for dependencies of apps being built in the current workflow run
24-
value: ${{ steps.calculateartifactnames.outputs.ThisBuildDependenciesArtifactsName }}
25-
ThisBuildTestAppsArtifactsName:
26-
description: Artifact name for test apps being built in the current workflow run
27-
value: ${{ steps.calculateartifactnames.outputs.ThisBuildTestAppsArtifactsName }}
2819
AppsArtifactsName:
2920
description: Artifacts name for Apps
3021
value: ${{ steps.calculateartifactnames.outputs.AppsArtifactsName }}

Actions/Github-Helper.psm1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ function GetDependencies {
141141
if ($dependency.release_status -eq "thisBuild") {
142142
$missingProjects = @()
143143
foreach($project in $projects.Split(',')) {
144+
$branchName = $dependency.branch.Replace('\', '_').Replace('/', '_')
144145
$project = $project.Replace('\','_').Replace('/','_') # sanitize project name
145146

146-
$downloadName = Join-Path $saveToPath "thisbuild-$project-$($mask)"
147+
$downloadName = Join-Path $saveToPath "$project-$branchName-$mask-*"
147148

148149
if (Test-Path $downloadName -PathType Container) {
149150
$folder = Get-Item $downloadName

Actions/ReadSettings/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ none
1414
| :-- | :-: | :-- | :-- |
1515
| shell | | The shell (powershell or pwsh) in which the PowerShell script in this action should run | powershell |
1616
| project | | Project name if the repository is setup for multiple projects | . |
17+
| buildMode | | Build mode. Only set when called from \_BuildALGoProject | Default |
1718
| get | | Specifies which properties to get from the settings file, default is all | |
1819

1920
## OUTPUT

Actions/ReadSettings/ReadSettings.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
Param(
22
[Parameter(HelpMessage = "Project folder", Mandatory = $false)]
33
[string] $project = ".",
4+
[Parameter(HelpMessage = "Build mode", Mandatory = $false)]
5+
[string] $buildMode = "Default",
46
[Parameter(HelpMessage = "Specifies which properties to get from the settings file, default is all", Mandatory = $false)]
57
[string] $get = ""
68
)
79

810
. (Join-Path -Path $PSScriptRoot -ChildPath "..\AL-Go-Helper.ps1" -Resolve)
911

10-
$settings = ReadSettings -project $project
12+
$settings = ReadSettings -project $project -buildMode $buildMode
1113
if ($get) {
1214
$getSettings = $get.Split(',').Trim()
1315
}

Actions/ReadSettings/action.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ inputs:
99
description: Project folder
1010
required: false
1111
default: '.'
12+
buildMode:
13+
description: Build mode
14+
required: false
15+
default: 'Default'
1216
get:
1317
description: Specifies which properties to get from the settings file, default is all
1418
required: false
@@ -28,10 +32,11 @@ runs:
2832
id: readsettings
2933
env:
3034
_project: ${{ inputs.project }}
35+
_buildMode: ${{ inputs.buildMode }}
3136
_get: ${{ inputs.get }}
3237
run: |
3338
${{ github.action_path }}/../Invoke-AlGoAction.ps1 -ActionName "ReadSettings" -Action {
34-
${{ github.action_path }}/ReadSettings.ps1 -project $ENV:_project -get $ENV:_get
39+
${{ github.action_path }}/ReadSettings.ps1 -project $ENV:_project -buildMode $ENV:_buildMode -get $ENV:_get
3540
}
3641
branding:
3742
icon: terminal

Actions/RunPipeline/RunPipeline.ps1

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -368,27 +368,29 @@ try {
368368
if ($settings."$_") { $runAlPipelineParams += @{ "$_" = $true } }
369369
}
370370

371-
switch($buildMode){
372-
'Clean' {
373-
$preprocessorsymbols = $settings.cleanModePreprocessorSymbols
371+
if ($buildMode -eq 'Translated') {
372+
if ($runAlPipelineParams.Keys -notcontains 'features') {
373+
$runAlPipelineParams["features"] = @()
374+
}
375+
Write-Host "Adding translationfile feature"
376+
$runAlPipelineParams["features"] += "translationfile"
377+
}
374378

375-
if (!$preprocessorsymbols) {
376-
throw "No cleanModePreprocessorSymbols defined in settings.json for this project. Please add the preprocessor symbols to use when building in clean mode or disable CLEAN mode."
377-
}
379+
if ($runAlPipelineParams.Keys -notcontains 'preprocessorsymbols') {
380+
$runAlPipelineParams["preprocessorsymbols"] = @()
381+
}
378382

379-
if ($runAlPipelineParams.Keys -notcontains 'preprocessorsymbols') {
380-
$runAlPipelineParams["preprocessorsymbols"] = @()
381-
}
383+
# REMOVE AFTER April 1st 2025 --->
384+
if ($settings.ContainsKey('cleanModePreprocessorSymbols')) {
385+
Write-Host "Adding Preprocessor symbols : $($settings.cleanModePreprocessorSymbols -join ',')"
386+
$runAlPipelineParams["preprocessorsymbols"] += $settings.cleanModePreprocessorSymbols
387+
Write-Warning -message "cleanModePreprocessorSymbols is deprecated. See https://aka.ms/ALGoDeprecations#cleanModePreprocessorSymbols for more information."
388+
}
389+
# <--- REMOVE AFTER April 1st 2025
382390

383-
Write-Host "Adding Preprocessor symbols: $preprocessorsymbols"
384-
$runAlPipelineParams["preprocessorsymbols"] += $preprocessorsymbols
385-
}
386-
'Translated' {
387-
if ($runAlPipelineParams.Keys -notcontains 'features') {
388-
$runAlPipelineParams["features"] = @()
389-
}
390-
$runAlPipelineParams["features"] += "translationfile"
391-
}
391+
if ($settings.ContainsKey('preprocessorSymbols')) {
392+
Write-Host "Adding Preprocessor symbols : $($settings.preprocessorSymbols -join ',')"
393+
$runAlPipelineParams["preprocessorsymbols"] += $settings.preprocessorSymbols
392394
}
393395

394396
Write-Host "Invoke Run-AlPipeline with buildmode $buildMode"

DEPRECATIONS.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Deprecated features in AL-Go for GitHub
2+
3+
This file contains a list of deprecations in AL-Go for GitHub, sorted by the date after which the support will be removed.
4+
5+
## Old AL-Go versions might stop working any time
6+
7+
Microsoft recommends that you always run the latest version of AL-Go for GitHub.
8+
9+
Old versions of AL-Go for GitHub uses old and unsupported versions of GitHub actions, which might be removed or no longer work due to unresolved dependencies no longer being installed on the GitHub runners.
10+
11+
When handling support requests, we will request that you to use the latest version of AL-Go for GitHub and in general, fixes will only be made available in a preview version of AL-Go for GitHub and subsequently in the next version released.
12+
13+
## Changes in effect after April 1st 2025
14+
15+
<a id="cleanModePreprocessorSymbols"></a>
16+
17+
### Setting `cleanModePreprocessorSymbols` will no longer be supported
18+
19+
[preprocessorSymbols](https://aka.ms/algosettings#preprocessorSymbols) are now supported as a global setting and can be applied to buildModes using [Conditional Settings](https://aka.ms/algosettings#conditional-settings). Example:
20+
21+
```
22+
"conditionalSettings": [
23+
{
24+
"buildModes": [ "Clean" ],
25+
"settings": {
26+
"preprocessorSymbols": [ "CLEAN21", "CLEAN22" ]
27+
}
28+
}
29+
]
30+
```

0 commit comments

Comments
 (0)