diff --git a/.AL-Go/cloudDevEnv.ps1 b/.AL-Go/cloudDevEnv.ps1 index 18555aa..da6d476 100644 --- a/.AL-Go/cloudDevEnv.ps1 +++ b/.AL-Go/cloudDevEnv.ps1 @@ -1,106 +1,90 @@ -# -# Script for creating cloud development environment -# Please do not modify this script as it will be auto-updated from the AL-Go Template -# Recommended approach is to use as is or add a script (freddyk-devenv.ps1), which calls this script with the user specific parameters -# -Param( - [string] $environmentName = "", - [bool] $reuseExistingEnvironment, - [switch] $fromVSCode -) - -$ErrorActionPreference = "stop" -Set-StrictMode -Version 2.0 - -$pshost = Get-Host -if ($pshost.Name -eq "Visual Studio Code Host") { - $executionPolicy = Get-ExecutionPolicy -Scope CurrentUser - Write-Host "Execution Policy is $executionPolicy" - if ($executionPolicy -eq "Restricted") { - Write-Host "Changing Execution Policy to RemoteSigned" - Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force - } - if ($MyInvocation.InvocationName -eq '.' -or $MyInvocation.Line -eq '') { - $scriptName = Join-Path $PSScriptRoot $MyInvocation.MyCommand - } - else { - $scriptName = $MyInvocation.InvocationName - } - if (Test-Path -Path $scriptName -PathType Leaf) { - $scriptName = (Get-Item -path $scriptName).FullName - $pslink = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs\Windows PowerShell\Windows PowerShell.lnk" - if (!(Test-Path $pslink)) { - $pslink = "powershell.exe" - } - Start-Process -Verb runas $pslink @("-Command ""$scriptName"" -fromVSCode -environmentName '$environmentName' -reuseExistingEnvironment `$$reuseExistingEnvironment") - return - } -} - -try { -$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" -$webClient = New-Object System.Net.WebClient -$webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumentList ([System.Net.Cache.RequestCacheLevel]::NoCacheNoStore) -$webClient.Encoding = [System.Text.Encoding]::UTF8 -Write-Host "Downloading AL-Go Helper script" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/preview/AL-Go-Helper.ps1', $ALGoHelperPath) -. $ALGoHelperPath -local - -$baseFolder = Join-Path $PSScriptRoot ".." -Resolve - -Clear-Host -Write-Host -ForegroundColor Yellow @' - _____ _ _ _____ ______ - / ____| | | | | __ \ | ____| - | | | | ___ _ _ __| | | | | | _____ __ |__ _ ____ __ - | | | |/ _ \| | | |/ _` | | | | |/ _ \ \ / / __| | '_ \ \ / / - | |____| | (_) | |_| | (_| | | |__| | __/\ V /| |____| | | \ V / - \_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/ - -'@ - -Write-Host @' -This script will create a cloud based development environment (Business Central SaaS Sandbox) for your project. -All apps and test apps will be compiled and published to the environment in the development scope. -The script will also modify launch.json to have a "Cloud Sandbox ()" configuration point to your environment. - -'@ - -if (Test-Path (Join-Path $PSScriptRoot "NewBcContainer.ps1")) { - Write-Host -ForegroundColor Red "WARNING: The project has a NewBcContainer override defined. Typically, this means that you cannot run a cloud development environment" -} - -$settings = ReadSettings -baseFolder $baseFolder -userName $env:USERNAME - -Write-Host - -if (-not $environmentName) { - $environmentName = Enter-Value ` - -title "Environment name" ` - -question "Please enter the name of the environment to create" ` - -default "$($env:USERNAME)-sandbox" -} - -if (-not $PSBoundParameters.ContainsKey('reuseExistingEnvironment')) { - $reuseExistingEnvironment = (Select-Value ` - -title "What if the environment already exists?" ` - -options @{ "Yes" = "Reuse existing environment"; "No" = "Recreate environment" } ` - -question "Select behavior" ` - -default "No") -eq "Yes" -} - -CreateDevEnv ` - -kind cloud ` - -caller local ` - -environmentName $environmentName ` - -reuseExistingEnvironment:$reuseExistingEnvironment ` - -baseFolder $baseFolder -} -catch { - Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)" -} -finally { - if ($fromVSCode) { - Read-Host "Press ENTER to close this window" - } -} +# +# Script for creating cloud development environment +# Please do not modify this script as it will be auto-updated from the AL-Go Template +# Recommended approach is to use as is or add a script (freddyk-devenv.ps1), which calls this script with the user specific parameters +# +Param( + [string] $environmentName = "", + [bool] $reuseExistingEnvironment, + [switch] $fromVSCode +) + +$ErrorActionPreference = "stop" +Set-StrictMode -Version 2.0 + +try { +$webClient = New-Object System.Net.WebClient +$webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumentList ([System.Net.Cache.RequestCacheLevel]::NoCacheNoStore) +$webClient.Encoding = [System.Text.Encoding]::UTF8 +Write-Host "Downloading GitHub Helper module" +$GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1" +$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.0/Github-Helper.psm1', $GitHubHelperPath) +Write-Host "Downloading AL-Go Helper script" +$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" +$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.0/AL-Go-Helper.ps1', $ALGoHelperPath) + +Import-Module $GitHubHelperPath +. $ALGoHelperPath -local + +$baseFolder = GetBaseFolder -folder $PSScriptRoot +$project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot + +Clear-Host +Write-Host +Write-Host -ForegroundColor Yellow @' + _____ _ _ _____ ______ + / ____| | | | | __ \ | ____| + | | | | ___ _ _ __| | | | | | _____ __ |__ _ ____ __ + | | | |/ _ \| | | |/ _` | | | | |/ _ \ \ / / __| | '_ \ \ / / + | |____| | (_) | |_| | (_| | | |__| | __/\ V /| |____| | | \ V / + \_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/ + +'@ + +Write-Host @' +This script will create a cloud based development environment (Business Central SaaS Sandbox) for your project. +All apps and test apps will be compiled and published to the environment in the development scope. +The script will also modify launch.json to have a "Cloud Sandbox ()" configuration point to your environment. + +'@ + +if (Test-Path (Join-Path $PSScriptRoot "NewBcContainer.ps1")) { + Write-Host -ForegroundColor Red "WARNING: The project has a NewBcContainer override defined. Typically, this means that you cannot run a cloud development environment" +} + +$settings = ReadSettings -baseFolder $baseFolder -project $project -userName $env:USERNAME + +Write-Host + +if (-not $environmentName) { + $environmentName = Enter-Value ` + -title "Environment name" ` + -question "Please enter the name of the environment to create" ` + -default "$($env:USERNAME)-sandbox" ` + -trimCharacters @('"',"'",' ') +} + +if ($PSBoundParameters.Keys -notcontains 'reuseExistingEnvironment') { + $reuseExistingEnvironment = (Select-Value ` + -title "What if the environment already exists?" ` + -options @{ "Yes" = "Reuse existing environment"; "No" = "Recreate environment" } ` + -question "Select behavior" ` + -default "No") -eq "Yes" +} + +CreateDevEnv ` + -kind cloud ` + -caller local ` + -environmentName $environmentName ` + -reuseExistingEnvironment:$reuseExistingEnvironment ` + -baseFolder $baseFolder ` + -project $project +} +catch { + Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)" +} +finally { + if ($fromVSCode) { + Read-Host "Press ENTER to close this window" + } +} diff --git a/.AL-Go/localDevEnv.ps1 b/.AL-Go/localDevEnv.ps1 index ff0a396..11a5976 100644 --- a/.AL-Go/localDevEnv.ps1 +++ b/.AL-Go/localDevEnv.ps1 @@ -1,167 +1,144 @@ -# -# Script for creating local development environment -# Please do not modify this script as it will be auto-updated from the AL-Go Template -# Recommended approach is to use as is or add a script (freddyk-devenv.ps1), which calls this script with the user specific parameters -# -Param( - [string] $containerName = "", - [string] $auth = "", - [pscredential] $credential = $null, - [string] $licenseFileUrl = "", - [string] $insiderSasToken = "", - [switch] $fromVSCode -) - -$ErrorActionPreference = "stop" -Set-StrictMode -Version 2.0 - -$pshost = Get-Host -if ($pshost.Name -eq "Visual Studio Code Host") { - $executionPolicy = Get-ExecutionPolicy -Scope CurrentUser - Write-Host "Execution Policy is $executionPolicy" - if ($executionPolicy -eq "Restricted") { - Write-Host "Changing Execution Policy to RemoteSigned" - Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force - } - if ($MyInvocation.InvocationName -eq '.' -or $MyInvocation.Line -eq '') { - $scriptName = Join-Path $PSScriptRoot $MyInvocation.MyCommand - } - else { - $scriptName = $MyInvocation.InvocationName - } - if (Test-Path -Path $scriptName -PathType Leaf) { - $scriptName = (Get-Item -path $scriptName).FullName - $pslink = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs\Windows PowerShell\Windows PowerShell.lnk" - if (!(Test-Path $pslink)) { - $pslink = "powershell.exe" - } - $credstr = "" - if ($credential) { - $credstr = " -credential (New-Object PSCredential '$($credential.UserName)', ('$($credential.Password | ConvertFrom-SecureString)' | ConvertTo-SecureString))" - } - Start-Process -Verb runas $pslink @("-Command ""$scriptName"" -fromVSCode -containerName '$containerName' -auth '$auth' -licenseFileUrl '$licenseFileUrl' -insiderSasToken '$insiderSasToken'$credstr") - return - } -} - -try { -$webClient = New-Object System.Net.WebClient -$webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumentList ([System.Net.Cache.RequestCacheLevel]::NoCacheNoStore) -$webClient.Encoding = [System.Text.Encoding]::UTF8 -Write-Host "Downloading GitHub Helper module" -$GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/preview/Github-Helper.psm1', $GitHubHelperPath) -Write-Host "Downloading AL-Go Helper script" -$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/preview/AL-Go-Helper.ps1', $ALGoHelperPath) - -Import-Module $GitHubHelperPath -. $ALGoHelperPath -local - -$baseFolder = Join-Path $PSScriptRoot ".." -Resolve - -Clear-Host -Write-Host -ForegroundColor Yellow @' - _ _ _____ ______ - | | | | | __ \ | ____| - | | ___ ___ __ _| | | | | | _____ __ |__ _ ____ __ - | | / _ \ / __/ _` | | | | | |/ _ \ \ / / __| | '_ \ \ / / - | |____ (_) | (__ (_| | | | |__| | __/\ V /| |____| | | \ V / - |______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/ - -'@ - -Write-Host @' -This script will create a docker based local development environment for your project. - -NOTE: You need to have Docker installed, configured and be able to create Business Central containers for this to work. -If this fails, you can setup a cloud based development environment by running cloudDevEnv.ps1 - -All apps and test apps will be compiled and published to the environment in the development scope. -The script will also modify launch.json to have a Local Sandbox configuration point to your environment. - -'@ - -$settings = ReadSettings -baseFolder $baseFolder -userName $env:USERNAME - -Write-Host "Checking System Requirements" -$dockerProcess = (Get-Process "dockerd" -ErrorAction Ignore) -if (!($dockerProcess)) { - Write-Host -ForegroundColor Red "Dockerd process not found. Docker might not be started, not installed or not running Windows Containers." -} -if ($settings.keyVaultName) { - if (-not (Get-Module -ListAvailable -Name 'Az.KeyVault')) { - Write-Host -ForegroundColor Red "A keyvault name is defined in Settings, you need to have the Az.KeyVault PowerShell module installed (use Install-Module az) or you can set the keyVaultName to an empty string in the user settings file ($($ENV:UserName).Settings.json)." - } -} - -Write-Host - -if (-not $containerName) { - $containerName = Enter-Value ` - -title "Container name" ` - -question "Please enter the name of the container to create" ` - -default "bcserver" -} - -if (-not $auth) { - $auth = Select-Value ` - -title "Authentication mechanism for container" ` - -options @{ "Windows" = "Windows Authentication"; "UserPassword" = "Username/Password authentication" } ` - -question "Select authentication mechanism for container" ` - -default "UserPassword" -} - -if (-not $credential) { - if ($auth -eq "Windows") { - $credential = Get-Credential -Message "Please enter your Windows Credentials" -UserName $env:USERNAME - $CurrentDomain = "LDAP://" + ([ADSI]"").distinguishedName - $domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain,$credential.UserName,$credential.GetNetworkCredential().password) - if ($null -eq $domain.name) { - Write-Host -ForegroundColor Red "Unable to verify your Windows Credentials, you might not be able to authenticate to your container" - } - } - else { - $credential = Get-Credential -Message "Please enter username and password for your container" -UserName "admin" - } -} - -if (-not $licenseFileUrl) { - if ($settings.type -eq "AppSource App") { - $description = "When developing AppSource Apps, your local development environment needs the developer licensefile with permissions to your AppSource app object IDs" - $default = "" - } - else { - $description = "When developing PTEs, you can optionally specify a developer licensefile with permissions to object IDs of your dependant apps" - $default = "none" - } - - $licenseFileUrl = Enter-Value ` - -title "LicenseFileUrl" ` - -description $description ` - -question "Local path or a secure download URL to license file " ` - -default $default - - if ($licenseFileUrl -eq "none") { - $licenseFileUrl = "" - } -} - -CreateDevEnv ` - -kind local ` - -caller local ` - -containerName $containerName ` - -baseFolder $baseFolder ` - -auth $auth ` - -credential $credential ` - -LicenseFileUrl $licenseFileUrl ` - -InsiderSasToken $insiderSasToken -} -catch { - Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)" -} -finally { - if ($fromVSCode) { - Read-Host "Press ENTER to close this window" - } -} +# +# Script for creating local development environment +# Please do not modify this script as it will be auto-updated from the AL-Go Template +# Recommended approach is to use as is or add a script (freddyk-devenv.ps1), which calls this script with the user specific parameters +# +Param( + [string] $containerName = "", + [string] $auth = "", + [pscredential] $credential = $null, + [string] $licenseFileUrl = "", + [string] $insiderSasToken = "", + [switch] $fromVSCode +) + +$ErrorActionPreference = "stop" +Set-StrictMode -Version 2.0 + +try { +$webClient = New-Object System.Net.WebClient +$webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumentList ([System.Net.Cache.RequestCacheLevel]::NoCacheNoStore) +$webClient.Encoding = [System.Text.Encoding]::UTF8 +Write-Host "Downloading GitHub Helper module" +$GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1" +$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.0/Github-Helper.psm1', $GitHubHelperPath) +Write-Host "Downloading AL-Go Helper script" +$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" +$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.0/AL-Go-Helper.ps1', $ALGoHelperPath) + +Import-Module $GitHubHelperPath +. $ALGoHelperPath -local + +$baseFolder = GetBaseFolder -folder $PSScriptRoot +$project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot + +Clear-Host +Write-Host +Write-Host -ForegroundColor Yellow @' + _ _ _____ ______ + | | | | | __ \ | ____| + | | ___ ___ __ _| | | | | | _____ __ |__ _ ____ __ + | | / _ \ / __/ _` | | | | | |/ _ \ \ / / __| | '_ \ \ / / + | |____ (_) | (__ (_| | | | |__| | __/\ V /| |____| | | \ V / + |______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/ + +'@ + +Write-Host @' +This script will create a docker based local development environment for your project. + +NOTE: You need to have Docker installed, configured and be able to create Business Central containers for this to work. +If this fails, you can setup a cloud based development environment by running cloudDevEnv.ps1 + +All apps and test apps will be compiled and published to the environment in the development scope. +The script will also modify launch.json to have a Local Sandbox configuration point to your environment. + +'@ + +$settings = ReadSettings -baseFolder $baseFolder -project $project -userName $env:USERNAME + +Write-Host "Checking System Requirements" +$dockerProcess = (Get-Process "dockerd" -ErrorAction Ignore) +if (!($dockerProcess)) { + Write-Host -ForegroundColor Red "Dockerd process not found. Docker might not be started, not installed or not running Windows Containers." +} +if ($settings.keyVaultName) { + if (-not (Get-Module -ListAvailable -Name 'Az.KeyVault')) { + Write-Host -ForegroundColor Red "A keyvault name is defined in Settings, you need to have the Az.KeyVault PowerShell module installed (use Install-Module az) or you can set the keyVaultName to an empty string in the user settings file ($($ENV:UserName).settings.json)." + } +} + +Write-Host + +if (-not $containerName) { + $containerName = Enter-Value ` + -title "Container name" ` + -question "Please enter the name of the container to create" ` + -default "bcserver" ` + -trimCharacters @('"',"'",' ') +} + +if (-not $auth) { + $auth = Select-Value ` + -title "Authentication mechanism for container" ` + -options @{ "Windows" = "Windows Authentication"; "UserPassword" = "Username/Password authentication" } ` + -question "Select authentication mechanism for container" ` + -default "UserPassword" +} + +if (-not $credential) { + if ($auth -eq "Windows") { + $credential = Get-Credential -Message "Please enter your Windows Credentials" -UserName $env:USERNAME + $CurrentDomain = "LDAP://" + ([ADSI]"").distinguishedName + $domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain,$credential.UserName,$credential.GetNetworkCredential().password) + if ($null -eq $domain.name) { + Write-Host -ForegroundColor Red "Unable to verify your Windows Credentials, you might not be able to authenticate to your container" + } + } + else { + $credential = Get-Credential -Message "Please enter username and password for your container" -UserName "admin" + } +} + +if (-not $licenseFileUrl) { + if ($settings.type -eq "AppSource App") { + $description = "When developing AppSource Apps, your local development environment needs the developer licensefile with permissions to your AppSource app object IDs" + $default = "" + } + else { + $description = "When developing PTEs, you can optionally specify a developer licensefile with permissions to object IDs of your dependant apps" + $default = "none" + } + + $licenseFileUrl = Enter-Value ` + -title "LicenseFileUrl" ` + -description $description ` + -question "Local path or a secure download URL to license file " ` + -default $default ` + -doNotConvertToLower ` + -trimCharacters @('"',"'",' ') +} + +if ($licenseFileUrl -eq "none") { + $licenseFileUrl = "" +} + +CreateDevEnv ` + -kind local ` + -caller local ` + -containerName $containerName ` + -baseFolder $baseFolder ` + -project $project ` + -auth $auth ` + -credential $credential ` + -licenseFileUrl $licenseFileUrl ` + -insiderSasToken $insiderSasToken +} +catch { + Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)" +} +finally { + if ($fromVSCode) { + Read-Host "Press ENTER to close this window" + } +} diff --git a/.github/AL-Go-Settings.json b/.github/AL-Go-Settings.json index 856f4a6..17ac5bb 100644 --- a/.github/AL-Go-Settings.json +++ b/.github/AL-Go-Settings.json @@ -1,4 +1,4 @@ -{ - "type": "PTE", - "templateUrl": "https://github.com/microsoft/AL-Go-PTE@preview" +{ + "type": "PTE", + "templateUrl": "https://github.com/microsoft/AL-Go-PTE@main" } diff --git a/.github/RELEASENOTES.copy.md b/.github/RELEASENOTES.copy.md index 6e08f96..30366f2 100644 --- a/.github/RELEASENOTES.copy.md +++ b/.github/RELEASENOTES.copy.md @@ -1,6 +1,127 @@ -## Preview +## v3.0 -Note that when using the preview version of AL-Go for GitHub, you need to Update your AL-Go system files, as soon as possible when told to do so. +### **NOTE:** When upgrading to this version +When upgrading to this version form earlier versions of AL-Go for GitHub, you will need to run the _Update AL-Go System Files_ workflow twice if you have the `useProjectDependencies` setting set to _true_. + +### Issues +- Issue #391 Create release action - CreateReleaseBranch error +- Issue #434 Building local DevEnv, downloading dependencies: Authentication fails when using "gh auth status" + +### Changes to Pull Request Process +In v2.4 and earlier, the PullRequestHandler would trigger the CI/CD workflow to run the PR build. +Now, the PullRequestHandler will perform the build and the CI/CD workflow is only run on push (or manual dispatch) and will perform a complete build. + +### Build modes per project +Build modes can now be specified per project + +### New Actions +- **DetermineProjectsToBuild** is used to determine which projects to build in PullRequestHandler, CI/CD, Current, NextMinor and NextMajor workflows. +- **CalculateArtifactNames** is used to calculate artifact names in PullRequestHandler, CI/CD, Current, NextMinor and NextMajor workflows. +- **VerifyPRChanges** is used to verify whether a PR contains changes, which are not allowed from a fork. + +## v2.4 + +### Issues +- Issue #171 create a workspace file when creating a project +- Issue #356 Publish to AppSource fails in multi project repo +- Issue #358 Publish To Environment Action stopped working in v2.3 +- Issue #362 Support for EnableTaskScheduler +- Issue #360 Creating a release and deploying from a release branch +- Issue #371 'No previous release found' for builds on release branches +- Issue #376 CICD jobs that are triggered by the pull request trigger run directly to an error if title contains quotes + +### Release Branches +**NOTE:** Release Branches are now only named after major.minor if the patch value is 0 in the release tag (which must be semver compatible) + +This version contains a number of bug fixes to release branches, to ensure that the recommended branching strategy is fully supported. Bugs fixed includes: +- Release branches was named after the full tag (1.0.0), even though subsequent hotfixes released from this branch would be 1.0.x +- Release branches named 1.0 wasn't picked up as a release branch +- Release notes contained the wrong changelog +- The previous release was always set to be the first release from a release branch +- SemVerStr could not have 5 segments after the dash +- Release was created on the right SHA, but the release branch was created on the wrong SHA + +Recommended branching strategy: + +![Branching Strategy](https://raw.githubusercontent.com/microsoft/AL-Go/main/Scenarios/images/branchingstrategy.png) + +### New Settings +New Project setting: EnableTaskScheduler in container executing tests and when setting up local development environment + +### Support for GitHub variables: ALGoOrgSettings and ALGoRepoSettings +Recently, GitHub added support for variables, which you can define on your organization or your repository. +AL-Go now supports that you can define a GitHub variable called ALGoOrgSettings, which will work for all repositories (with access to the variable) +Org Settings will be applied before Repo settings and local repository settings files will override values in the org settings +You can also define a variable called ALGoRepoSettings on the repository, which will be applied after reading the Repo Settings file in the repo +Example for usage could be setup of branching strategies, versioning or an appDependencyProbingPaths to repositories which all repositories share. +appDependencyProbingPaths from settings variables are merged together with appDependencyProbingPaths defined in repositories + +### Refactoring and tests +ReadSettings has been refactored to allow organization wide settings to be added as well. CI Tests have been added to cover ReadSettings. + +## v2.3 + +### Issues +- Issue #312 Branching enhancements +- Issue #229 Create Release action tags wrong commit +- Issue #283 Create Release workflow uses deprecated actions +- Issue #319 Support for AssignPremiumPlan +- Issue #328 Allow multiple projects in AppSource App repo +- Issue #344 Deliver To AppSource on finding app.json for the app +- Issue #345 LocalDevEnv.ps1 can't Dowload the file license file + +### New Settings +New Project setting: AssignPremiumPlan on user in container executing tests and when setting up local development environment +New Repo setting: unusedALGoSystemFiles is an array of AL-Go System Files, which won't be updated during Update AL-Go System Files. They will instead be removed. Use with care, as this can break the AL-Go for GitHub functionality and potentially leave your repo no longer functional. + +### Build modes support +AL-Go projects can now be built in different modes, by specifying the _buildModes_ setting in AL-Go-Settings.json. Read more about build modes in the [Basic Repository settings](https://github.com/microsoft/AL-Go/blob/main/Scenarios/settings.md#basic-repository-settings). + +### LocalDevEnv / CloudDevEnv +With the support for PowerShell 7 in BcContainerHelper, the scripts LocalDevEnv and CloudDevEnv (placed in the .AL-Go folder) for creating development environments have been modified to run inside VS Code instead of spawning a new powershell 5.1 session. + +### Continuous Delivery +Continuous Delivery can now run from other branches than main. By specifying a property called branches, containing an array of branches in the deliveryContext json construct, the artifacts generated from this branch are also delivered. The branch specification can include wildcards (like release/*). Default is main, i.e. no changes to functionality. + +### Continuous Deployment +Continuous Deployment can now run from other branches than main. By creating a repo setting (.github/AL-Go-Settings.json) called **`-Branches`**, which is an array of branches, which will deploy the generated artifacts to this environment. The branch specification can include wildcards (like release/*), although this probably won't be used a lot in continuous deployment. Default is main, i.e. no changes to functionality. + +### Create Release +When locating artifacts for the various projects, the SHA used to build the artifact is used for the release tag +If all projects are not available with the same SHA, this error is thrown: **The build selected for release doesn't contain all projects. Please rebuild all projects by manually running the CI/CD workflow and recreate the release.** +There is no longer a hard dependency on the main branch name from Create Release. + +### AL-Go Tests +Some unit tests have been added and AL-Go unit tests can now be run directly from VS Code. +Another set of end to end tests have also been added and in the documentation on contributing to AL-Go, you can see how to run these in a local fork or from VS Code. + +### LF, UTF8 and JSON +GitHub natively uses LF as line seperator in source files. +In earlier versions of AL-Go for GitHub, many scripts and actions would use CRLF and convert back and forth. Some files were written with UTF8 BOM (Byte Order Mark), other files without and JSON formatting was done using PowerShell 5.1 (which is different from PowerShell 7). +In the latest version, we always use LF as line seperator, UTF8 without BOM and JSON files are written using PowerShell 7. If you have self-hosted runners, you need to ensure that PS7 is installed to make this work. + +### Experimental Support +Setting the repo setting "shell" to "pwsh", followed by running Update AL-Go System Files, will cause all PowerShell code to be run using PowerShell 7 instead of PowerShell 5. This functionality is experimental. Please report any issues at https://github.com/microsoft/AL-Go/issues +Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Update AL-Go System Files, will cause all non-build jobs to run using Linux. This functionality is experimental. Please report any issues at https://github.com/microsoft/AL-Go/issues + +## v2.2 + +### Enhancements +- Container Event log is added as a build artifact if builds or tests are failing + +### Issues +- Issue #280 Overflow error when test result summary was too big +- Issue #282, 292 AL-Go for GitHub causes GitHub to issue warnings +- Issue #273 Potential security issue in Pull Request Handler in Open Source repositories +- Issue #303 PullRequestHandler fails on added files +- Issue #299 Multi-project repositories build all projects on Pull Requests +- Issue #291 Issues with new Pull Request Handler +- Issue #287 AL-Go pipeline fails in ReadSettings step + +### Changes +- VersioningStrategy 1 is no longer supported. GITHUB_ID has changed behavior (Issue #277) + +## v2.1 ### Issues - Issue #233 AL-Go for GitHub causes GitHub to issue warnings diff --git a/.github/workflows/AddExistingAppOrTestApp.yaml b/.github/workflows/AddExistingAppOrTestApp.yaml index 235ca78..1ed100b 100644 --- a/.github/workflows/AddExistingAppOrTestApp.yaml +++ b/.github/workflows/AddExistingAppOrTestApp.yaml @@ -1,4 +1,4 @@ -name: 'Add existing app or test app' +name: 'Add existing app or test app' on: workflow_dispatch: @@ -21,7 +21,11 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: AddExistingAppOrTestApp: @@ -32,13 +36,15 @@ jobs: - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0090" - name: Add existing app - uses: microsoft/AL-Go-Actions/AddExistingApp@preview + uses: microsoft/AL-Go-Actions/AddExistingApp@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} url: ${{ github.event.inputs.url }} @@ -46,7 +52,8 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0090" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CICD.yaml b/.github/workflows/CICD.yaml index ee035cb..bc81409 100644 --- a/.github/workflows/CICD.yaml +++ b/.github/workflows/CICD.yaml @@ -1,182 +1,144 @@ -name: ' CI/CD' +name: ' CI/CD' on: workflow_dispatch: - workflow_run: - workflows: ["Pull Request Handler"] - types: - - completed push: paths-ignore: - - 'README.md' - - '.github/**' + - '**.md' + - '.github/workflows/*.yaml' + - '!.github/workflows/CICD.yaml' branches: [ 'main', 'release/*', 'feature/*' ] +defaults: + run: + shell: powershell + permissions: contents: read actions: read - pull-requests: write - checks: write -defaults: - run: - shell: PowerShell +env: + workflowDepth: 1 + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: Initialization: - if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' runs-on: [ windows-latest ] - env: - workflowDepth: 1 outputs: telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} settings: ${{ steps.ReadSettings.outputs.SettingsJson }} - projects: ${{ steps.ReadSettings.outputs.ProjectsJson }} - projectCount: ${{ steps.ReadSettings.outputs.ProjectCount }} environments: ${{ steps.ReadSettings.outputs.EnvironmentsJson }} environmentCount: ${{ steps.ReadSettings.outputs.EnvironmentCount }} deliveryTargets: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetsJson }} deliveryTargetCount: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetCount }} githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} + githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} checkRunId: ${{ steps.CreateCheckRun.outputs.checkRunId }} - projectDependenciesJson: ${{ steps.ReadSettings.outputs.ProjectDependenciesJson }} - buildOrderJson: ${{ steps.ReadSettings.outputs.BuildOrderJson }} - buildOrderDepth: ${{ steps.ReadSettings.outputs.BuildOrderDepth }} + projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }} + projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }} + buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }} steps: - - name: Create CI/CD Workflow Check Run - id: CreateCheckRun - if: github.event_name == 'workflow_run' - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - var details_url = context.serverUrl.concat('/',context.repo.owner,'/',context.repo.repo,'/actions/runs/',context.runId) - var response = await github.rest.checks.create({ - owner: context.repo.owner, - repo: context.repo.repo, - name: 'CI/CD Workflow', - head_sha: '${{ github.event.workflow_run.head_sha }}', - status: 'queued', - details_url: details_url, - output: { - title: 'CI/CD Workflow', - summary: '[Workflow Details]('.concat(details_url,')') - } - }); - core.setOutput('checkRunId', response.data.id); - - name: Checkout uses: actions/checkout@v3 - - - name: 'Download Pull Request Changes' - if: github.event_name == 'workflow_run' - uses: actions/github-script@v6 - with: - script: | - var run_id = Number('${{ github.event.workflow_run.id }}'); - var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: run_id - }); - var matchArtifact = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == 'Pull_Request_Files' - })[0]; - var download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip' - }); - var fs = require('fs'); - fs.writeFileSync('.PullRequestChanges.zip', Buffer.from(download.data)); - - - name: Apply Pull Request Changes - if: github.event_name == 'workflow_run' - run: | - $ErrorActionPreference = "STOP" - $location = (Get-Location).path - $prfolder = '.PullRequestChanges' - Expand-Archive -Path ".\$prfolder.zip" -DestinationPath ".\$prfolder" - Remove-Item -Path ".\$prfolder.zip" -force - Get-ChildItem -Path $prfolder -Recurse -File | ForEach-Object { - $path = $_.FullName - $deleteFile = $path.EndsWith('.REMOVE') - if ($deleteFile) { - $path = $path.SubString(0,$path.Length-7) - } - $newPath = $path.Replace("$prfolder\","") - $newFolder = [System.IO.Path]::GetDirectoryName($newPath) - $extension = [System.IO.Path]::GetExtension($path) - $filename = [System.IO.Path]::GetFileName($path) - if ('${{ github.event.workflow_run.head_repository.full_name }}' -ne $ENV:GITHUB_REPOSITORY) { - if ($extension -eq '.ps1' -or $extension -eq '.yaml' -or $extension -eq '.yml' -or $filename -eq "CODEOWNERS") { - throw "Pull Request containing changes to scripts, workflows or CODEOWNERS are not allowed from forks." - } - } - if ($deleteFile) { - if (Test-Path $newPath) { - Write-Host "Removing $newPath" - Remove-Item $newPath -Force - } - else { - Write-Host "$newPath was already deleted" - } - } - else { - if (-not (Test-Path $newFolder)) { - New-Item $newFolder -ItemType Directory | Out-Null - } - Write-Host "Copying $path to $newFolder" - Copy-Item $path -Destination $newFolder -Force - } - } + with: + lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0091" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - getProjects: 'Y' getEnvironments: '*' + + - name: Determine Projects To Build + id: determineProjectsToBuild + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v3.0 + with: + shell: powershell + maxBuildDepth: ${{ env.workflowDepth }} + + - name: Determine Delivery Target Secrets + id: DetermineDeliveryTargetSecrets + run: | + $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 + $deliveryTargetSecrets = @('GitHubPackagesContext','NuGetContext','StorageContext','AppSourceContext') + $namePrefix = 'DeliverTo' + Get-Item -Path (Join-Path $ENV:GITHUB_WORKSPACE ".github/$($namePrefix)*.ps1") | ForEach-Object { + $deliveryTarget = [System.IO.Path]::GetFileNameWithoutExtension($_.Name.SubString($namePrefix.Length)) + $deliveryTargetSecrets += @("$($deliveryTarget)Context") + } + Add-Content -Path $env:GITHUB_OUTPUT -Value "Secrets=$($deliveryTargetSecrets -join ',')" - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 env: secrets: ${{ toJson(secrets) }} with: + shell: powershell settingsJson: ${{ env.Settings }} - secrets: 'GitHubPackagesContext,NuGetContext,StorageContext,AppSourceContext' + secrets: ${{ steps.DetermineDeliveryTargetSecrets.outputs.Secrets }} - name: Determine Delivery Targets id: DetermineDeliveryTargets run: | $ErrorActionPreference = "STOP" - $deliveryTargets = @() - if ($env:StorageContext) { - $deliveryTargets += @("Storage") - } - if ($env:NuGetContext) { - $deliveryTargets += @("NuGet") - } - if ($env:GitHubPackagesContext) { - $deliveryTargets += @("GitHubPackages") - } - if ($env:type -eq "AppSource App" -and $env:AppSourceContinuousDelivery -eq "true") { - if ($env:AppSourceContext) { + Set-StrictMode -version 2.0 + $deliveryTargets = @('GitHubPackages','NuGet','Storage') + if ($env:type -eq "AppSource App") { + $continuousDelivery = $false + # For multi-project repositories, we will add deliveryTarget AppSource if any project has AppSourceContinuousDelivery set to true + ('${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}' | ConvertFrom-Json) | where-Object { $_ } | ForEach-Object { + $projectSettings = Get-Content (Join-Path $_ '.AL-Go/settings.json') -raw | ConvertFrom-Json + if ($projectSettings.PSObject.Properties.Name -eq 'AppSourceContinuousDelivery' -and $projectSettings.AppSourceContinuousDelivery) { + Write-Host "Project $_ is setup for Continuous Delivery" + $continuousDelivery = $true + } + } + if ($continuousDelivery) { $deliveryTargets += @("AppSource") } } - Get-Item -Path (Join-Path $ENV:GITHUB_WORKSPACE ".github\DeliverTo*.ps1") | ForEach-Object { - $deliveryTargets += @([System.IO.Path]::GetFileNameWithoutExtension($_.Name.SubString(9))) + $namePrefix = 'DeliverTo' + Get-Item -Path (Join-Path $ENV:GITHUB_WORKSPACE ".github/$($namePrefix)*.ps1") | ForEach-Object { + $deliveryTarget = [System.IO.Path]::GetFileNameWithoutExtension($_.Name.SubString($namePrefix.Length)) + $deliveryTargets += @($deliveryTarget) } - $deliveryTargets = $deliveryTargets | Select-Object -unique + $deliveryTargets = @($deliveryTargets | Select-Object -unique | Where-Object { + $include = $false + Write-Host "Check DeliveryTarget $_" + $contextName = "$($_)Context" + $deliveryContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($contextName))) + if ($deliveryContext) { + $settingName = "DeliverTo$_" + $settings = $env:Settings | ConvertFrom-Json + if (($settings.PSObject.Properties.Name -eq $settingName) -and ($settings."$settingName".PSObject.Properties.Name -eq "Branches")) { + Write-Host "Branches:" + $settings."$settingName".Branches | ForEach-Object { + Write-Host "- $_" + if ($ENV:GITHUB_REF_NAME -like $_) { + $include = $true + } + } + } + else { + $include = ($ENV:GITHUB_REF_NAME -eq 'main') + } + } + if ($include) { + Write-Host "DeliveryTarget $_ included" + } + $include + }) $deliveryTargetsJson = $deliveryTargets | ConvertTo-Json -Depth 99 -compress if ($deliveryTargets.Count -lt 2) { $deliveryTargetsJson = "[$($deliveryTargetsJson)]" } Add-Content -Path $env:GITHUB_OUTPUT -Value "DeliveryTargetsJson=$deliveryTargetsJson" @@ -185,73 +147,39 @@ jobs: Write-Host "DeliveryTargetCount=$($deliveryTargets.Count)" Add-Content -Path $env:GITHUB_ENV -Value "DeliveryTargets=$deliveryTargetsJson" - - name: Determine Build Order - if: env.WorkflowDepth > 1 - id: BuildOrder - run: | - $ErrorActionPreference = "STOP" - $projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json - $buildOrder = '${{ steps.ReadSettings.outputs.BuildOrderJson }}' | ConvertFrom-Json - $depth = ${{ steps.ReadSettings.outputs.BuildOrderDepth }} - $workflowDepth = ${{ steps.ReadSettings.outputs.WorkflowDepth }} - if ($depth -lt $workflowDepth) { - Write-Host "::Error::Project Dependencies depth is $depth. Workflow is only setup for $workflowDepth. You need to Run Update AL-Go System Files to update the workflows" - $host.SetShouldExit(1) - } - $step = $depth - $depth..1 | ForEach-Object { - $ps = @($buildOrder."$_" | Where-Object { $projects -contains $_ }) - if ($ps.Count -eq 1) { - $projectsJSon = "[$($ps | ConvertTo-Json -compress)]" - } - else { - $projectsJSon = $ps | ConvertTo-Json -compress - } - if ($ps.Count -gt 0) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=$projectsJson" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=$($ps.count)" - Write-Host "Projects$($step)Json=$projectsJson" - Write-Host "Projects$($step)Count=$($ps.count)" - $step-- - } - } - while ($step -ge 1) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=0" - Write-Host "Projects$($step)Json=" - Write-Host "Projects$($step)Count=0" - $step-- - } - CheckForUpdates: runs-on: [ windows-latest ] needs: [ Initialization ] - if: github.event_name != 'workflow_run' steps: - name: Checkout uses: actions/checkout@v3 - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - get: TemplateUrl + get: templateUrl - name: Check for updates to AL-Go system files - uses: microsoft/AL-Go-Actions/CheckForUpdates@preview + uses: microsoft/AL-Go-Actions/CheckForUpdates@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - templateUrl: ${{ env.TemplateUrl }} + templateUrl: ${{ env.templateUrl }} Build: needs: [ Initialization ] - if: ${{ needs.Initialization.outputs.projectCount > 0 }} + if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} + defaults: + run: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: - project: ${{ fromJson(needs.Initialization.outputs.projects) }} + include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} + name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} outputs: AppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.AppsArtifactsName }} TestAppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestAppsArtifactsName }} @@ -259,189 +187,98 @@ jobs: BcptTestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.BcptTestResultsArtifactsName }} BuildOutputArtifactsName: ${{ steps.calculateArtifactNames.outputs.BuildOutputArtifactsName }} steps: - - name: Create Build Job Check Run - id: CreateCheckRun - if: github.event_name == 'workflow_run' - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - var jobName = context.job.concat(' ${{ matrix.project }}') - var jobs = await github.rest.actions.listJobsForWorkflowRun({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.runId - }); - var job = jobs.data.jobs.filter((job) => { - return job.name == jobName - })[0]; - var details_url = context.serverUrl.concat('/',context.repo.owner,'/',context.repo.repo,'/actions/runs/',context.runId) - if (job) { - details_url = job.html_url; - } - var response = await github.rest.checks.create({ - owner: context.repo.owner, - repo: context.repo.repo, - name: context.job.concat(' ${{ matrix.project }}'), - head_sha: '${{ github.event.workflow_run.head_sha }}', - status: 'in_progress', - details_url: details_url, - output: { - 'title': context.job.concat(' ${{ matrix.project }}'), - 'summary': '[Workflow Details]('.concat(details_url,')') - } - }); - core.setOutput('checkRunId', response.data.id); - core.setOutput('detailsUrl', details_url); - - - name: Update CI/CD Workflow Check Run - if: github.event_name == 'workflow_run' - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - var response = await github.rest.checks.update({ - owner: context.repo.owner, - repo: context.repo.repo, - check_run_id: ${{ needs.Initialization.outputs.checkRunId }}, - status: 'in_progress' - }); - - name: Checkout uses: actions/checkout@v3 with: lfs: true - - - name: Download artifacts + + - name: Download thisbuild artifacts + if: env.workflowDepth > 1 uses: actions/download-artifact@v3 with: - path: '${{ github.workspace }}\.dependencies' - - - name: 'Download Pull Request Changes' - if: github.event_name == 'workflow_run' - uses: actions/github-script@v6 - with: - script: | - var run_id = Number('${{ github.event.workflow_run.id }}'); - var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: run_id - }); - var matchArtifact = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == 'Pull_Request_Files' - })[0]; - var download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip' - }); - var fs = require('fs'); - fs.writeFileSync('.PullRequestChanges.zip', Buffer.from(download.data)); - - - name: Apply Pull Request Changes - if: github.event_name == 'workflow_run' - run: | - $ErrorActionPreference = "STOP" - $location = (Get-Location).path - $prfolder = '.PullRequestChanges' - Expand-Archive -Path ".\$prfolder.zip" -DestinationPath ".\$prfolder" - Remove-Item -Path ".\$prfolder.zip" -force - Get-ChildItem -Path $prfolder -Recurse -File | ForEach-Object { - $path = $_.FullName - $deleteFile = $path.EndsWith('.REMOVE') - if ($deleteFile) { - $path = $path.SubString(0,$path.Length-7) - } - $newPath = $path.Replace("$prfolder\","") - $newFolder = [System.IO.Path]::GetDirectoryName($newPath) - $extension = [System.IO.Path]::GetExtension($path) - $filename = [System.IO.Path]::GetFileName($path) - if ('${{ github.event.workflow_run.head_repository.full_name }}' -ne $ENV:GITHUB_REPOSITORY) { - if ($extension -eq '.ps1' -or $extension -eq '.yaml' -or $extension -eq '.yml' -or $filename -eq "CODEOWNERS") { - throw "Pull Request containing changes to scripts, workflows or CODEOWNERS are not allowed from forks." - } - } - if ($deleteFile) { - if (Test-Path $newPath) { - Write-Host "Removing $newPath" - Remove-Item $newPath -Force - } - else { - Write-Host "$newPath was already deleted" - } - } - else { - if (-not (Test-Path $newFolder)) { - New-Item $newFolder -ItemType Directory | Out-Null - } - Write-Host "Copying $path to $newFolder" - Copy-Item $path -Destination $newFolder -Force - } - } + path: '.dependencies' - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} project: ${{ matrix.project }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 env: secrets: ${{ toJson(secrets) }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,StorageContext,GitHubPackagesContext' + secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,storageContext,gitHubPackagesContext' - name: Run pipeline id: RunPipeline - uses: microsoft/AL-Go-Actions/RunPipeline@preview + uses: microsoft/AL-Go-Actions/RunPipeline@v3.0 + env: + BuildMode: ${{ matrix.buildMode }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} - ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} + project: ${{ matrix.project }} + projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} settingsJson: ${{ env.Settings }} - SecretsJson: ${{ env.RepoSecrets }} + secretsJson: ${{ env.RepoSecrets }} + buildMode: ${{ matrix.buildMode }} - name: Calculate Artifact names - id: calculateArtifactNames + id: calculateArtifactsNames + uses: microsoft/AL-Go-Actions/CalculateArtifactNames@v3.0 if: success() || failure() - run: | - $ErrorActionPreference = "STOP" - $settings = '${{ env.Settings }}' | ConvertFrom-Json - $project = '${{ matrix.project }}' - if ($project -eq ".") { $project = $settings.RepoName } - 'Apps','Dependencies','TestApps','TestResults','BcptTestResults','BuildOutput' | ForEach-Object { - $name = "$($_)ArtifactsName" - $value = "$($project.Replace('\','_'))-$("$ENV:GITHUB_REF_NAME".Replace('/','_'))-$_-$($settings.repoVersion).$($settings.appBuild).$($settings.appRevision)" - Add-Content -Path $env:GITHUB_OUTPUT -Value "$name=$value" - Add-Content -Path $env:GITHUB_ENV -Value "$name=$value" - } + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + settingsJson: ${{ env.Settings }} + project: ${{ matrix.project }} + buildMode: ${{ matrix.buildMode }} + branchName: ${{ github.ref_name }} + + - name: Upload thisbuild artifacts - apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} + path: '${{ matrix.project }}/.buildartifacts/Apps/' + if-no-files-found: ignore + retention-days: 1 + + - name: Upload thisbuild artifacts - test apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} + path: '${{ matrix.project }}/.buildartifacts/TestApps/' + if-no-files-found: ignore + retention-days: 1 - name: Publish artifacts - apps uses: actions/upload-artifact@v3 - if: (github.event_name != 'workflow_run') && (github.ref_name == 'main' || startswith(github.ref_name, 'release/')) + if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 with: - name: ${{ env.appsArtifactsName }} + name: ${{ env.AppsArtifactsName }} path: '${{ matrix.project }}/.buildartifacts/Apps/' if-no-files-found: ignore - name: Publish artifacts - dependencies uses: actions/upload-artifact@v3 - if: (github.event_name != 'workflow_run') && (github.ref_name == 'main' || startswith(github.ref_name, 'release/')) + if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 with: - name: ${{ env.dependenciesArtifactsName }} + name: ${{ env.DependenciesArtifactsName }} path: '${{ matrix.project }}/.buildartifacts/Dependencies/' if-no-files-found: ignore - name: Publish artifacts - test apps uses: actions/upload-artifact@v3 - if: (github.event_name != 'workflow_run') && (github.ref_name == 'main' || startswith(github.ref_name, 'release/')) + if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 with: - name: ${{ env.testAppsArtifactsName }} + name: ${{ env.TestAppsArtifactsName }} path: '${{ matrix.project }}/.buildartifacts/TestApps/' if-no-files-found: ignore @@ -449,15 +286,23 @@ jobs: uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') with: - name: ${{ env.buildOutputArtifactsName }} + name: ${{ env.BuildOutputArtifactsName }} path: '${{ matrix.project }}/BuildOutput.txt' if-no-files-found: ignore + - name: Publish artifacts - container event log + uses: actions/upload-artifact@v3 + if: (failure()) && (hashFiles(format('{0}/ContainerEventLog.evtx',matrix.project)) != '') + with: + name: ${{ env.ContainerEventLogArtifactsName }} + path: '${{ matrix.project }}/ContainerEventLog.evtx' + if-no-files-found: ignore + - name: Publish artifacts - test results uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') with: - name: ${{ env.testResultsArtifactsName }} + name: ${{ env.TestResultsArtifactsName }} path: '${{ matrix.project }}/TestResults.xml' if-no-files-found: ignore @@ -465,50 +310,30 @@ jobs: uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/bcptTestResults.json',matrix.project)) != '') with: - name: ${{ env.bcptTestResultsArtifactsName }} + name: ${{ env.BcptTestResultsArtifactsName }} path: '${{ matrix.project }}/bcptTestResults.json' if-no-files-found: ignore - name: Analyze Test Results id: analyzeTestResults if: success() || failure() - uses: microsoft/AL-Go-Actions/AnalyzeTests@preview + uses: microsoft/AL-Go-Actions/AnalyzeTests@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} - - name: Update Build Job Check Run - if: always() && github.event_name == 'workflow_run' - uses: actions/github-script@v6 - env: - TestResultMD: ${{ steps.analyzeTestResults.outputs.TestResultMD }} - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - var details_url = '${{ steps.CreateCheckRun.outputs.detailsUrl }}' - var testResultMD = process.env.TestResultMD - var response = await github.rest.checks.update({ - owner: context.repo.owner, - repo: context.repo.repo, - check_run_id: ${{ steps.CreateCheckRun.outputs.checkRunId }}, - conclusion: '${{ steps.RunPipeline.conclusion }}', - output: { - title: context.job.concat(' ${{ matrix.project }}'), - summary: testResultMD.replaceAll('\\n','\n'), - text: '[Workflow details]('.concat(details_url,')') - } - }); - - name: Cleanup if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@preview + uses: microsoft/AL-Go-Actions/PipelineCleanup@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} Deploy: needs: [ Initialization, Build ] - if: always() && needs.Build.result == 'Success' && github.event_name != 'workflow_run' && github.ref_name == 'main' && needs.Initialization.outputs.environmentCount > 0 + if: always() && needs.Build.result == 'Success' && needs.Initialization.outputs.environmentCount > 0 strategy: ${{ fromJson(needs.Initialization.outputs.environments) }} runs-on: ${{ fromJson(matrix.os) }} name: Deploy to ${{ matrix.environment }} @@ -521,37 +346,49 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v3 with: - path: '${{ github.workspace }}\.artifacts' + path: '.artifacts' - name: EnvName id: envName run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $envName = '${{ matrix.environment }}'.split(' ')[0] Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 + with: + shell: powershell - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 env: secrets: ${{ toJson(secrets) }} with: + shell: powershell settingsJson: ${{ env.Settings }} - secrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,Projects' + secrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,projects' - name: AuthContext id: authContext run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $envName = '${{ steps.envName.outputs.envName }}' + $deployToSettingStr = [System.Environment]::GetEnvironmentVariable("DeployTo$envName") + if ($deployToSettingStr) { + $deployToSetting = $deployToSettingStr | ConvertFrom-Json + } + else { + $deployToSetting = [PSCustomObject]@{} + } $authContext = $null "$($envName)-AuthContext", "$($envName)_AuthContext", "AuthContext" | ForEach-Object { if (!($authContext)) { $authContext = [System.Environment]::GetEnvironmentVariable($_) if ($authContext) { - Write-Host "Using $_ secret" + Write-Host "Using $_ secret as AuthContext" } } } @@ -559,28 +396,39 @@ jobs: Write-Host "::Error::No AuthContext provided" exit 1 } - $environmentName = $null - "$($envName)-EnvironmentName", "$($envName)_EnvironmentName", "EnvironmentName" | ForEach-Object { - if (!($EnvironmentName)) { - $EnvironmentName = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($_))) - if ($EnvironmentName) { - Write-Host "Using $_ secret" - } - } + if (("$deployToSetting" -ne "") -and $deployToSetting.PSObject.Properties.name -eq "EnvironmentName") { + $environmentName = $deployToSetting.EnvironmentName + } + else { + $environmentName = $null + "$($envName)-EnvironmentName", "$($envName)_EnvironmentName", "EnvironmentName" | ForEach-Object { + if (!($EnvironmentName)) { + $EnvironmentName = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($_))) + if ($EnvironmentName) { + Write-Host "Using $_ secret as EnvironmentName" + Write-Host "Please consider using the DeployTo$_ setting instead, where you can specify EnvironmentName, projects and branches" + } + } + } } if (!($environmentName)) { $environmentName = '${{ steps.envName.outputs.envName }}' } $environmentName = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($environmentName + '${{ matrix.environment }}'.SubString($envName.Length)).ToUpperInvariant())) - $projects = [System.Environment]::GetEnvironmentVariable("$($envName)-Projects") - if (-not $projects) { - $projects = [System.Environment]::GetEnvironmentVariable("$($envName)_Projects") + if (("$deployToSetting" -ne "") -and $deployToSetting.PSObject.Properties.name -eq "projects") { + $projects = $deployToSetting.projects + } + else { + $projects = [System.Environment]::GetEnvironmentVariable("$($envName)-projects") if (-not $projects) { - $projects = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('projects'))) + $projects = [System.Environment]::GetEnvironmentVariable("$($envName)_Projects") + if (-not $projects) { + $projects = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('projects'))) + } } } - if ($projects -eq '') { + if ($projects -eq '' -or $projects -eq '*') { $projects = '*' } else { @@ -591,23 +439,25 @@ jobs: Add-Content -Path $env:GITHUB_OUTPUT -Value "authContext=$authContext" Write-Host "authContext=$authContext" Add-Content -Path $env:GITHUB_OUTPUT -Value "environmentName=$environmentName" - Write-Host "environmentName=$environmentName" + Write-Host "environmentName=$([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($environmentName)))" + Write-Host "environmentName (as Base64)=$environmentName" Add-Content -Path $env:GITHUB_OUTPUT -Value "projects=$projects" Write-Host "projects=$projects" - name: Deploy - uses: microsoft/AL-Go-Actions/Deploy@preview + uses: microsoft/AL-Go-Actions/Deploy@v3.0 env: - authContext: ${{ steps.authContext.outputs.authContext }} + AuthContext: ${{ steps.authContext.outputs.authContext }} with: + shell: powershell type: 'CD' projects: ${{ steps.authContext.outputs.projects }} environmentName: ${{ steps.authContext.outputs.environmentName }} - artifacts: '${{ github.workspace }}\.artifacts' + artifacts: '.artifacts' Deliver: needs: [ Initialization, Build ] - if: always() && needs.Build.result == 'Success' && github.event_name != 'workflow_run' && github.ref_name == 'main' && needs.Initialization.outputs.deliveryTargetCount > 0 + if: always() && needs.Build.result == 'Success' && needs.Initialization.outputs.deliveryTargetCount > 0 strategy: matrix: deliveryTarget: ${{ fromJson(needs.Initialization.outputs.deliveryTargets) }} @@ -621,16 +471,19 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v3 with: - path: '${{ github.workspace }}\.artifacts' + path: '.artifacts' - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 + with: + shell: powershell - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 env: secrets: ${{ toJson(secrets) }} with: + shell: powershell settingsJson: ${{ env.Settings }} secrets: '${{ matrix.deliveryTarget }}Context' @@ -638,40 +491,25 @@ jobs: id: deliveryContext run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $contextName = '${{ matrix.deliveryTarget }}Context' $deliveryContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($contextName))) Add-Content -Path $env:GITHUB_OUTPUT -Value "deliveryContext=$deliveryContext" Write-Host "deliveryContext=$deliveryContext" - name: Deliver - uses: microsoft/AL-Go-Actions/Deliver@preview + uses: microsoft/AL-Go-Actions/Deliver@v3.0 env: deliveryContext: ${{ steps.deliveryContext.outputs.deliveryContext }} with: + shell: powershell type: 'CD' projects: ${{ needs.Initialization.outputs.projects }} deliveryTarget: ${{ matrix.deliveryTarget }} - artifacts: '${{ github.workspace }}\.artifacts' - - UpdatePRcheck: - if: always() && github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' - runs-on: [ windows-latest ] - needs: [ Initialization, Build ] - steps: - - name: Update CI/CD Workflow Check Run - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - var response = await github.rest.checks.update({ - owner: context.repo.owner, - repo: context.repo.repo, - check_run_id: ${{ needs.Initialization.outputs.checkRunId }}, - conclusion: '${{ needs.Build.result }}' - }); + artifacts: '.artifacts' PostProcess: - if: (!cancelled()) && (github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success') + if: (!cancelled()) runs-on: [ windows-latest ] needs: [ Initialization, Build, Deploy, Deliver ] steps: @@ -680,7 +518,8 @@ jobs: - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0091" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateApp.yaml b/.github/workflows/CreateApp.yaml index 0b6a2dd..40bfa8a 100644 --- a/.github/workflows/CreateApp.yaml +++ b/.github/workflows/CreateApp.yaml @@ -1,4 +1,4 @@ -name: 'Create a new app' +name: 'Create a new app' on: workflow_dispatch: @@ -31,7 +31,11 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: CreateApp: @@ -42,19 +46,22 @@ jobs: - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0092" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} get: type - name: Creating a new app - uses: microsoft/AL-Go-Actions/CreateApp@preview + uses: microsoft/AL-Go-Actions/CreateApp@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} type: ${{ env.type }} @@ -66,7 +73,8 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0092" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml b/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml index eb8a1b5..96078f7 100644 --- a/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml +++ b/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml @@ -1,4 +1,4 @@ -name: ' Create Online Dev. Environment' +name: ' Create Online Dev. Environment' on: workflow_dispatch: @@ -21,7 +21,11 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: CreateOnlineDevelopmentEnvironment: @@ -32,26 +36,31 @@ jobs: - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0093" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 env: secrets: ${{ toJson(secrets) }} with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} secrets: 'adminCenterApiCredentials' - name: Check AdminCenterApiCredentials / Initiate Device Login (open to see code) run: | + $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $adminCenterApiCredentials = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($env:adminCenterApiCredentials)) if ($adminCenterApiCredentials) { Write-Host "AdminCenterApiCredentials provided!" @@ -60,7 +69,7 @@ jobs: Write-Host "AdminCenterApiCredentials not provided, initiating Device Code flow" $ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" $webClient = New-Object System.Net.WebClient - $webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/preview/AL-Go-Helper.ps1', $ALGoHelperPath) + $webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v3.0/AL-Go-Helper.ps1', $ALGoHelperPath) . $ALGoHelperPath $BcContainerHelperPath = DownloadAndImportBcContainerHelper -baseFolder $ENV:GITHUB_WORKSPACE $authContext = New-BcAuthContext -includeDeviceLogin -deviceLoginTimeout ([TimeSpan]::FromSeconds(0)) @@ -71,8 +80,9 @@ jobs: } - name: Create Development Environment - uses: microsoft/AL-Go-Actions/CreateDevelopmentEnvironment@preview + uses: microsoft/AL-Go-Actions/CreateDevelopmentEnvironment@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} environmentName: ${{ github.event.inputs.environmentName }} reUseExistingEnvironment: ${{ github.event.inputs.reUseExistingEnvironment }} @@ -81,7 +91,8 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0093" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreatePerformanceTestApp.yaml b/.github/workflows/CreatePerformanceTestApp.yaml index 0877e5c..b09cc13 100644 --- a/.github/workflows/CreatePerformanceTestApp.yaml +++ b/.github/workflows/CreatePerformanceTestApp.yaml @@ -1,4 +1,4 @@ -name: 'Create a new performance test app' +name: 'Create a new performance test app' on: workflow_dispatch: @@ -37,7 +37,11 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: CreatePerformanceTestApp: @@ -48,13 +52,15 @@ jobs: - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0102" - name: Creating a new test app - uses: microsoft/AL-Go-Actions/CreateApp@preview + uses: microsoft/AL-Go-Actions/CreateApp@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} type: 'Performance Test App' @@ -67,7 +73,8 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0102" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateRelease.yaml b/.github/workflows/CreateRelease.yaml index c6a0f47..2310bb9 100644 --- a/.github/workflows/CreateRelease.yaml +++ b/.github/workflows/CreateRelease.yaml @@ -1,4 +1,4 @@ -name: ' Create release' +name: ' Create release' on: workflow_dispatch: @@ -45,75 +45,114 @@ concurrency: release defaults: run: - shell: PowerShell + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: - Initialization: + CreateRelease: runs-on: [ windows-latest ] outputs: telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + artifacts: ${{ steps.analyzeartifacts.outputs.artifacts }} + releaseId: ${{ steps.createrelease.outputs.releaseId }} + commitish: ${{ steps.analyzeartifacts.outputs.commitish }} + releaseBranch: ${{ steps.createreleasenotes.outputs.releaseBranch }} steps: - name: Checkout uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0094" - CreateRelease: - runs-on: [ windows-latest ] - needs: [ Initialization ] - outputs: - artifacts: ${{ steps.analyzeartifacts.outputs.artifacts }} - upload_url: ${{ steps.createrelease.outputs.upload_url }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 + with: + shell: powershell + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + get: templateUrl,repoName + + - name: Determine Projects + id: determineProjects + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v3.0 with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - get: TemplateUrl,RepoName - getProjects: 'Y' + shell: powershell - name: Check for updates to AL-Go system files - uses: microsoft/AL-Go-Actions/CheckForUpdates@preview + uses: microsoft/AL-Go-Actions/CheckForUpdates@v3.0 with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - templateUrl: ${{ env.TemplateUrl }} + shell: powershell + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + templateUrl: ${{ env.templateUrl }} - name: Analyze Artifacts id: analyzeartifacts run: | $ErrorActionPreference = "STOP" - $projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json - $projects | out-host + Set-StrictMode -version 2.0 + $projects = '${{ steps.determineProjects.outputs.ProjectsJson }}' | ConvertFrom-Json + Write-Host "projects:" + $projects | ForEach-Object { Write-Host "- $_" } $include = @() + $sha = '' + $allArtifacts = @() + $page = 1 + $headers = @{ + "Authorization" = "token ${{ github.token }}" + "Accept" = "application/json" + } + do { + $repoArtifacts = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/actions/artifacts?per_page=100&page=$page" | ConvertFrom-Json + $allArtifacts += $repoArtifacts.Artifacts + $page++ + } + while ($repoArtifacts.Artifacts.Count -gt 0) + Write-Host "Repo Artifacts count: $($repoArtifacts.total_count)" + Write-Host "Downloaded Artifacts count: $($allArtifacts.Count)" $projects | ForEach-Object { $thisProject = $_ if ($thisProject -and ($thisProject -ne '.')) { - $project = $thisProject.Replace('\','_') + $project = $thisProject.Replace('\','_').Replace('/','_') } else { - $project = $env:RepoName + $project = $env:repoName } + $refname = "$ENV:GITHUB_REF_NAME".Replace('/','_') Write-Host "Analyzing artifacts for project $project" $appVersion = '${{ github.event.inputs.appVersion }}' - $headers = @{ - "Authorization" = "token ${{ github.token }}" - "Accept" = "application/json" - } - $allArtifacts = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/actions/artifacts" | ConvertFrom-Json - $artifactsVersion = $appVersion if ($appVersion -eq "latest") { - $artifact = $allArtifacts.artifacts | Where-Object { $_.name -like "$project-*-Apps-*" } | Select-Object -First 1 - $artifactsVersion = $artifact.name.SubString($artifact.name.IndexOf('-Apps-')+6) + Write-Host "Grab latest" + $artifact = $allArtifacts | Where-Object { $_.name -like "$project-$refname-Apps-*" } | Select-Object -First 1 + } + else { + Write-Host "Search for $project-$refname-Apps-$appVersion" + $artifact = $allArtifacts | Where-Object { $_.name -eq "$project-$refname-Apps-$appVersion" } | Select-Object -First 1 + } + if ($artifact) { + $artifactsVersion = $artifact.name.SubString($artifact.name.LastIndexOf('-Apps-')+6) + } + else { + Write-Host "::Error::No artifacts found for this project" + exit 1 + } + if ($sha) { + if ($artifact.workflow_run.head_sha -ne $sha) { + Write-Host "::Error::The build selected for release doesn't contain all projects. Please rebuild all projects by manually running the CI/CD workflow and recreate the release." + throw "The build selected for release doesn't contain all projects. Please rebuild all projects by manually running the CI/CD workflow and recreate the release." + } } - $allArtifacts.artifacts | Where-Object { $_.name -like "$project-*-Apps-$($artifactsVersion)" -or $_.name -like "$project-*-TestApps-$($artifactsVersion)" -or $_.name -like "$project-*-Dependencies-$($artifactsVersion)" } | ForEach-Object { + else { + $sha = $artifact.workflow_run.head_sha + } + + $allArtifacts | Where-Object { ($_.name -like "$project-$refname-Apps-$($artifactsVersion)" -or $_.name -like "$project-$refname-TestApps-$($artifactsVersion)" -or $_.name -like "$project-$refname-Dependencies-$($artifactsVersion)") } | ForEach-Object { $atype = $_.name.SubString(0,$_.name.Length-$artifactsVersion.Length-1) $atype = $atype.SubString($atype.LastIndexOf('-')+1) $include += $( [ordered]@{ "name" = $_.name; "url" = $_.archive_download_url; "atype" = $atype; "project" = $thisproject } ) @@ -127,28 +166,44 @@ jobs: $artifactsJson = $artifacts | ConvertTo-Json -compress Add-Content -Path $env:GITHUB_OUTPUT -Value "artifacts=$artifactsJson" Write-Host "artifacts=$artifactsJson" + Add-Content -Path $env:GITHUB_OUTPUT -Value "commitish=$sha" + Write-Host "commitish=$sha" - name: Prepare release notes id: createreleasenotes - uses: microsoft/AL-Go-Actions/CreateReleaseNotes@preview + uses: microsoft/AL-Go-Actions/CreateReleaseNotes@v3.0 with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: powershell + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} tag_name: ${{ github.event.inputs.tag }} - name: Create release - uses: actions/create-release@v1 + uses: actions/github-script@v6 id: createrelease env: - GITHUB_TOKEN: ${{ github.token }} + bodyMD: ${{ steps.createreleasenotes.outputs.releaseNotes }} with: - draft: ${{ github.event.inputs.draft=='Y' }} - prerelease: ${{ github.event.inputs.prerelease=='Y' }} - release_name: ${{ github.event.inputs.name }} - tag_name: ${{ github.event.inputs.tag }} - body: ${{ steps.createreleasenotes.outputs.releaseNotes }} + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var bodyMD = process.env.bodyMD + const createReleaseResponse = await github.rest.repos.createRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: '${{ github.event.inputs.tag }}', + name: '${{ github.event.inputs.name }}', + body: bodyMD.replaceAll('\\n','\n'), + draft: ${{ github.event.inputs.draft=='Y' }}, + prerelease: ${{ github.event.inputs.prerelease=='Y' }}, + make_latest: 'legacy', + target_commitish: '${{ steps.analyzeartifacts.outputs.commitish }}' + }); + const { + data: { id: releaseId, html_url: htmlUrl, upload_url: uploadUrl } + } = createReleaseResponse; + core.setOutput('releaseId', releaseId); UploadArtifacts: - runs-on: [ windows-latest ] + runs-on: [ windows-latest ] needs: [ CreateRelease ] strategy: matrix: ${{ fromJson(needs.CreateRelease.outputs.artifacts) }} @@ -158,81 +213,95 @@ jobs: uses: actions/checkout@v3 - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: powershell + parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 env: secrets: ${{ toJson(secrets) }} with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: powershell + parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'NuGetContext,StorageContext' + secrets: 'nuGetContext,storageContext' - name: Download artifact run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 Write-Host "Downloading artifact ${{ matrix.name}}" $headers = @{ "Authorization" = "token ${{ github.token }}" "Accept" = "application/vnd.github.v3+json" } Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri '${{ matrix.url }}' -OutFile '${{ matrix.name }}.zip' - + - name: Upload release artifacts - uses: actions/upload-release-asset@v1 + uses: actions/github-script@v6 env: - GITHUB_TOKEN: ${{ github.token }} + releaseId: ${{ needs.createrelease.outputs.releaseId }} with: - upload_url: ${{ needs.createrelease.outputs.upload_url }} - asset_path: '${{ matrix.name }}.zip' - asset_name: '${{ matrix.name }}.zip' - asset_content_type: application/zip + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const releaseId = process.env.releaseId + const assetPath = '${{ matrix.name }}.zip' + const assetName = '${{ matrix.name }}.zip' + const fs = require('fs'); + const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: releaseId, + name: assetName, + data: fs.readFileSync(assetPath) + }); - - name: NuGetContext + - name: nuGetContext id: nuGetContext - if: ${{ env.NuGetContext }} + if: ${{ env.nuGetContext }} run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $nuGetContext = '' if ('${{ matrix.atype }}' -eq 'Apps') { - $nuGetContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('NuGetContext'))) + $nuGetContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('nuGetContext'))) } Add-Content -Path $env:GITHUB_OUTPUT -Value "nuGetContext=$nuGetContext" - Write-Host "nuGetContext=$nuGetContext" - name: Deliver to NuGet - uses: microsoft/AL-Go-Actions/Deliver@preview + uses: microsoft/AL-Go-Actions/Deliver@v3.0 if: ${{ steps.nuGetContext.outputs.nuGetContext }} env: deliveryContext: ${{ steps.nuGetContext.outputs.nuGetContext }} with: + shell: powershell type: 'Release' projects: ${{ matrix.project }} deliveryTarget: 'NuGet' artifacts: ${{ github.event.inputs.appVersion }} atypes: 'Apps,TestApps' - - name: StorageContext + - name: storageContext id: storageContext - if: ${{ env.StorageContext }} + if: ${{ env.storageContext }} run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $storageContext = '' if ('${{ matrix.atype }}' -eq 'Apps') { - $storageContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('StorageContext'))) + $storageContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('storageContext'))) } - Write-Host "Add-Content -Path $env:GITHUB_OUTPUT -Value "storageContext=$storageContext" - Write-Host "storageContext=$storageContext" + Add-Content -Path $env:GITHUB_OUTPUT -Value "storageContext=$storageContext" - name: Deliver to Storage - uses: microsoft/AL-Go-Actions/Deliver@preview + uses: microsoft/AL-Go-Actions/Deliver@v3.0 if: ${{ steps.storageContext.outputs.storageContext }} env: deliveryContext: ${{ steps.storageContext.outputs.storageContext }} with: + shell: powershell type: 'Release' projects: ${{ matrix.project }} deliveryTarget: 'Storage' @@ -242,43 +311,48 @@ jobs: CreateReleaseBranch: if: ${{ github.event.inputs.createReleaseBranch=='Y' }} runs-on: [ windows-latest ] - needs: [ Initialization, CreateRelease, UploadArtifacts ] + needs: [ CreateRelease, UploadArtifacts ] steps: - name: Checkout uses: actions/checkout@v3 + with: + ref: '${{ needs.createRelease.outputs.commitish }}' - name: Create Release Branch run: | $ErrorActionPreference = "STOP" - git checkout -b release/${{ github.event.inputs.tag }} + Set-StrictMode -version 2.0 + git checkout -b ${{ needs.CreateRelease.outputs.releaseBranch }} git config user.name ${{ github.actor}} git config user.email ${{ github.actor}}@users.noreply.github.com - git commit --allow-empty -m "Release branch ${{ github.event.inputs.tag }}" - git push origin release/${{ github.event.inputs.tag }} + git commit --allow-empty -m "Release branch ${{ needs.CreateRelease.outputs.releaseBranch }}" + git push origin ${{ needs.CreateRelease.outputs.releaseBranch }} UpdateVersionNumber: if: ${{ github.event.inputs.updateVersionNumber!='' }} runs-on: [ windows-latest ] - needs: [ Initialization, CreateRelease, UploadArtifacts ] + needs: [ CreateRelease, UploadArtifacts ] steps: - name: Update Version Number - uses: microsoft/AL-Go-Actions/IncrementVersionNumber@preview + uses: microsoft/AL-Go-Actions/IncrementVersionNumber@v3.0 with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: powershell + parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} versionNumber: ${{ github.event.inputs.updateVersionNumber }} directCommit: ${{ github.event.inputs.directCommit }} PostProcess: if: always() runs-on: [ windows-latest ] - needs: [ Initialization, CreateRelease, UploadArtifacts, CreateReleaseBranch, UpdateVersionNumber ] + needs: [ CreateRelease, UploadArtifacts, CreateReleaseBranch, UpdateVersionNumber ] steps: - name: Checkout uses: actions/checkout@v3 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0094" - telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + telemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateTestApp.yaml b/.github/workflows/CreateTestApp.yaml index 9e099e3..47e7ad7 100644 --- a/.github/workflows/CreateTestApp.yaml +++ b/.github/workflows/CreateTestApp.yaml @@ -1,4 +1,4 @@ -name: 'Create a new test app' +name: 'Create a new test app' on: workflow_dispatch: @@ -33,7 +33,11 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: CreateTestApp: @@ -44,13 +48,15 @@ jobs: - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0095" - name: Creating a new test app - uses: microsoft/AL-Go-Actions/CreateApp@preview + uses: microsoft/AL-Go-Actions/CreateApp@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} type: 'Test App' @@ -62,7 +68,8 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0095" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/Current.yaml b/.github/workflows/Current.yaml index ba77a64..0c0f0bd 100644 --- a/.github/workflows/Current.yaml +++ b/.github/workflows/Current.yaml @@ -1,4 +1,4 @@ -name: ' Test Current' +name: ' Test Current' on: workflow_dispatch: @@ -8,86 +8,63 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell + +env: + workflowDepth: 1 + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: Initialization: runs-on: [ windows-latest ] - env: - workflowDepth: 1 outputs: telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} settings: ${{ steps.ReadSettings.outputs.SettingsJson }} - projects: ${{ steps.ReadSettings.outputs.ProjectsJson }} - projectCount: ${{ steps.ReadSettings.outputs.ProjectCount }} githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} - projectDependenciesJson: ${{ steps.ReadSettings.outputs.ProjectDependenciesJson }} - buildOrderJson: ${{ steps.ReadSettings.outputs.BuildOrderJson }} - buildOrderDepth: ${{ steps.ReadSettings.outputs.BuildOrderDepth }} + githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} + projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }} + projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }} + buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }} steps: - name: Checkout uses: actions/checkout@v3 + with: + lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0101" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - getProjects: 'Y' - - - name: Determine Build Order - if: env.WorkflowDepth > 1 - id: BuildOrder - run: | - $ErrorActionPreference = "STOP" - $projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json - $buildOrder = '${{ steps.ReadSettings.outputs.BuildOrderJson }}' | ConvertFrom-Json - $depth = ${{ steps.ReadSettings.outputs.BuildOrderDepth }} - $workflowDepth = ${{ steps.ReadSettings.outputs.WorkflowDepth }} - if ($depth -lt $workflowDepth) { - Write-Host "::Error::Project Dependencies depth is $depth. Workflow is only setup for $workflowDepth. You need to Run Update AL-Go System Files to update the workflows" - $host.SetShouldExit(1) - } - $step = $depth - $depth..1 | ForEach-Object { - $ps = @($buildOrder."$_" | Where-Object { $projects -contains $_ }) - if ($ps.Count -eq 1) { - $projectsJSon = "[$($ps | ConvertTo-Json -compress)]" - } - else { - $projectsJSon = $ps | ConvertTo-Json -compress - } - if ($ps.Count -gt 0) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=$projectsJson" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=$($ps.count)" - Write-Host "Projects$($step)Json=$projectsJson" - Write-Host "Projects$($step)Count=$($ps.count)" - $step-- - } - } - while ($step -ge 1) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=0" - Write-Host "Projects$($step)Json=" - Write-Host "Projects$($step)Count=0" - $step-- - } + + - name: Determine Projects To Build + id: determineProjectsToBuild + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v3.0 + with: + shell: powershell + maxBuildDepth: ${{ env.workflowDepth }} Build: needs: [ Initialization ] - if: ${{ needs.Initialization.outputs.projectCount > 0 }} + if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} + defaults: + run: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: - project: ${{ fromJson(needs.Initialization.outputs.projects) }} + include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} + name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} outputs: TestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestResultsArtifactsName }} BcptTestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.BcptTestResultsArtifactsName }} @@ -95,50 +72,74 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - - name: Download artifacts + with: + lfs: true + + - name: Download thisbuild artifacts + if: env.workflowDepth > 1 uses: actions/download-artifact@v3 with: path: '${{ github.workspace }}\.dependencies' - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} project: ${{ matrix.project }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 env: secrets: ${{ toJson(secrets) }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,GitHubPackagesContext' + secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - name: Run pipeline - uses: microsoft/AL-Go-Actions/RunPipeline@preview + uses: microsoft/AL-Go-Actions/RunPipeline@v3.0 + env: + BuildMode: ${{ matrix.buildMode }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} - ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} + project: ${{ matrix.project }} + projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} settingsJson: ${{ env.Settings }} - SecretsJson: ${{ env.RepoSecrets }} + secretsJson: ${{ env.RepoSecrets }} + buildMode: ${{ matrix.buildMode }} - name: Calculate Artifact names - id: calculateArtifactNames + id: calculateArtifactsNames + uses: microsoft/AL-Go-Actions/CalculateArtifactNames@v3.0 if: success() || failure() - run: | - $ErrorActionPreference = "STOP" - $settings = '${{ env.Settings }}' | ConvertFrom-Json - $project = '${{ matrix.project }}' - if ($project -eq ".") { $project = $settings.RepoName } - 'TestResults','BcptTestResults','BuildOutput' | ForEach-Object { - $name = "$($_)ArtifactsName" - $value = "$($project.Replace('\','_'))-$_-Current-$([DateTime]::UtcNow.ToString('yyyyMMdd'))" - Add-Content -Path $env:GITHUB_OUTPUT -Value "$name=$value" - Add-Content -Path $env:GITHUB_ENV -Value "$name=$value" - } + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + settingsJson: ${{ env.Settings }} + project: ${{ matrix.project }} + buildMode: ${{ matrix.buildMode }} + branchName: ${{ github.ref_name }} + suffix: 'Current' + + - name: Upload thisbuild artifacts - apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} + path: '${{ matrix.project }}/.buildartifacts/Apps/' + if-no-files-found: ignore + retention-days: 1 + + - name: Upload thisbuild artifacts - test apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} + path: '${{ matrix.project }}/.buildartifacts/TestApps/' + if-no-files-found: ignore + retention-days: 1 - name: Publish artifacts - build output uses: actions/upload-artifact@v3 @@ -148,11 +149,19 @@ jobs: path: '${{ matrix.project }}/BuildOutput.txt' if-no-files-found: ignore + - name: Publish artifacts - container event log + uses: actions/upload-artifact@v3 + if: (failure()) && (hashFiles(format('{0}/ContainerEventLog.evtx',matrix.project)) != '') + with: + name: ${{ env.ContainerEventLogArtifactsName }} + path: '${{ matrix.project }}/ContainerEventLog.evtx' + if-no-files-found: ignore + - name: Publish artifacts - test results uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') with: - name: ${{ env.testResultsArtifactsName }} + name: ${{ env.TestResultsArtifactsName }} path: '${{ matrix.project }}/TestResults.xml' if-no-files-found: ignore @@ -160,22 +169,24 @@ jobs: uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/bcptTestResults.json',matrix.project)) != '') with: - name: ${{ env.bcptTestResultsArtifactsName }} + name: ${{ env.BcptTestResultsArtifactsName }} path: '${{ matrix.project }}/bcptTestResults.json' if-no-files-found: ignore - name: Analyze Test Results id: analyzeTestResults if: success() || failure() - uses: microsoft/AL-Go-Actions/AnalyzeTests@preview + uses: microsoft/AL-Go-Actions/AnalyzeTests@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} - name: Cleanup if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@preview + uses: microsoft/AL-Go-Actions/PipelineCleanup@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -189,7 +200,8 @@ jobs: - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0101" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/IncrementVersionNumber.yaml b/.github/workflows/IncrementVersionNumber.yaml index 51771b5..a7e86c8 100644 --- a/.github/workflows/IncrementVersionNumber.yaml +++ b/.github/workflows/IncrementVersionNumber.yaml @@ -1,52 +1,59 @@ -name: ' Increment Version Number' - -on: - workflow_dispatch: - inputs: - project: - description: Project name if the repository is setup for multiple projects (* for all projects) - required: false - default: '*' - versionNumber: - description: Updated Version Number. Use Major.Minor for absolute change, use +Major.Minor for incremental change. - required: true - directCommit: - description: Direct COMMIT (Y/N) - required: false - default: 'N' - -permissions: - contents: write - pull-requests: write - -defaults: - run: - shell: PowerShell - -jobs: - IncrementVersionNumber: - runs-on: [ windows-latest ] - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Initialize the workflow - id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview - with: - eventId: "DO0096" - - - name: Increment Version Number - uses: microsoft/AL-Go-Actions/IncrementVersionNumber@preview - with: - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - project: ${{ github.event.inputs.project }} - versionNumber: ${{ github.event.inputs.versionNumber }} - directCommit: ${{ github.event.inputs.directCommit }} - - - name: Finalize the workflow - if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview - with: - eventId: "DO0096" - telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} +name: ' Increment Version Number' + +on: + workflow_dispatch: + inputs: + project: + description: Project name if the repository is setup for multiple projects (* for all projects) + required: false + default: '*' + versionNumber: + description: Updated Version Number. Use Major.Minor for absolute change, use +Major.Minor for incremental change. + required: true + directCommit: + description: Direct COMMIT (Y/N) + required: false + default: 'N' + +permissions: + contents: write + pull-requests: write + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + IncrementVersionNumber: + runs-on: [ windows-latest ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 + with: + shell: powershell + eventId: "DO0096" + + - name: Increment Version Number + uses: microsoft/AL-Go-Actions/IncrementVersionNumber@v3.0 + with: + shell: powershell + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + project: ${{ github.event.inputs.project }} + versionNumber: ${{ github.event.inputs.versionNumber }} + directCommit: ${{ github.event.inputs.directCommit }} + + - name: Finalize the workflow + if: always() + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 + with: + shell: powershell + eventId: "DO0096" + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/NextMajor.yaml b/.github/workflows/NextMajor.yaml index 342018e..80d28d3 100644 --- a/.github/workflows/NextMajor.yaml +++ b/.github/workflows/NextMajor.yaml @@ -1,95 +1,70 @@ -name: ' Test Next Major' +name: ' Test Next Major' on: workflow_dispatch: - schedule: - - cron: "0 0 * * 3" # Wednesday every week permissions: contents: read defaults: run: - shell: PowerShell + shell: powershell + +env: + workflowDepth: 1 + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: Initialization: runs-on: [ windows-latest ] - env: - workflowDepth: 1 outputs: telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} settings: ${{ steps.ReadSettings.outputs.SettingsJson }} - projects: ${{ steps.ReadSettings.outputs.ProjectsJson }} - projectCount: ${{ steps.ReadSettings.outputs.ProjectCount }} githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} - projectDependenciesJson: ${{ steps.ReadSettings.outputs.ProjectDependenciesJson }} - buildOrderJson: ${{ steps.ReadSettings.outputs.BuildOrderJson }} - buildOrderDepth: ${{ steps.ReadSettings.outputs.BuildOrderDepth }} + githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} + projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }} + projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }} + buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }} steps: - name: Checkout uses: actions/checkout@v3 + with: + lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0099" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - getProjects: 'Y' - - - name: Determine Build Order - if: env.WorkflowDepth > 1 - id: BuildOrder - run: | - $ErrorActionPreference = "STOP" - $projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json - $buildOrder = '${{ steps.ReadSettings.outputs.BuildOrderJson }}' | ConvertFrom-Json - $depth = ${{ steps.ReadSettings.outputs.BuildOrderDepth }} - $workflowDepth = ${{ steps.ReadSettings.outputs.WorkflowDepth }} - if ($depth -lt $workflowDepth) { - Write-Host "::Error::Project Dependencies depth is $depth. Workflow is only setup for $workflowDepth. You need to Run Update AL-Go System Files to update the workflows" - $host.SetShouldExit(1) - } - $step = $depth - $depth..1 | ForEach-Object { - $ps = @($buildOrder."$_" | Where-Object { $projects -contains $_ }) - if ($ps.Count -eq 1) { - $projectsJSon = "[$($ps | ConvertTo-Json -compress)]" - } - else { - $projectsJSon = $ps | ConvertTo-Json -compress - } - if ($ps.Count -gt 0) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=$projectsJson" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=$($ps.count)" - Write-Host "Projects$($step)Json=$projectsJson" - Write-Host "Projects$($step)Count=$($ps.count)" - $step-- - } - } - while ($step -ge 1) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=0" - Write-Host "Projects$($step)Json=" - Write-Host "Projects$($step)Count=0" - $step-- - } + + - name: Determine Projects To Build + id: determineProjectsToBuild + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v3.0 + with: + shell: powershell + maxBuildDepth: ${{ env.workflowDepth }} Build: needs: [ Initialization ] - if: ${{ needs.Initialization.outputs.projectCount > 0 }} + if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} + defaults: + run: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: - project: ${{ fromJson(needs.Initialization.outputs.projects) }} + include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} + name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} outputs: TestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestResultsArtifactsName }} BcptTestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.BcptTestResultsArtifactsName }} @@ -97,50 +72,74 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - - name: Download artifacts + with: + lfs: true + + - name: Download thisbuild artifacts + if: env.workflowDepth > 1 uses: actions/download-artifact@v3 with: path: '${{ github.workspace }}\.dependencies' - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} project: ${{ matrix.project }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 env: secrets: ${{ toJson(secrets) }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,GitHubPackagesContext' + secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - name: Run pipeline - uses: microsoft/AL-Go-Actions/RunPipeline@preview + uses: microsoft/AL-Go-Actions/RunPipeline@v3.0 + env: + BuildMode: ${{ matrix.buildMode }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} - ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} + project: ${{ matrix.project }} + projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} settingsJson: ${{ env.Settings }} - SecretsJson: ${{ env.RepoSecrets }} + secretsJson: ${{ env.RepoSecrets }} + buildMode: ${{ matrix.buildMode }} - name: Calculate Artifact names - id: calculateArtifactNames + id: calculateArtifactsNames + uses: microsoft/AL-Go-Actions/CalculateArtifactNames@v3.0 if: success() || failure() - run: | - $ErrorActionPreference = "STOP" - $settings = '${{ env.Settings }}' | ConvertFrom-Json - $project = '${{ matrix.project }}' - if ($project -eq ".") { $project = $settings.RepoName } - 'TestResults','BcptTestResults','BuildOutput' | ForEach-Object { - $name = "$($_)ArtifactsName" - $value = "$($project.Replace('\','_'))-$_-NextMajor-$([DateTime]::UtcNow.ToString('yyyyMMdd'))" - Add-Content -Path $env:GITHUB_OUTPUT -Value "$name=$value" - Add-Content -Path $env:GITHUB_ENV -Value "$name=$value" - } + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + settingsJson: ${{ env.Settings }} + project: ${{ matrix.project }} + buildMode: ${{ matrix.buildMode }} + branchName: ${{ github.ref_name }} + suffix: 'NextMajor' + + - name: Upload thisbuild artifacts - apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} + path: '${{ matrix.project }}/.buildartifacts/Apps/' + if-no-files-found: ignore + retention-days: 1 + + - name: Upload thisbuild artifacts - test apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} + path: '${{ matrix.project }}/.buildartifacts/TestApps/' + if-no-files-found: ignore + retention-days: 1 - name: Publish artifacts - build output uses: actions/upload-artifact@v3 @@ -150,11 +149,19 @@ jobs: path: '${{ matrix.project }}/BuildOutput.txt' if-no-files-found: ignore + - name: Publish artifacts - container event log + uses: actions/upload-artifact@v3 + if: (failure()) && (hashFiles(format('{0}/ContainerEventLog.evtx',matrix.project)) != '') + with: + name: ${{ env.ContainerEventLogArtifactsName }} + path: '${{ matrix.project }}/ContainerEventLog.evtx' + if-no-files-found: ignore + - name: Publish artifacts - test results uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') with: - name: ${{ env.testResultsArtifactsName }} + name: ${{ env.TestResultsArtifactsName }} path: '${{ matrix.project }}/TestResults.xml' if-no-files-found: ignore @@ -162,22 +169,24 @@ jobs: uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/bcptTestResults.json',matrix.project)) != '') with: - name: ${{ env.bcptTestResultsArtifactsName }} + name: ${{ env.BcptTestResultsArtifactsName }} path: '${{ matrix.project }}/bcptTestResults.json' if-no-files-found: ignore - name: Analyze Test Results id: analyzeTestResults if: success() || failure() - uses: microsoft/AL-Go-Actions/AnalyzeTests@preview + uses: microsoft/AL-Go-Actions/AnalyzeTests@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} - name: Cleanup if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@preview + uses: microsoft/AL-Go-Actions/PipelineCleanup@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -191,7 +200,8 @@ jobs: - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0099" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/NextMinor.yaml b/.github/workflows/NextMinor.yaml index 2219889..3dd5deb 100644 --- a/.github/workflows/NextMinor.yaml +++ b/.github/workflows/NextMinor.yaml @@ -1,95 +1,70 @@ -name: ' Test Next Minor' +name: ' Test Next Minor' on: workflow_dispatch: - schedule: - - cron: "0 0 * * 3" # Wednesday every week permissions: contents: read defaults: run: - shell: PowerShell + shell: powershell + +env: + workflowDepth: 1 + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: Initialization: runs-on: [ windows-latest ] - env: - workflowDepth: 1 outputs: telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} settings: ${{ steps.ReadSettings.outputs.SettingsJson }} - projects: ${{ steps.ReadSettings.outputs.ProjectsJson }} - projectCount: ${{ steps.ReadSettings.outputs.ProjectCount }} githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} - projectDependenciesJson: ${{ steps.ReadSettings.outputs.ProjectDependenciesJson }} - buildOrderJson: ${{ steps.ReadSettings.outputs.BuildOrderJson }} - buildOrderDepth: ${{ steps.ReadSettings.outputs.BuildOrderDepth }} + githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} + projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }} + projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }} + buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }} steps: - name: Checkout uses: actions/checkout@v3 + with: + lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0100" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - getProjects: 'Y' - - - name: Determine Build Order - if: env.WorkflowDepth > 1 - id: BuildOrder - run: | - $ErrorActionPreference = "STOP" - $projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json - $buildOrder = '${{ steps.ReadSettings.outputs.BuildOrderJson }}' | ConvertFrom-Json - $depth = ${{ steps.ReadSettings.outputs.BuildOrderDepth }} - $workflowDepth = ${{ steps.ReadSettings.outputs.WorkflowDepth }} - if ($depth -lt $workflowDepth) { - Write-Host "::Error::Project Dependencies depth is $depth. Workflow is only setup for $workflowDepth. You need to Run Update AL-Go System Files to update the workflows" - $host.SetShouldExit(1) - } - $step = $depth - $depth..1 | ForEach-Object { - $ps = @($buildOrder."$_" | Where-Object { $projects -contains $_ }) - if ($ps.Count -eq 1) { - $projectsJSon = "[$($ps | ConvertTo-Json -compress)]" - } - else { - $projectsJSon = $ps | ConvertTo-Json -compress - } - if ($ps.Count -gt 0) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=$projectsJson" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=$($ps.count)" - Write-Host "Projects$($step)Json=$projectsJson" - Write-Host "Projects$($step)Count=$($ps.count)" - $step-- - } - } - while ($step -ge 1) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=0" - Write-Host "Projects$($step)Json=" - Write-Host "Projects$($step)Count=0" - $step-- - } + + - name: Determine Projects To Build + id: determineProjectsToBuild + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v3.0 + with: + shell: powershell + maxBuildDepth: ${{ env.workflowDepth }} Build: needs: [ Initialization ] - if: ${{ needs.Initialization.outputs.projectCount > 0 }} + if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} + defaults: + run: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: - project: ${{ fromJson(needs.Initialization.outputs.projects) }} + include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} + name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} outputs: TestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestResultsArtifactsName }} BcptTestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.BcptTestResultsArtifactsName }} @@ -97,51 +72,75 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - - name: Download artifacts + with: + lfs: true + + - name: Download thisbuild artifacts + if: env.workflowDepth > 1 uses: actions/download-artifact@v3 with: path: '${{ github.workspace }}\.dependencies' - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} project: ${{ matrix.project }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 env: secrets: ${{ toJson(secrets) }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,GitHubPackagesContext' + secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - name: Run pipeline - uses: microsoft/AL-Go-Actions/RunPipeline@preview + uses: microsoft/AL-Go-Actions/RunPipeline@v3.0 + env: + BuildMode: ${{ matrix.buildMode }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} - ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} + project: ${{ matrix.project }} + projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} settingsJson: ${{ env.Settings }} - SecretsJson: ${{ env.RepoSecrets }} + secretsJson: ${{ env.RepoSecrets }} + buildMode: ${{ matrix.buildMode }} - name: Calculate Artifact names - id: calculateArtifactNames + id: calculateArtifactsNames + uses: microsoft/AL-Go-Actions/CalculateArtifactNames@v3.0 if: success() || failure() - run: | - $ErrorActionPreference = "STOP" - $settings = '${{ env.Settings }}' | ConvertFrom-Json - $project = '${{ matrix.project }}' - if ($project -eq ".") { $project = $settings.RepoName } - 'TestResults','BcptTestResults','BuildOutput' | ForEach-Object { - $name = "$($_)ArtifactsName" - $value = "$($project.Replace('\','_'))-$_-NextMinor-$([DateTime]::UtcNow.ToString('yyyyMMdd'))" - Add-Content -Path $env:GITHUB_OUTPUT -Value "$name=$value" - Add-Content -Path $env:GITHUB_ENV -Value "$name=$value" - } + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + settingsJson: ${{ env.Settings }} + project: ${{ matrix.project }} + buildMode: ${{ matrix.buildMode }} + branchName: ${{ github.ref_name }} + suffix: 'NextMinor' + - name: Upload thisbuild artifacts - apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} + path: '${{ matrix.project }}/.buildartifacts/Apps/' + if-no-files-found: ignore + retention-days: 1 + + - name: Upload thisbuild artifacts - test apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} + path: '${{ matrix.project }}/.buildartifacts/TestApps/' + if-no-files-found: ignore + retention-days: 1 + - name: Publish artifacts - build output uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') @@ -150,11 +149,19 @@ jobs: path: '${{ matrix.project }}/BuildOutput.txt' if-no-files-found: ignore + - name: Publish artifacts - container event log + uses: actions/upload-artifact@v3 + if: (failure()) && (hashFiles(format('{0}/ContainerEventLog.evtx',matrix.project)) != '') + with: + name: ${{ env.ContainerEventLogArtifactsName }} + path: '${{ matrix.project }}/ContainerEventLog.evtx' + if-no-files-found: ignore + - name: Publish artifacts - test results uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') with: - name: ${{ env.testResultsArtifactsName }} + name: ${{ env.TestResultsArtifactsName }} path: '${{ matrix.project }}/TestResults.xml' if-no-files-found: ignore @@ -162,22 +169,24 @@ jobs: uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/bcptTestResults.json',matrix.project)) != '') with: - name: ${{ env.bcptTestResultsArtifactsName }} + name: ${{ env.BcptTestResultsArtifactsName }} path: '${{ matrix.project }}/bcptTestResults.json' if-no-files-found: ignore - name: Analyze Test Results id: analyzeTestResults if: success() || failure() - uses: microsoft/AL-Go-Actions/AnalyzeTests@preview + uses: microsoft/AL-Go-Actions/AnalyzeTests@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} - name: Cleanup if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@preview + uses: microsoft/AL-Go-Actions/PipelineCleanup@v3.0 with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -191,7 +200,8 @@ jobs: - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0100" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/PublishToEnvironment.yaml b/.github/workflows/PublishToEnvironment.yaml index 9d57a96..adae8c8 100644 --- a/.github/workflows/PublishToEnvironment.yaml +++ b/.github/workflows/PublishToEnvironment.yaml @@ -1,4 +1,4 @@ -name: ' Publish To Environment' +name: ' Publish To Environment' on: workflow_dispatch: @@ -17,7 +17,11 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: Initialization: @@ -33,14 +37,16 @@ jobs: - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0097" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} getEnvironments: ${{ github.event.inputs.environmentName }} includeProduction: 'Y' @@ -61,31 +67,43 @@ jobs: id: envName run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $envName = '${{ matrix.environment }}'.split(' ')[0] Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 + with: + shell: powershell - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 env: secrets: ${{ toJson(secrets) }} with: + shell: powershell settingsJson: ${{ env.Settings }} - secrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,Projects' + secrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,projects' - name: AuthContext id: authContext run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $envName = '${{ steps.envName.outputs.envName }}' + $deployToSettingStr = [System.Environment]::GetEnvironmentVariable("DeployTo$envName") + if ($deployToSettingStr) { + $deployToSetting = $deployToSettingStr | ConvertFrom-Json + } + else { + $deployToSetting = [PSCustomObject]@{} + } $authContext = $null "$($envName)-AuthContext", "$($envName)_AuthContext", "AuthContext" | ForEach-Object { if (!($authContext)) { $authContext = [System.Environment]::GetEnvironmentVariable($_) if ($authContext) { - Write-Host "Using $_ secret" + Write-Host "Using $_ secret as AuthContext" } } } @@ -93,43 +111,58 @@ jobs: Write-Host "::Error::No AuthContext provided" exit 1 } - $environmentName = $null - "$($envName)-EnvironmentName", "$($envName)_EnvironmentName", "EnvironmentName" | ForEach-Object { - if (!($EnvironmentName)) { - $EnvironmentName = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($_))) - if ($EnvironmentName) { - Write-Host "Using $_ secret" - } - } + if (("$deployToSetting" -ne "") -and $deployToSetting.PSObject.Properties.name -eq "EnvironmentName") { + $environmentName = $deployToSetting.EnvironmentName + } + else { + $environmentName = $null + "$($envName)-EnvironmentName", "$($envName)_EnvironmentName", "EnvironmentName" | ForEach-Object { + if (!($environmentName)) { + $EnvironmentName = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($_))) + if ($EnvironmentName) { + Write-Host "Using $_ secret as EnvironmentName" + Write-Host "Please consider using the DeployTo$_ setting instead, where you can specify EnvironmentName, projects and branches" + } + } + } } if (!($environmentName)) { $environmentName = '${{ steps.envName.outputs.envName }}' } $environmentName = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($environmentName + '${{ matrix.environment }}'.SubString($envName.Length)).ToUpperInvariant())) - - $projects = [System.Environment]::GetEnvironmentVariable("$($envName)-Projects") - if (-not $projects) { - $projects = [System.Environment]::GetEnvironmentVariable("$($envName)_Projects") + if (("$deployToSetting" -ne "") -and $deployToSetting.PSObject.Properties.name -eq "projects") { + $projects = $deployToSetting.projects + } + else { + $projects = [System.Environment]::GetEnvironmentVariable("$($envName)-projects") if (-not $projects) { - $projects = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('projects'))) + $projects = [System.Environment]::GetEnvironmentVariable("$($envName)_Projects") + if (-not $projects) { + $projects = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('projects'))) + } } } if ($projects -eq '') { $projects = '*' } - + elseif ($projects -ne '*') { + $buildProjects = '${{ needs.Initialization.outputs.projects }}' | ConvertFrom-Json + $projects = ($projects.Split(',') | Where-Object { $buildProjects -contains $_ }) -join ',' + } Add-Content -Path $env:GITHUB_OUTPUT -Value "authContext=$authContext" Write-Host "authContext=$authContext" Add-Content -Path $env:GITHUB_OUTPUT -Value "environmentName=$environmentName" - Write-Host "environmentName=$environmentName" + Write-Host "environmentName=$([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($environmentName)))" + Write-Host "environmentName (as Base64)=$environmentName" Add-Content -Path $env:GITHUB_OUTPUT -Value "projects=$projects" Write-Host "projects=$projects" - name: Deploy - uses: microsoft/AL-Go-Actions/Deploy@preview + uses: microsoft/AL-Go-Actions/Deploy@v3.0 env: - authContext: ${{ steps.authContext.outputs.authContext }} + AuthContext: ${{ steps.authContext.outputs.authContext }} with: + shell: powershell parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} type: 'Publish' projects: ${{ steps.authContext.outputs.projects }} @@ -146,7 +179,8 @@ jobs: - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0097" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/PullRequestHandler.yaml b/.github/workflows/PullRequestHandler.yaml index badb80c..9212d82 100644 --- a/.github/workflows/PullRequestHandler.yaml +++ b/.github/workflows/PullRequestHandler.yaml @@ -1,84 +1,241 @@ -name: 'Pull Request Handler' +name: 'Pull Request Build' on: - pull_request: + pull_request_target: paths-ignore: - - '*.md' - - '*.ps1' - - '*.yaml' + - '**.md' branches: [ 'main' ] +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + defaults: run: - shell: PowerShell + shell: powershell permissions: contents: read actions: read pull-requests: read +env: + workflowDepth: 1 + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + jobs: - PullRequestHandler: + PregateCheck: + if: github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name runs-on: [ windows-latest ] steps: - uses: actions/checkout@v3 - - - name: Determine Changed Files - id: ChangedFiles - run: | - $ErrorActionPreference = "STOP" - $sb = [System.Text.StringBuilder]::new() - $headers = @{ - "Authorization" = 'token ${{ secrets.GITHUB_TOKEN }}' - "Accept" = "application/vnd.github.baptiste-preview+json" - } - $baseSHA = '${{ github.event.pull_request.base.sha }}' - $headSHA = '${{ github.event.pull_request.head.sha }}' - $url = "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/compare/$baseSHA...$headSHA" - $response = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $url | ConvertFrom-Json - $location = (Get-Location).path - $prfolder = [GUID]::NewGuid().ToString() - Add-Content -Path $env:GITHUB_OUTPUT -Value "prfolder=$prfolder" - $prPath = Join-Path $location $prFolder - New-Item -Path $prPath -ItemType Directory | Out-Null - Write-Host "Files Changed:" - $response.files | ForEach-Object { - $filename = $_.filename - $status = $_.status - Write-Host "- $filename $status" - $path = Join-Path $location $filename - $newPath = Join-Path $prPath $filename - $newfolder = [System.IO.Path]::GetDirectoryName($newpath) - $extension = [System.IO.Path]::GetExtension($path) - $name = [System.IO.Path]::GetFileName($path) - if ('${{ github.event.pull_request.head.repo.full_name }}' -ne $ENV:GITHUB_REPOSITORY) { - if ($extension -eq '.ps1' -or $extension -eq '.yaml' -or $extension -eq '.yml' -or $name -eq "CODEOWNERS") { - throw "Pull Request containing changes to scripts, workflows or CODEOWNERS are not allowed from forks." - } - } - if (-not (Test-Path $newfolder)) { - New-Item $newfolder -ItemType Directory | Out-Null - } - if ($status -eq "renamed") { - Copy-Item -Path $path -Destination $newfolder -Force - $oldPath = Join-Path $prPath $_.previous_filename - $oldFolder = [System.IO.Path]::GetDirectoryName($oldpath) - if (-not (Test-Path $oldFolder)) { - New-Item $oldFolder -ItemType Directory | Out-Null - } - New-Item -Path "$oldPath.REMOVE" -itemType File | Out-Null - } - elseif ($status -eq "removed") { - New-Item -Path $newfolder -name "$name.REMOVE" -itemType File | Out-Null - } - else { - Copy-Item -Path $path -Destination $newfolder -Force - } - } - Set-Content -path (Join-Path $prPath "comment_id") -value '${{ steps.CreateComment.outputs.comment_id }}' -NoNewLine -Force - - - name: Upload Changed Files + with: + lfs: true + ref: refs/pull/${{ github.event.number }}/merge + + - uses: microsoft/AL-Go-Actions/VerifyPRChanges@v3.0 + with: + baseSHA: ${{ github.event.pull_request.base.sha }} + headSHA: ${{ github.event.pull_request.head.sha }} + prbaseRepository: ${{ github.event.pull_request.base.repo.full_name }} + + Initialization: + needs: [ PregateCheck ] + if: (!failure() && !cancelled()) + runs-on: [ windows-latest ] + outputs: + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + settings: ${{ steps.ReadSettings.outputs.SettingsJson }} + 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 }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + lfs: true + ref: refs/pull/${{ github.event.number }}/merge + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 + with: + shell: powershell + eventId: "DO0104" + + - name: Read settings + id: ReadSettings + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 + with: + shell: powershell + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + getEnvironments: '*' + + - name: Determine Projects To Build + id: determineProjectsToBuild + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v3.0 + with: + shell: powershell + maxBuildDepth: ${{ env.workflowDepth }} + + Build: + needs: [ Initialization ] + if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 + runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} + defaults: + run: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + strategy: + matrix: + include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} + fail-fast: false + name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} + outputs: + AppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.AppsArtifactsName }} + TestAppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestAppsArtifactsName }} + TestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestResultsArtifactsName }} + BcptTestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.BcptTestResultsArtifactsName }} + BuildOutputArtifactsName: ${{ steps.calculateArtifactNames.outputs.BuildOutputArtifactsName }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + lfs: true + ref: refs/pull/${{ github.event.number }}/merge + + - name: Download thisbuild artifacts + if: env.workflowDepth > 1 + uses: actions/download-artifact@v3 + with: + path: '.dependencies' + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + project: ${{ matrix.project }} + + - name: Read secrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 + env: + secrets: ${{ toJson(secrets) }} + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + settingsJson: ${{ env.Settings }} + secrets: 'licenseFileUrl,insiderSasToken,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' + + - name: Run pipeline + id: RunPipeline + uses: microsoft/AL-Go-Actions/RunPipeline@v3.0 + env: + BuildMode: ${{ matrix.buildMode }} + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + project: ${{ matrix.project }} + projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} + settingsJson: ${{ env.Settings }} + secretsJson: ${{ env.RepoSecrets }} + buildMode: ${{ matrix.buildMode }} + + - name: Calculate Artifact names + id: calculateArtifactsNames + uses: microsoft/AL-Go-Actions/CalculateArtifactNames@v3.0 + if: success() || failure() + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + settingsJson: ${{ env.Settings }} + project: ${{ matrix.project }} + buildMode: ${{ matrix.buildMode }} + branchName: ${{ github.ref_name }} + + - name: Upload thisbuild artifacts - apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} + path: '${{ matrix.project }}/.buildartifacts/Apps/' + if-no-files-found: ignore + retention-days: 1 + + - name: Upload thisbuild artifacts - test apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} + path: '${{ matrix.project }}/.buildartifacts/TestApps/' + if-no-files-found: ignore + retention-days: 1 + + - name: Publish artifacts - build output + uses: actions/upload-artifact@v3 + if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') + with: + name: ${{ env.BuildOutputArtifactsName }} + path: '${{ matrix.project }}/BuildOutput.txt' + if-no-files-found: ignore + + - name: Publish artifacts - container event log + uses: actions/upload-artifact@v3 + if: (failure()) && (hashFiles(format('{0}/ContainerEventLog.evtx',matrix.project)) != '') + with: + name: ${{ env.ContainerEventLogArtifactsName }} + path: '${{ matrix.project }}/ContainerEventLog.evtx' + if-no-files-found: ignore + + - name: Publish artifacts - test results uses: actions/upload-artifact@v3 + if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') + with: + name: ${{ env.TestResultsArtifactsName }} + path: '${{ matrix.project }}/TestResults.xml' + if-no-files-found: ignore + + - name: Publish artifacts - bcpt test results + uses: actions/upload-artifact@v3 + if: (success() || failure()) && (hashFiles(format('{0}/bcptTestResults.json',matrix.project)) != '') + with: + name: ${{ env.BcptTestResultsArtifactsName }} + path: '${{ matrix.project }}/bcptTestResults.json' + if-no-files-found: ignore + + - name: Analyze Test Results + id: analyzeTestResults + if: success() || failure() + uses: microsoft/AL-Go-Actions/AnalyzeTests@v3.0 + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + Project: ${{ matrix.project }} + + - name: Cleanup + if: always() + uses: microsoft/AL-Go-Actions/PipelineCleanup@v3.0 + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + Project: ${{ matrix.project }} + + PostProcess: + runs-on: [ windows-latest ] + needs: [ Initialization, Build ] + if: (!cancelled()) + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + lfs: true + ref: refs/pull/${{ github.event.number }}/merge + + - name: Finalize the workflow + id: PostProcess + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: - name: Pull_Request_Files - path: '${{ steps.ChangedFiles.outputs.prfolder }}/' + shell: powershell + eventId: "DO0104" + telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/UpdateGitHubGoSystemFiles.yaml b/.github/workflows/UpdateGitHubGoSystemFiles.yaml index b23b2e5..7d5fb49 100644 --- a/.github/workflows/UpdateGitHubGoSystemFiles.yaml +++ b/.github/workflows/UpdateGitHubGoSystemFiles.yaml @@ -1,10 +1,10 @@ -name: ' Update AL-Go System Files' +name: ' Update AL-Go System Files' on: workflow_dispatch: inputs: templateUrl: - description: Template Repository URL (current is https://github.com/microsoft/AL-Go-PTE@preview) + description: Template Repository URL (current is https://github.com/microsoft/AL-Go-PTE@main) required: false default: '' directCommit: @@ -17,7 +17,11 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: UpdateALGoSystemFiles: @@ -28,34 +32,38 @@ jobs: - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v3.0 with: + shell: powershell eventId: "DO0098" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - get: KeyVaultName,GhTokenWorkflowSecretName,TemplateUrl + get: keyVaultName,ghTokenWorkflowSecretName,templateUrl - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + uses: microsoft/AL-Go-Actions/ReadSecrets@v3.0 env: secrets: ${{ toJson(secrets) }} with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} secrets: 'ghTokenWorkflow=${{ env.GHTOKENWORKFLOWSECRETNAME }}' - - name: Override TemplateUrl + - name: Override templateUrl env: templateUrl: ${{ github.event.inputs.templateUrl }} run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $templateUrl = $ENV:templateUrl if ($templateUrl) { Write-Host "Using Template Url: $templateUrl" - Add-Content -Path $env:GITHUB_ENV -Value "TemplateUrl=$templateUrl" + Add-Content -Path $env:GITHUB_ENV -Value "templateUrl=$templateUrl" } - name: Calculate DirectCommit @@ -64,6 +72,7 @@ jobs: eventName: ${{ github.event_name }} run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $directCommit = $ENV:directCommit Write-Host $ENV:eventName if ($ENV:eventName -eq 'schedule') { @@ -73,17 +82,19 @@ jobs: Add-Content -Path $env:GITHUB_ENV -Value "DirectCommit=$directCommit" - name: Update AL-Go system files - uses: microsoft/AL-Go-Actions/CheckForUpdates@preview + uses: microsoft/AL-Go-Actions/CheckForUpdates@v3.0 with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} token: ${{ env.ghTokenWorkflow }} Update: Y - templateUrl: ${{ env.TemplateUrl }} + templateUrl: ${{ env.templateUrl }} directCommit: ${{ env.directCommit }} - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v3.0 with: + shell: powershell eventId: "DO0098" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}