Skip to content

Commit

Permalink
Allow GitHubRunner as a project setting (#1177)
Browse files Browse the repository at this point in the history
Allow GitHubRunner as a project setting. This would enable us to compile
apps on linux-based GitHub runners while running the tests on either
windows GitHub runners or self-hosted runners.
  • Loading branch information
aholstrup1 authored Sep 9, 2024
1 parent 564c339 commit a2a51be
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 40 deletions.
5 changes: 5 additions & 0 deletions Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,11 @@ function ReadSettings {
if ($settings.shell -ne "powershell" -and $settings.shell -ne "pwsh") {
throw "Invalid value for setting: shell: $($settings.githubRunnerShell)"
}
if (($settings.githubRunner -like "ubuntu-*") -and ($settings.githubRunnerShell -eq "powershell")) {
Write-Host "Switching shell to pwsh for ubuntu"
$settings.githubRunnerShell = "pwsh"
}

if($settings.projectName -eq '') {
$settings.projectName = $project # Default to project path as project name
}
Expand Down
3 changes: 1 addition & 2 deletions Actions/AL-Go-TestRepoHelper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ function Test-SettingsJson {
Test-Property -settingsDescription $settingsDescription -json $json -key 'templateUrl' -should
}
if ($type -eq 'Project') {
# GitHubRunner should not be in a project settings file (only read from repo or workflow settings)
Test-Property -settingsDescription $settingsDescription -json $json -key 'githubRunner' -shouldnot
# Test for things that should / should not exist in a project settings file
Test-Property -settingsDescription $settingsDescription -json $json -key 'bcContainerHelperVersion' -shouldnot
}
if ($type -eq 'Workflow') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ function CreateBuildDimensions {

foreach($project in $projects) {
$projectSettings = ReadSettings -project $project -baseFolder $baseFolder
$gitHubRunner = $projectSettings.githubRunner.Split(',').Trim() | ConvertTo-Json -compress
$githubRunnerShell = $projectSettings.githubRunnerShell
$buildModes = @($projectSettings.buildModes)

if(!$buildModes) {
Expand All @@ -168,6 +170,8 @@ function CreateBuildDimensions {
project = $project
projectName = $projectSettings.projectName
buildMode = $buildMode
gitHubRunner = $gitHubRunner
githubRunnerShell = $githubRunnerShell
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

- Issue 1184 Publish to Environment fails on 'Permission Denied'

### Allow GitHubRunner and GitHubRunnerShell as project settings

Previously, AL-Go required the GitHubRunner and GitHubRunnerShell settings to be set on repository level. This has now been changed such that they can be set on project level.

## v5.3

### Issues
Expand Down
4 changes: 2 additions & 2 deletions Templates/AppSource App/.github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ jobs:
uses: ./.github/workflows/_BuildALGoProject.yaml
secrets: inherit
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
runsOn: ${{ needs.Initialization.outputs.githubRunner }}
shell: ${{ matrix.githubRunnerShell }}
runsOn: ${{ matrix.githubRunner }}
project: ${{ matrix.project }}
projectName: ${{ matrix.projectName }}
buildMode: ${{ matrix.buildMode }}
Expand Down
6 changes: 2 additions & 4 deletions Templates/AppSource App/.github/workflows/Current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
needs: [ ]
runs-on: [ windows-latest ]
outputs:
githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }}
githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }}
projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}
projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }}
buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }}
Expand Down Expand Up @@ -75,8 +73,8 @@ jobs:
uses: ./.github/workflows/_BuildALGoProject.yaml
secrets: inherit
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
runsOn: ${{ needs.Initialization.outputs.githubRunner }}
shell: ${{ matrix.githubRunnerShell }}
runsOn: ${{ matrix.githubRunner }}
project: ${{ matrix.project }}
projectName: ${{ matrix.projectName }}
buildMode: ${{ matrix.buildMode }}
Expand Down
6 changes: 2 additions & 4 deletions Templates/AppSource App/.github/workflows/NextMajor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
needs: [ ]
runs-on: [ windows-latest ]
outputs:
githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }}
githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }}
projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}
projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }}
buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }}
Expand Down Expand Up @@ -75,8 +73,8 @@ jobs:
uses: ./.github/workflows/_BuildALGoProject.yaml
secrets: inherit
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
runsOn: ${{ needs.Initialization.outputs.githubRunner }}
shell: ${{ matrix.githubRunnerShell }}
runsOn: ${{ matrix.githubRunner }}
project: ${{ matrix.project }}
projectName: ${{ matrix.projectName }}
buildMode: ${{ matrix.buildMode }}
Expand Down
6 changes: 2 additions & 4 deletions Templates/AppSource App/.github/workflows/NextMinor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
needs: [ ]
runs-on: [ windows-latest ]
outputs:
githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }}
githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }}
projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}
projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }}
buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }}
Expand Down Expand Up @@ -75,8 +73,8 @@ jobs:
uses: ./.github/workflows/_BuildALGoProject.yaml
secrets: inherit
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
runsOn: ${{ needs.Initialization.outputs.githubRunner }}
shell: ${{ matrix.githubRunnerShell }}
runsOn: ${{ matrix.githubRunner }}
project: ${{ matrix.project }}
projectName: ${{ matrix.projectName }}
buildMode: ${{ matrix.buildMode }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ jobs:
if: (!failure() && !cancelled())
runs-on: [ windows-latest ]
outputs:
githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }}
githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }}
projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}
projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }}
buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }}
Expand Down Expand Up @@ -90,8 +88,8 @@ jobs:
uses: ./.github/workflows/_BuildALGoProject.yaml
secrets: inherit
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
runsOn: ${{ needs.Initialization.outputs.githubRunner }}
shell: ${{ matrix.githubRunnerShell }}
runsOn: ${{ matrix.githubRunner }}
checkoutRef: ${{ github.event_name == 'pull_request' && github.sha || format('refs/pull/{0}/merge', github.event.pull_request.number) }}
project: ${{ matrix.project }}
projectName: ${{ matrix.projectName }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
id: sign
uses: microsoft/AL-Go-Actions/Sign@main
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
shell: ${{ inputs.shell }}
azureCredentialsJson: '${{ fromJson(steps.ReadSecrets.outputs.Secrets).AZURE_CREDENTIALS }}'
pathToFiles: '${{ inputs.project }}/.buildartifacts/Apps/*.app'

Expand Down
4 changes: 2 additions & 2 deletions Templates/Per Tenant Extension/.github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ jobs:
uses: ./.github/workflows/_BuildALGoProject.yaml
secrets: inherit
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
runsOn: ${{ needs.Initialization.outputs.githubRunner }}
shell: ${{ matrix.githubRunnerShell }}
runsOn: ${{ matrix.githubRunner }}
project: ${{ matrix.project }}
projectName: ${{ matrix.projectName }}
buildMode: ${{ matrix.buildMode }}
Expand Down
6 changes: 2 additions & 4 deletions Templates/Per Tenant Extension/.github/workflows/Current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
needs: [ ]
runs-on: [ windows-latest ]
outputs:
githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }}
githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }}
projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}
projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }}
buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }}
Expand Down Expand Up @@ -75,8 +73,8 @@ jobs:
uses: ./.github/workflows/_BuildALGoProject.yaml
secrets: inherit
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
runsOn: ${{ needs.Initialization.outputs.githubRunner }}
shell: ${{ matrix.githubRunnerShell }}
runsOn: ${{ matrix.githubRunner }}
project: ${{ matrix.project }}
projectName: ${{ matrix.projectName }}
buildMode: ${{ matrix.buildMode }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
needs: [ ]
runs-on: [ windows-latest ]
outputs:
githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }}
githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }}
projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}
projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }}
buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }}
Expand Down Expand Up @@ -75,8 +73,8 @@ jobs:
uses: ./.github/workflows/_BuildALGoProject.yaml
secrets: inherit
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
runsOn: ${{ needs.Initialization.outputs.githubRunner }}
shell: ${{ matrix.githubRunnerShell }}
runsOn: ${{ matrix.githubRunner }}
project: ${{ matrix.project }}
projectName: ${{ matrix.projectName }}
buildMode: ${{ matrix.buildMode }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
needs: [ ]
runs-on: [ windows-latest ]
outputs:
githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }}
githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }}
projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}
projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }}
buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }}
Expand Down Expand Up @@ -75,8 +73,8 @@ jobs:
uses: ./.github/workflows/_BuildALGoProject.yaml
secrets: inherit
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
runsOn: ${{ needs.Initialization.outputs.githubRunner }}
shell: ${{ matrix.githubRunnerShell }}
runsOn: ${{ matrix.githubRunner }}
project: ${{ matrix.project }}
projectName: ${{ matrix.projectName }}
buildMode: ${{ matrix.buildMode }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ jobs:
if: (!failure() && !cancelled())
runs-on: [ windows-latest ]
outputs:
githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }}
githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }}
projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}
projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }}
buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }}
Expand Down Expand Up @@ -90,8 +88,8 @@ jobs:
uses: ./.github/workflows/_BuildALGoProject.yaml
secrets: inherit
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
runsOn: ${{ needs.Initialization.outputs.githubRunner }}
shell: ${{ matrix.githubRunnerShell }}
runsOn: ${{ matrix.githubRunner }}
checkoutRef: ${{ github.event_name == 'pull_request' && github.sha || format('refs/pull/{0}/merge', github.event.pull_request.number) }}
project: ${{ matrix.project }}
projectName: ${{ matrix.projectName }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
id: sign
uses: microsoft/AL-Go-Actions/Sign@main
with:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
shell: ${{ inputs.shell }}
azureCredentialsJson: '${{ fromJson(steps.ReadSecrets.outputs.Secrets).AZURE_CREDENTIALS }}'
pathToFiles: '${{ inputs.project }}/.buildartifacts/Apps/*.app'

Expand Down

0 comments on commit a2a51be

Please sign in to comment.