Skip to content

Commit 2da6c0d

Browse files
authored
runs-on type is ambiguous (#1473)
Today, the runs-on type in settings must be a string (can be a comma separated number of runner tags) and the runs-on property under environment needs to be an array of strings = runner tags. This PR makes the runs-on under Environments become a string as well, but support arrays, to not break old settings files. Fixes #1182 FIxes https://www.yammer.com/dynamicsnavdev/threads/3172600716926976 This means that this setting: ![image](https://github.com/user-attachments/assets/17ac236c-9cf7-4055-b314-2ab538a0936b) Yields identical os settings in environment matrix json: ``` EnvironmentsMatrixJson={"matrix":{"include":[{"environment":"TEST","os":"[\"windows-latest\",\"windows-2022\"]","shell":"powershell"},{"environment":"TEST2","os":"[\"windows-latest\",\"windows-2022\"]","shell":"powershell"}]},"fail-fast":false} ``` The PR also ensures that shell becomes pwsh if runs-on is `*ubuntu-*` --------- Co-authored-by: freddydk <[email protected]>
1 parent ae1cc97 commit 2da6c0d

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

Actions/AL-Go-Helper.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,15 +788,15 @@ function ReadSettings {
788788
# At some point in the future (likely version 3.0), we will switch to Ubuntu (Linux) as default for "runs-on"
789789
#
790790
if ($settings.shell -eq "") {
791-
if ($settings."runs-on" -like "ubuntu-*") {
791+
if ($settings."runs-on" -like "*ubuntu-*") {
792792
$settings.shell = "pwsh"
793793
}
794794
else {
795795
$settings.shell = "powershell"
796796
}
797797
}
798798
if ($settings.githubRunner -eq "") {
799-
if ($settings."runs-on" -like "ubuntu-*") {
799+
if ($settings."runs-on" -like "*ubuntu-*") {
800800
$settings.githubRunner = "windows-latest"
801801
}
802802
else {
@@ -813,7 +813,7 @@ function ReadSettings {
813813
if ($settings.shell -ne "powershell" -and $settings.shell -ne "pwsh") {
814814
throw "Invalid value for setting: shell: $($settings.githubRunnerShell)"
815815
}
816-
if (($settings.githubRunner -like "ubuntu-*") -and ($settings.githubRunnerShell -eq "powershell")) {
816+
if (($settings.githubRunner -like "*ubuntu-*") -and ($settings.githubRunnerShell -eq "powershell")) {
817817
Write-Host "Switching shell to pwsh for ubuntu"
818818
$settings.githubRunnerShell = "pwsh"
819819
}

Actions/DetermineDeploymentEnvironments/DetermineDeploymentEnvironments.ps1

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ if (!($environments)) {
112112
"Scope" = $null
113113
"buildMode" = $null
114114
"continuousDeployment" = !($getEnvironments -like '* (PROD)' -or $getEnvironments -like '* (Production)' -or $getEnvironments -like '* (FAT)' -or $getEnvironments -like '* (Final Acceptance Test)')
115-
"runs-on" = @($settings."runs-on".Split(',').Trim())
115+
"runs-on" = $settings."runs-on"
116116
"shell" = $settings."shell"
117117
"companyId" = ''
118118
"ppEnvironmentUrl" = ''
@@ -155,7 +155,7 @@ else {
155155
"Scope" = $null
156156
"buildMode" = $null
157157
"continuousDeployment" = $null
158-
"runs-on" = @($settings."runs-on".Split(',').Trim())
158+
"runs-on" = $settings."runs-on"
159159
"shell" = $settings."shell"
160160
"companyId" = ''
161161
"ppEnvironmentUrl" = ''
@@ -173,7 +173,14 @@ else {
173173
foreach($key in $keys) {
174174
if ($deploymentSettings.ContainsKey($key)) {
175175
if ($null -ne $deploymentSettings."$key" -and $null -ne $deployTo."$key" -and $deploymentSettings."$key".GetType().Name -ne $deployTo."$key".GetType().Name) {
176-
Write-Host "::WARNING::The property $key in $settingsName is expected to be of type $($deploymentSettings."$key".GetType().Name)"
176+
if ($key -eq "runs-on" -and $deployTo."$key" -is [Object[]]) {
177+
# Support setting runs-on as an array in settings to not break old settings
178+
# See https://github.com/microsoft/AL-Go/issues/1182
179+
$deployTo."$key" = $deployTo."$key" -join ','
180+
}
181+
else {
182+
Write-Host "::WARNING::The property $key in $settingsName is expected to be of type $($deploymentSettings."$key".GetType().Name)"
183+
}
177184
}
178185
Write-Host "Property $key = $($deployTo."$key")"
179186
$deploymentSettings."$key" = $deployTo."$key"
@@ -188,6 +195,10 @@ else {
188195
if ($deploymentSettings."shell" -ne 'pwsh' -and $deploymentSettings."shell" -ne 'powershell') {
189196
throw "The shell setting in $settingsName must be either 'pwsh' or 'powershell'"
190197
}
198+
if ($deploymentSettings."runs-on" -like "*ubuntu-*" -and $deploymentSettings."shell" -eq "powershell") {
199+
Write-Host "Switching deployment shell to pwsh for ubuntu"
200+
$deploymentSettings."shell" = "pwsh"
201+
}
191202
}
192203

193204
# Get Branch policies on GitHub Environment
@@ -261,7 +272,7 @@ else {
261272
$json = @{"matrix" = @{ "include" = @() }; "fail-fast" = $false }
262273
$deploymentEnvironments.Keys | Sort-Object | ForEach-Object {
263274
$deploymentEnvironment = $deploymentEnvironments."$_"
264-
$json.matrix.include += @{ "environment" = $_; "os" = "$(ConvertTo-Json -InputObject $deploymentEnvironment."runs-on" -compress)"; "shell" = $deploymentEnvironment."shell" }
275+
$json.matrix.include += @{ "environment" = $_; "os" = "$(ConvertTo-Json -InputObject @($deploymentEnvironment."runs-on".Split(',').Trim()) -compress)"; "shell" = $deploymentEnvironment."shell" }
265276
}
266277
$environmentsMatrixJson = $json | ConvertTo-Json -Depth 99 -compress
267278
Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "EnvironmentsMatrixJson=$environmentsMatrixJson"

RELEASENOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Issue 1268 Do not throw an un-understandable error during nuGet download
1212
- Performance test sample code in 25.4 contains objects with ID 149201 and 149202, which are not renumbered
1313
- Issue 798 Publish To Environment breaks CI/CD pipelines
14+
- Issue 1182 Runs-on setting type is ambiguous - string or array
1415

1516
### New Workflow specific settings
1617

0 commit comments

Comments
 (0)