Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incremental Builds #1304

Open
wants to merge 235 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 234 commits
Commits
Show all changes
235 commits
Select commit Hold shift + click to select a range
cd0d861
write json
freddydk Nov 9, 2024
5277c11
use sha
freddydk Nov 10, 2024
b008537
syntax
freddydk Nov 10, 2024
d1f9900
use pr sha
freddydk Nov 10, 2024
aaeaa3d
dumps
freddydk Nov 10, 2024
794d1a9
use baseline
freddydk Nov 10, 2024
49b0710
pull
freddydk Nov 10, 2024
a047541
pull
freddydk Nov 10, 2024
2d1bc93
remove empty
freddydk Nov 10, 2024
4e9fe58
add sha
freddydk Nov 10, 2024
e8421a2
branch
freddydk Nov 10, 2024
973b91e
dump
freddydk Nov 10, 2024
6f5275e
dump
freddydk Nov 10, 2024
6455d85
dumps
freddydk Nov 10, 2024
8eb6807
fetch
freddydk Nov 10, 2024
d85db5d
fetch unshallow
freddydk Nov 10, 2024
d9288d0
fetch origin
freddydk Nov 10, 2024
1fc4c54
fetch
freddydk Nov 10, 2024
1cf1db3
add baseline
freddydk Nov 10, 2024
fd92f2b
headp
freddydk Nov 10, 2024
91ad0d5
dispatch
freddydk Nov 10, 2024
2af02e1
branch
freddydk Nov 10, 2024
faf913f
add
freddydk Nov 10, 2024
382fba1
sha
freddydk Nov 10, 2024
bc29279
eq
freddydk Nov 10, 2024
ce1abbb
transfer skipped
freddydk Nov 11, 2024
dc3ebc4
remove syntax err
freddydk Nov 11, 2024
c8f4593
include skipped
freddydk Nov 11, 2024
53e2e78
dump
freddydk Nov 11, 2024
d82a4e4
buildIt
freddydk Nov 11, 2024
0a7ad8f
use action
freddydk Nov 11, 2024
2eef1ce
add env
freddydk Nov 11, 2024
9a17928
)
freddydk Nov 11, 2024
ce85f89
read sett
freddydk Nov 11, 2024
6d5c2ee
rename
freddydk Nov 11, 2024
e9279be
recall getprojects
freddydk Nov 11, 2024
a007fa1
err
freddydk Nov 11, 2024
8833217
add token
freddydk Nov 11, 2024
78c2047
download artifacts
freddydk Nov 11, 2024
5781265
correct folder
freddydk Nov 11, 2024
987c7a7
download and unpack
freddydk Nov 11, 2024
24dc50d
try exists
freddydk Nov 11, 2024
3e7f0d5
use hash
freddydk Nov 11, 2024
c300bbf
add concurrency
freddydk Nov 11, 2024
7e85650
use format
freddydk Nov 11, 2024
3fbef9d
check for artifacts
freddydk Nov 11, 2024
2f5970a
conditional analyze
freddydk Nov 11, 2024
1591d40
set token
freddydk Nov 11, 2024
5a83ef8
ps 5 trick
freddydk Nov 11, 2024
38ef283
check errlevel
freddydk Nov 11, 2024
2775342
use pwsh
freddydk Nov 11, 2024
293d4b7
use ghtoken
freddydk Nov 11, 2024
232ff01
ignore
freddydk Nov 11, 2024
32120fc
use try
freddydk Nov 11, 2024
c5b3dcd
get modified
freddydk Nov 11, 2024
173aaef
arr
freddydk Nov 11, 2024
b5af39a
)
freddydk Nov 11, 2024
34b94b4
find folders
freddydk Nov 12, 2024
8f4dab5
use full path
freddydk Nov 12, 2024
1451f4b
dump
freddydk Nov 12, 2024
9cd8e28
dont join
freddydk Nov 12, 2024
c3d0daf
syntax
freddydk Nov 12, 2024
2694ea5
syntax
freddydk Nov 12, 2024
a294a9e
remove ./
freddydk Nov 12, 2024
cff8a34
test
freddydk Nov 12, 2024
702e818
add runid
freddydk Nov 12, 2024
742c41b
rename
freddydk Nov 12, 2024
ddc3d07
ignore cancelled
freddydk Nov 12, 2024
2e304a5
use projectname
freddydk Nov 12, 2024
aa316d5
use repo name
freddydk Nov 12, 2024
e74238c
use repo
freddydk Nov 12, 2024
90a1255
dump
freddydk Nov 12, 2024
64290ca
create tempfolder
freddydk Nov 12, 2024
c217a7e
download
freddydk Nov 12, 2024
3ef3aae
do not set
freddydk Nov 12, 2024
768d052
s
freddydk Nov 12, 2024
9840475
err
freddydk Nov 12, 2024
9309ae2
use this
freddydk Nov 12, 2024
507ea1e
include project
freddydk Nov 12, 2024
c07156c
buildall
freddydk Nov 12, 2024
a1b2ee4
call
freddydk Nov 12, 2024
95f92d5
parm
freddydk Nov 12, 2024
76880c2
+
freddydk Nov 12, 2024
e6969a6
Merge branch 'main' into partial
freddydk Nov 12, 2024
b104f8f
remove download all
freddydk Nov 13, 2024
e8e9031
Merge branch 'partial' of https://github.com/freddydk/AL-Go into partial
freddydk Nov 13, 2024
cc4f7f5
avoid warning
freddydk Nov 13, 2024
5a62b54
fix precommit
freddydk Nov 13, 2024
604c1fe
only download thisbuild
freddydk Nov 13, 2024
ff99ecd
b
freddydk Nov 13, 2024
b7360be
no double downloads
freddydk Nov 13, 2024
e80fe8d
dump
freddydk Nov 13, 2024
2640c11
remove ()
freddydk Nov 13, 2024
23baf93
add dumps
freddydk Nov 13, 2024
145df8e
fix
freddydk Nov 13, 2024
47c558c
remove dumps
freddydk Nov 13, 2024
a5e9fc9
remove dump
freddydk Nov 13, 2024
cc0bad9
do not issue warnings if donotbuild is set
freddydk Nov 13, 2024
422315a
resolve path
freddydk Nov 13, 2024
4f90bfd
use relative
freddydk Nov 13, 2024
391b53e
use filesystem
freddydk Nov 13, 2024
f138883
use dirsep
freddydk Nov 13, 2024
08171ea
output
freddydk Nov 13, 2024
b4b0f86
-(
freddydk Nov 13, 2024
b58819e
Merge branch 'main' into partial
freddydk Nov 13, 2024
9ad517a
MOVE
freddydk Nov 13, 2024
07286b7
check all folders
freddydk Nov 13, 2024
674e4e3
dump
freddydk Nov 13, 2024
8bdae86
save time
freddydk Nov 13, 2024
ff59a9b
settings
freddydk Nov 13, 2024
2b641ba
always all
freddydk Nov 13, 2024
3d4e8b2
remove dump
freddydk Nov 13, 2024
eb1c5c8
use special
freddydk Nov 13, 2024
0c7e42b
buildmode
freddydk Nov 14, 2024
d84bfa7
rename to incrementalBuilds
freddydk Nov 14, 2024
f19cdc7
set modifiedfiles
freddydk Nov 15, 2024
ef088b0
exit0
freddydk Nov 15, 2024
d1236b5
setshouldexit
freddydk Nov 15, 2024
596edd8
head
freddydk Nov 15, 2024
263235a
using pr head
freddydk Nov 15, 2024
631624c
use artifacts cache
freddydk Nov 15, 2024
db3a07d
move
freddydk Nov 15, 2024
fa8e388
check duplicate
freddydk Nov 16, 2024
f6aa3cc
allowprerel
freddydk Nov 16, 2024
057e5be
()
freddydk Nov 16, 2024
86c28cc
exact
freddydk Nov 16, 2024
748a501
version
freddydk Nov 16, 2024
5c49073
find - not download
freddydk Nov 16, 2024
2692a96
use appjson.version
freddydk Nov 16, 2024
8f261c2
Merge branch 'main' into partial
freddydk Nov 22, 2024
abf4f59
space
freddydk Nov 22, 2024
0613613
Merge branch 'partial' of https://github.com/freddydk/AL-Go into partial
freddydk Nov 22, 2024
1d668d8
review
freddydk Nov 22, 2024
c565875
remove buildPP from appsource template
freddydk Nov 22, 2024
07cd036
precommit
freddydk Nov 22, 2024
eb7d483
Merge branch 'main' into partial
freddydk Nov 22, 2024
f52120c
Merge branch 'main' into partial
freddydk Nov 28, 2024
8bec033
no incremental
freddydk Dec 9, 2024
0642e8b
spell
freddydk Dec 10, 2024
4e8572f
Merge branch 'main' into partial
freddydk Dec 10, 2024
a371a9b
change parameter name
freddydk Dec 10, 2024
0d2ae93
Merge branch 'partial' of https://github.com/freddydk/AL-Go into partial
freddydk Dec 10, 2024
72ccf70
enable
freddydk Dec 12, 2024
83cb87c
fix tests
freddydk Dec 12, 2024
a4b46f6
remove dumps
freddydk Dec 12, 2024
e3e59f7
precommit
freddydk Dec 12, 2024
3d883ee
use preview
freddydk Dec 12, 2024
8e09a7a
ped
freddydk Dec 13, 2024
2aa69e7
add unknown
freddydk Dec 13, 2024
4b50bd8
add knownApps
freddydk Dec 13, 2024
aae75b7
arr
freddydk Dec 13, 2024
7e1178e
add project
freddydk Dec 13, 2024
faf8f90
all folders
freddydk Dec 14, 2024
1f2a607
add project
freddydk Dec 14, 2024
665e84f
dump
freddydk Dec 14, 2024
f9303e3
sub 2
freddydk Dec 14, 2024
39547d9
add end 2 end test
freddydk Dec 15, 2024
60f0b2f
review
freddydk Dec 15, 2024
0f934ff
-bash
freddydk Dec 15, 2024
61a6a77
-linux
freddydk Dec 15, 2024
23bb87f
release notes and settings
freddydk Dec 15, 2024
020dfa5
Merge branch 'main' into partial
freddydk Dec 15, 2024
796ccdb
remove mode
freddydk Dec 16, 2024
dfb42b8
Merge branch 'partial' of https://github.com/freddydk/AL-Go into partial
freddydk Dec 16, 2024
0b68f06
add cancelinprogress setting
freddydk Dec 16, 2024
ab06358
bool
freddydk Dec 16, 2024
c334581
replace
freddydk Dec 16, 2024
4516ae9
concurrency setting
freddydk Dec 16, 2024
8e578b5
move
freddydk Dec 16, 2024
c6be36e
default allowed
freddydk Dec 16, 2024
dd1dee0
update docs
freddydk Dec 16, 2024
53c2414
fix e2e test
freddydk Dec 16, 2024
ca1b3b7
precommit
freddydk Dec 16, 2024
e6f2eea
doc
freddydk Dec 16, 2024
619c5b4
Merge branch 'main' into partial
freddydk Dec 16, 2024
6dc589b
Merge branch 'main' into partial
freddydk Dec 18, 2024
be1253c
move
freddydk Dec 18, 2024
17e571a
move2
freddydk Dec 18, 2024
9596353
Merge branch 'main' into partial
freddydk Dec 18, 2024
6ce0007
Merge branch 'main' into partial
freddydk Dec 18, 2024
5b0c838
Merge branch 'main' into partial
freddydk Dec 30, 2024
932ab42
Merge branch 'main' into partial
freddydk Dec 30, 2024
466f671
Merge branch 'main' into partial
freddydk Jan 9, 2025
8a8bc7c
Merge branch 'main' into partial
freddydk Jan 10, 2025
360d6db
fix
freddydk Jan 10, 2025
3f61918
Merge branch 'partial' of https://github.com/freddydk/AL-Go into partial
freddydk Jan 10, 2025
274aacd
Update e2eTests/scenarios/IncrementalBuilds/runtest.ps1
freddydk Jan 10, 2025
b84b4d1
Update Actions/DetermineProjectsToBuild/action.yaml
freddydk Jan 10, 2025
ca7cdbe
review
freddydk Jan 10, 2025
99745be
incremental
freddydk Jan 10, 2025
cfd9e87
doc
freddydk Jan 10, 2025
6252d0d
remove concurrency
freddydk Jan 10, 2025
f053d67
lines
freddydk Jan 10, 2025
fbcd0e2
space
freddydk Jan 10, 2025
8d88d67
Merge branch 'main' into partial
freddydk Jan 14, 2025
1fa094c
Merge branch 'main' into partial
freddydk Jan 14, 2025
7c1a37e
Merge branch 'main' into partial
freddydk Jan 16, 2025
fdbef48
Merge branch 'main' into partial
freddydk Jan 16, 2025
332e2cc
review
freddydk Jan 16, 2025
a068ef1
new modification of yaml
freddydk Jan 18, 2025
46a1fae
loop
freddydk Jan 19, 2025
43b0770
prop
freddydk Jan 19, 2025
0b73f18
dump
freddydk Jan 19, 2025
0a2a2f1
buildmode ''
freddydk Jan 19, 2025
6d26d7e
add branchsha
freddydk Jan 19, 2025
469bd0c
7
freddydk Jan 19, 2025
50fa2d2
add deprecation
freddydk Jan 19, 2025
79543b8
add deorecations to troubleshooting
freddydk Jan 20, 2025
890dbf3
add deprecation tests
freddydk Jan 20, 2025
1910274
add err
freddydk Jan 20, 2025
fb7002a
test
freddydk Jan 21, 2025
90a752b
fix
freddydk Jan 21, 2025
aa3fdde
use preview
freddydk Jan 21, 2025
8f431aa
Merge branch 'main' into partial
freddydk Jan 25, 2025
3bd5805
rename parameter
freddydk Jan 25, 2025
f259633
full build on schedule
freddydk Jan 27, 2025
61ee3f1
thisbuild artifacts no longer exists
freddydk Jan 27, 2025
815cc50
Modify settings
freddydk Jan 29, 2025
7a21c94
md
freddydk Jan 29, 2025
25af796
use github_event_name
freddydk Jan 29, 2025
bfe4058
e2e
freddydk Jan 29, 2025
015d3a5
Merge branch 'main' into partial
freddydk Jan 30, 2025
1bebd9c
review
freddydk Jan 30, 2025
ec0c3f5
Merge branch 'partial' of https://github.com/freddydk/AL-Go into partial
freddydk Jan 30, 2025
9d962ca
move
freddydk Jan 30, 2025
9f78686
move
freddydk Jan 30, 2025
2bdba91
back
freddydk Jan 30, 2025
e16eaaf
Merge branch 'main' into partial
freddydk Jan 31, 2025
549c7e6
env ghtoken
freddydk Jan 31, 2025
1b44912
use token parameter
freddydk Jan 31, 2025
8c8a755
use e2epat parameter
freddydk Jan 31, 2025
a746505
add dollar
freddydk Jan 31, 2025
9ac9c77
s
freddydk Jan 31, 2025
6419484
fix merge problem and e2e failure
freddydk Feb 1, 2025
fffdd57
Update Actions/Github-Helper.psm1
freddydk Feb 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ updates:
directories:
- ".github/workflows/"
- "/Templates/**/.github/workflows/"
- "/Actions/**/"
groups:
External-Dependencies:
applies-to: version-updates
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CleanupTempRepos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
Import-Module (Join-Path "." "e2eTests/e2eTestHelper.psm1") -DisableNameChecking
$owner = '${{ needs.Check.outputs.githubowner }}'
$e2epat = '${{ Secrets.E2EPAT }}'
SetTokenAndRepository -github -githubOwner $owner -e2epat $e2epat -repository ''
SetTokenAndRepository -github -githubOwner $owner -token $e2epat -repository ''
@(invoke-gh repo list $owner --limit 1000 -silent -returnValue) | ForEach-Object { $_.Split("`t")[0] } | Where-Object { "$_" -like "$owner/tmp*" } | ForEach-Object {
$repo = $_
Write-Host "https://github.com/$repo"
Expand Down
124 changes: 87 additions & 37 deletions Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ function Copy-HashTable() {
}
}

# Convert SecureString to plain text
function Get-PlainText {
freddydk marked this conversation as resolved.
Show resolved Hide resolved
Param(
[parameter(ValueFromPipeline, Mandatory = $true)]
[System.Security.SecureString] $SecureString
)
Process {
$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString);
try {
return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr);
}
finally {
[Runtime.InteropServices.Marshal]::FreeBSTR($bstr);
}
}
}

function IsPropertySecret {
param (
[string] $propertyName
Expand Down Expand Up @@ -406,7 +423,7 @@ function DownloadAndImportBcContainerHelper([string] $baseFolder = $ENV:GITHUB_W
# Read Repository Settings file (without applying organization variables, repository variables or project settings files)
# Override default BcContainerHelper version from AL-Go-Helper only if new version is specifically specified in repo settings file
$repoSettings = Get-Content $repoSettingsPath -Encoding UTF8 | ConvertFrom-Json | ConvertTo-HashTable
if ($repoSettings.Keys -contains "BcContainerHelperVersion") {
if ($repoSettings.Keys -contains "BcContainerHelperVersion" -and $defaultBcContainerHelperVersion -notlike 'https://*') {
$bcContainerHelperVersion = $repoSettings.BcContainerHelperVersion
Write-Host "Using BcContainerHelper $bcContainerHelperVersion version"
if ($bcContainerHelperVersion -like "https://*") {
Expand Down Expand Up @@ -647,6 +664,15 @@ function ReadSettings {
"cacheImageName" = "my"
"cacheKeepDays" = 3
"alwaysBuildAllProjects" = $false
"incrementalBuilds" = [ordered]@{
"onPush" = $false
"onPull_Request" = $true
"onSchedule" = $false
"retentionDays" = 30
"mode" = "modifiedApps" # modifiedProjects, modifiedApps
freddydk marked this conversation as resolved.
Show resolved Hide resolved
}
"cicdConcurrency" = "Allowed"
"createReleaseConcurrency" = "Wait"
"microsoftTelemetryConnectionString" = "InstrumentationKey=cd2cc63e-0f37-4968-b99a-532411a314b8;IngestionEndpoint=https://northeurope-2.in.applicationinsights.azure.com/"
"partnerTelemetryConnectionString" = ""
"sendExtendedTelemetryToMicrosoft" = $false
Expand Down Expand Up @@ -732,29 +758,13 @@ function ReadSettings {
if ("$conditionalSetting" -ne "") {
$conditionMet = $true
$conditions = @()
if ($conditionalSetting.PSObject.Properties.Name -eq "buildModes") {
$conditionMet = $conditionMet -and ($conditionalSetting.buildModes | Where-Object { $buildMode -like $_ })
$conditions += @("buildMode: $buildMode")
}
if ($conditionalSetting.PSObject.Properties.Name -eq "branches") {
$conditionMet = $conditionMet -and ($conditionalSetting.branches | Where-Object { $branchName -like $_ })
$conditions += @("branchName: $branchName")
}
if ($conditionalSetting.PSObject.Properties.Name -eq "repositories") {
$conditionMet = $conditionMet -and ($conditionalSetting.repositories | Where-Object { $repoName -like $_ })
$conditions += @("repoName: $repoName")
}
if ($project -and $conditionalSetting.PSObject.Properties.Name -eq "projects") {
$conditionMet = $conditionMet -and ($conditionalSetting.projects | Where-Object { $project -like $_ })
$conditions += @("project: $project")
}
if ($workflowName -and $conditionalSetting.PSObject.Properties.Name -eq "workflows") {
$conditionMet = $conditionMet -and ($conditionalSetting.workflows | Where-Object { $workflowName -like $_ })
$conditions += @("workflowName: $workflowName")
}
if ($userName -and $conditionalSetting.PSObject.Properties.Name -eq "users") {
$conditionMet = $conditionMet -and ($conditionalSetting.users | Where-Object { $userName -like $_ })
$conditions += @("userName: $userName")
@{"buildModes" = $buildMode; "branches" = $branchName; "repositories" = $repoName; "projects" = $project; "workflows" = $workflowName; "users" = $userName}.GetEnumerator() | ForEach-Object {
$propName = $_.Key
$propValue = $_.Value
if ($conditionMet -and $conditionalSetting.PSObject.Properties.Name -eq $propName) {
$conditionMet = $propValue -and $conditionMet -and ($conditionalSetting."$propName" | Where-Object { $propValue -like $_ })
$conditions += @("$($propName): $propValue")
}
}
if ($conditionMet) {
Write-Host "Applying conditional settings for $($conditions -join ", ")"
Expand Down Expand Up @@ -926,11 +936,6 @@ function AnalyzeRepo {
)

$settings = $settings | Copy-HashTable

if (!$runningLocal) {
Write-Host "::group::Analyzing repository"
}

$projectPath = Join-Path $baseFolder $project -Resolve

# Check applicationDependency
Expand Down Expand Up @@ -1124,17 +1129,12 @@ function AnalyzeRepo {
if ($performanceToolkitApps.Contains($dep.id)) { $settings.installPerformanceToolkit = $true }
}
}

if (!$runningLocal) {
Write-Host "::endgroup::"
}

if (!$settings.doNotRunBcptTests -and -not $settings.bcptTestFolders) {
Write-Host "No performance test apps found in bcptTestFolders in $ALGoSettingsFile"
if (!$settings.doNotBuildTests) { Write-Host "No performance test apps found in bcptTestFolders in $ALGoSettingsFile" }
$settings.doNotRunBcptTests = $true
}
if (!$settings.doNotRunTests -and -not $settings.testFolders) {
if (!$doNotIssueWarnings) { OutputWarning -message "No test apps found in testFolders in $ALGoSettingsFile" }
if (-not ($doNotIssueWarnings -or $settings.doNotBuildTests)) { OutputWarning -message "No test apps found in testFolders in $ALGoSettingsFile" }
$settings.doNotRunTests = $true
}
if (-not $settings.appFolders) {
Expand Down Expand Up @@ -2119,7 +2119,7 @@ Function AnalyzeProjectDependencies {
Pop-Location
}

Write-Host "Folders containing apps are $($folders -join ',' )"
OutputMessageAndArray -Message "Folders containing apps" -arrayOfStrings $folders

$unknownDependencies = @()
$apps = @()
Expand Down Expand Up @@ -2382,6 +2382,7 @@ function RetryCommand {
try {
Invoke-Command $Command -ArgumentList $argumentList
if ($LASTEXITCODE -ne 0) {
$host.SetShouldExit(0);
throw "Command failed with exit code $LASTEXITCODE"
}
break
Expand Down Expand Up @@ -2437,6 +2438,22 @@ function GetProjectsFromRepository {
return @(GetMatchingProjects -projects $projects -selectProjects $selectProjects)
}

function GetFoldersFromAllProjects {
Param(
[string] $baseFolder
)

$settings = ReadSettings -baseFolder $baseFolder
$projects = GetProjectsFromRepository -baseFolder $baseFolder -projectsFromSettings $settings.projects
$folders = @()
foreach($project in $projects) {
$projectSettings = ReadSettings -project $project -baseFolder $baseFolder
ResolveProjectFolders -baseFolder $baseFolder -project $project -projectSettings ([ref] $projectSettings)
$folders += @( @($projectSettings.appFolders) + @($projectSettings.testFolders) + @($projectSettings.bcptTestFolders) | ForEach-Object { Join-Path $project "$_".Substring(2) } )
}
return $folders
}

function GetPackageVersion($packageName) {
$alGoPackages = Get-Content -Path "$PSScriptRoot\Packages.json" | ConvertFrom-Json

Expand Down Expand Up @@ -2520,3 +2537,36 @@ function ConnectAz {
throw "Error trying to authenticate to Azure. Error was $($_.Exception.Message)"
}
}

function OutputMessageAndArray {
Param(
[string] $message,
[string[]] $arrayOfStrings
)
Write-Host "$($message):"
if (!$arrayOfStrings) {
Write-Host "- None"
}
else {
$arrayOfStrings | ForEach-Object {
Write-Host "- $_"
}
}
}

<#
.SYNOPSIS
Run an executable and check the exit code
.EXAMPLE
RunAndCheck git checkout -b xxx
#>
function RunAndCheck {
$ErrorActionPreference = 'SilentlyContinue'
$rest = if ($args.Count -gt 1) { $args[1..($args.Count - 1)] } else { $null }
& $args[0] $rest
$ErrorActionPreference = 'STOP'
if ($LASTEXITCODE -ne 0) {
$host.SetShouldExit(0)
throw "$($args[0]) $($rest | ForEach-Object { $_ }) failed with exit code $LASTEXITCODE"
}
}
32 changes: 25 additions & 7 deletions Actions/AL-Go-TestRepoHelper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ function Test-Shell {
}
}

function Test-Deprecations {
Param(
[HashTable] $json,
[string] $settingsDescription
)

# cleanModePreprocessorSymbols is deprecated
if ($json.Keys -contains 'cleanModePreprocessorSymbols') {
OutputWarning -Message "cleanModePreprocessorSymbols in $settingsDescription is deprecated. See https://aka.ms/algodeprecations#cleanModePreprocessorSymbols"
}

# <workflowName>Schedule is deprecated
($json.Keys | Where-Object {$_ -like '*Schedule' -and $_ -ne 'WorkflowSchedule'}) | ForEach-Object {
OutputWarning -Message "$_ in $settingsDescription is deprecated. See https://aka.ms/algodeprecations#_workflow_Schedule. This warning will become an error in the future."
}
}

function Test-SettingsJson {
Param(
[hashtable] $json,
Expand All @@ -51,6 +68,8 @@ function Test-SettingsJson {
[string] $type
)

Test-Deprecations -json $json -settingsDescription $settingsDescription

Test-Shell -json $json -settingsDescription $settingsDescription -property 'shell'
Test-Shell -json $json -settingsDescription $settingsDescription -property 'gitHubRunnerShell'

Expand All @@ -71,18 +90,17 @@ function Test-SettingsJson {
if ($type -eq 'Workflow') {
# Test for things that should / should not exist in a workflow settings file
}
else {
# workflowSchedule and workflowConcurrency should only exist in workflow specific settings files (or conditional settings - not tested)
Test-Property -settingsDescription $settingsDescription -json $json -key 'workflowSchedule' -maynot
Test-Property -settingsDescription $settingsDescription -json $json -key 'workflowConcurrency' -maynot
}
if ($type -eq 'Variable') {
# Test for things that should / should not exist in a settings variable
}
if ($type -eq 'Project' -or $type -eq 'Workflow') {
# templateUrl should not be in Project or Workflow settings
Test-Property -settingsDescription $settingsDescription -json $json -key 'templateUrl' -maynot

# schedules and runs-on should not be in Project or Workflow settings
# These properties are used in Update AL-Go System Files, hence they should only be in Repo settings
'nextMajorSchedule','nextMinorSchedule','currentSchedule','runs-on' | ForEach-Object {
Test-Property -settingsDescription $settingsDescription -json $json -key $_ -shouldnot
}
}
}

Expand All @@ -100,7 +118,7 @@ function Test-JsonStr {

try {
$json = $jsonStr | ConvertFrom-Json | ConvertTo-HashTable
Test-SettingsJson -json $json -settingsDescription $settingsDescription -type:$type
Test-SettingsJson -json $json -settingsDescription $settingsDescription -type $type
}
catch {
OutputError "$($_.Exception.Message.Replace("`r",'').Replace("`n",' ')) in $settingsDescription"
Expand Down
46 changes: 41 additions & 5 deletions Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,50 @@ function GetWorkflowContentWithChangesFromSettings {

$baseName = [System.IO.Path]::GetFileNameWithoutExtension($srcFile)
$yaml = [Yaml]::Load($srcFile)
$workflowScheduleKey = "$($baseName)Schedule"
$yamlName = $yaml.get('name:')
if ($yamlName) {
$workflowName = $yamlName.content.SubString('name:'.Length).Trim().Trim('''"').Trim()
}
else {
$workflowName = $baseName
}

$workflowScheduleKey = "WorkflowSchedule"
$workflowConcurrencyKey = "WorkflowConcurrency"
foreach($key in @($workflowScheduleKey,$workflowConcurrencyKey)) {
if ($repoSettings.Keys -contains $key -and ($repoSettings."$key")) {
throw "The $key setting is not allowed in the global repository settings. Please use the workflow specific settings file or conditional settings."
}
}

# Re-read settings and this time include workflow specific settings
$repoSettings = ReadSettings -buildMode '' -project '' -workflowName $workflowName -userName '' -branchName '' | ConvertTo-HashTable -recurse

# Any workflow (except for the PullRequestHandler and reusable workflows (_*)) can have a RepoSetting called <workflowname>Schedule, which will be used to set the schedule for the workflow
# Old Schedule key is deprecated, but still supported
$oldWorkflowScheduleKey = "$($baseName)Schedule"
if ($repoSettings.Keys -contains $oldWorkflowScheduleKey) {
# DEPRECATION: REPLACE WITH ERROR AFTER April 1st 2025 --->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The release notes say October 1st.

if ($repoSettings.Keys -contains $workflowScheduleKey) {
OutputWarning "Both $oldWorkflowScheduleKey and $workflowScheduleKey are defined in the settings file. $oldWorkflowScheduleKey will be ignored. This warning will become an error in the future"
}
else {
Trace-DeprecationWarning -Message "$oldWorkflowScheduleKey is deprecated" -DeprecationTag "_workflow_Schedule" -WillBecomeError
# Convert the old <workflow>Schedule setting to the new WorkflowSchedule setting
$repoSettings."$workflowScheduleKey" = $repoSettings."$oldWorkflowScheduleKey"
}
# <--- REPLACE WITH ERROR AFTER April 1st 2025
}

# Any workflow (except for the PullRequestHandler and reusable workflows (_*)) can have concurrency and schedule defined
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, PullRequestHandler workflow already has concurrency. Not sure if we should allow changing it though. What do you think?

if ($baseName -ne "PullRequestHandler" -and $baseName -notlike '_*') {
# Add Schedule and Concurrency settings to the workflow
if ($repoSettings.Keys -contains $workflowScheduleKey) {
# Read the section under the on: key and add the schedule section
$yamlOn = $yaml.Get('on:/')
$yaml.Replace('on:/', $yamlOn.content+@('schedule:', " - cron: '$($repoSettings."$workflowScheduleKey")'"))
# Replace or add the schedule part under the on: key
$yaml.ReplaceOrAdd('on:/', 'schedule:', @("- cron: '$($repoSettings."$workflowScheduleKey")'"))
}
if ($repoSettings.Keys -contains $workflowConcurrencyKey) {
# Replace or add the concurrency part
$yaml.ReplaceOrAdd('', 'concurrency:', $repoSettings."$workflowConcurrencyKey")
}
}

Expand Down
6 changes: 4 additions & 2 deletions Actions/CheckForUpdates/CheckForUpdates.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
)

. (Join-Path -Path $PSScriptRoot -ChildPath "..\AL-Go-Helper.ps1" -Resolve)
Import-Module (Join-Path -Path $PSScriptRoot -ChildPath '..\TelemetryHelper.psm1' -Resolve)
. (Join-Path -Path $PSScriptRoot -ChildPath "yamlclass.ps1")
. (Join-Path -Path $PSScriptRoot -ChildPath "CheckForUpdates.HelperFunctions.ps1")

Expand Down Expand Up @@ -63,7 +64,7 @@ $headers = GetHeaders -token $readToken
# if $downloadLatest is set to true, CheckForUpdates will download the latest version of the template repository, else it will use the templateSha setting in the .github/AL-Go-Settings file

# Get Repo settings as a hashtable (do NOT read any specific project settings, nor any specific workflow, user or branch settings)
$repoSettings = ReadSettings -project '' -workflowName '' -userName '' -branchName '' | ConvertTo-HashTable -recurse
$repoSettings = ReadSettings -buildMode '' -project '' -workflowName '' -userName '' -branchName '' | ConvertTo-HashTable -recurse
$templateSha = $repoSettings.templateSha
$unusedALGoSystemFiles = $repoSettings.unusedALGoSystemFiles
$includeBuildPP = $repoSettings.type -eq 'PTE' -and $repoSettings.powerPlatformSolutionFolder -ne ''
Expand Down Expand Up @@ -212,7 +213,8 @@ else {
# $update set, update the files
try {
# If a pull request already exists with the same REF, then exit
$commitMessage = "[$updateBranch] Update AL-Go System Files from $templateInfo - $templateSha"
$branchSHA = RunAndCheck git rev-list -n 1 $updateBranch
$commitMessage = "[$($updateBranch)@$($branchSHA.SubString(0,7))] Update AL-Go System Files from $templateInfo - $($templateSha.SubString(0,7))"

# Get Token with permissions to modify workflows in this repository
$writeToken = GetAccessToken -token $token -permissions @{"actions"="read";"contents"="write";"pull_requests"="write";"workflows"="write"}
Expand Down
15 changes: 12 additions & 3 deletions Actions/CheckForUpdates/yamlclass.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,18 @@ class Yaml {
$this.Remove($start, $count)
$this.Insert($start, $yamlContent)
}
else {
Write-Host -ForegroundColor Red "cannot locate $line"
}
}

# Add the lines in $content to the lines for the specified Yaml path, given by $line
[void] Add([string] $line, [string[]] $content) {
$this.Replace($line, $this.Get($line).content + $content)
}

# Replace or add a key and content to the lines for the specified Yaml path, given by $line
[void] ReplaceOrAdd([string] $line, [string] $key, [string[]]$content) {
# Remove the key part under the line
$this.Replace("$line$key",@())
$this.Add($line, @($key) + @($content | ForEach-Object { " $_" }))
}

# Replace all occurrences of $from with $to throughout the Yaml content
Expand Down
Loading
Loading