Skip to content

Commit

Permalink
Merge pull request #2 from SearchAndDestroy/xue55izd.d31
Browse files Browse the repository at this point in the history
Updated AL-Go System Files
  • Loading branch information
SearchAndDestroy authored Mar 1, 2023
2 parents 88a0e55 + 30dfa6a commit e935df3
Show file tree
Hide file tree
Showing 18 changed files with 768 additions and 408 deletions.
52 changes: 18 additions & 34 deletions .AL-Go/cloudDevEnv.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
#
# 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
Expand All @@ -12,43 +12,25 @@ Param(
$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 GitHub Helper module"
$GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1"
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v2.4/Github-Helper.psm1', $GitHubHelperPath)
Write-Host "Downloading AL-Go Helper script"
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v2.2/AL-Go-Helper.ps1', $ALGoHelperPath)
. $ALGoHelperPath -local
$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1"
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v2.4/AL-Go-Helper.ps1', $ALGoHelperPath)

$baseFolder = Join-Path $PSScriptRoot ".." -Resolve
Import-Module $GitHubHelperPath
. $ALGoHelperPath -local

$baseFolder = GetBaseFolder -folder $PSScriptRoot
$project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot

Clear-Host
Write-Host
Write-Host -ForegroundColor Yellow @'
_____ _ _ _____ ______
/ ____| | | | | __ \ | ____|
Expand All @@ -70,18 +52,19 @@ 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
$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"
-default "$($env:USERNAME)-sandbox" `
-trimCharacters @('"',"'",' ')
}

if (-not $PSBoundParameters.ContainsKey('reuseExistingEnvironment')) {
if ($PSBoundParameters.Keys -notcontains 'reuseExistingEnvironment') {
$reuseExistingEnvironment = (Select-Value `
-title "What if the environment already exists?" `
-options @{ "Yes" = "Reuse existing environment"; "No" = "Recreate environment" } `
Expand All @@ -94,7 +77,8 @@ CreateDevEnv `
-caller local `
-environmentName $environmentName `
-reuseExistingEnvironment:$reuseExistingEnvironment `
-baseFolder $baseFolder
-baseFolder $baseFolder `
-project $project
}
catch {
Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)"
Expand Down
55 changes: 16 additions & 39 deletions .AL-Go/localDevEnv.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
#
# 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
Expand All @@ -15,52 +15,25 @@ Param(
$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/v2.2/Github-Helper.psm1', $GitHubHelperPath)
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v2.4/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/v2.2/AL-Go-Helper.ps1', $ALGoHelperPath)
$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v2.4/AL-Go-Helper.ps1', $ALGoHelperPath)

Import-Module $GitHubHelperPath
. $ALGoHelperPath -local

$baseFolder = Join-Path $PSScriptRoot ".." -Resolve
$baseFolder = GetBaseFolder -folder $PSScriptRoot
$project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot

Clear-Host
Write-Host
Write-Host -ForegroundColor Yellow @'
_ _ _____ ______
| | | | | __ \ | ____|
Expand All @@ -82,7 +55,7 @@ The script will also modify launch.json to have a Local Sandbox configuration po
'@

$settings = ReadSettings -baseFolder $baseFolder -userName $env:USERNAME
$settings = ReadSettings -baseFolder $baseFolder -project $project -userName $env:USERNAME

Write-Host "Checking System Requirements"
$dockerProcess = (Get-Process "dockerd" -ErrorAction Ignore)
Expand All @@ -91,7 +64,7 @@ if (!($dockerProcess)) {
}
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 -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)."
}
}

Expand All @@ -101,7 +74,8 @@ if (-not $containerName) {
$containerName = Enter-Value `
-title "Container name" `
-question "Please enter the name of the container to create" `
-default "bcserver"
-default "bcserver" `
-trimCharacters @('"',"'",' ')
}

if (-not $auth) {
Expand Down Expand Up @@ -140,7 +114,9 @@ if (-not $licenseFileUrl) {
-title "LicenseFileUrl" `
-description $description `
-question "Local path or a secure download URL to license file " `
-default $default
-default $default `
-doNotConvertToLower `
-trimCharacters @('"',"'",' ')

if ($licenseFileUrl -eq "none") {
$licenseFileUrl = ""
Expand All @@ -152,10 +128,11 @@ CreateDevEnv `
-caller local `
-containerName $containerName `
-baseFolder $baseFolder `
-project $project `
-auth $auth `
-credential $credential `
-LicenseFileUrl $licenseFileUrl `
-InsiderSasToken $insiderSasToken
-licenseFileUrl $licenseFileUrl `
-insiderSasToken $insiderSasToken
}
catch {
Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)"
Expand Down
2 changes: 1 addition & 1 deletion .github/AL-Go-Settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"type": "PTE",
"templateUrl": "https://github.com/microsoft/AL-Go-PTE@main"
}
85 changes: 85 additions & 0 deletions .github/RELEASENOTES.copy.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,88 @@
## v2.4

### Issues
- Issue [#171](https://github.com/microsoft/AL-Go/issues/171) create a workspace file when creating a project
- Issue [#356](https://github.com/microsoft/AL-Go/issues/356) Publish to AppSource fails in multi project repo
- Issue [#358](https://github.com/microsoft/AL-Go/issues/358) Publish To Environment Action stopped working in v2.3
- Issue [#362](https://github.com/microsoft/AL-Go/issues/362) Support for EnableTaskScheduler
- Issue [#360](https://github.com/microsoft/AL-Go/issues/360) Creating a release and deploying from a release branch
- Issue [#371](https://github.com/microsoft/AL-Go/issues/371) 'No previous release found' for builds on release branches
- Issue [#376](https://github.com/microsoft/AL-Go/issues/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 **`<environmentname>-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
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/AddExistingAppOrTestApp.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Add existing app or test app'
name: 'Add existing app or test app'

on:
workflow_dispatch:
Expand All @@ -21,7 +21,11 @@ permissions:

defaults:
run:
shell: PowerShell
shell: powershell

env:
ALGoOrgSettings: ${{ vars.ALGoOrgSettings }}
ALGoRepoSettings: ${{ vars.ALGoRepoSettings }}

jobs:
AddExistingAppOrTestApp:
Expand All @@ -32,21 +36,24 @@ jobs:

- name: Initialize the workflow
id: init
uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.2
uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.4
with:
shell: powershell
eventId: "DO0090"

- name: Add existing app
uses: microsoft/AL-Go-Actions/AddExistingApp@v2.2
uses: microsoft/AL-Go-Actions/AddExistingApp@v2.4
with:
shell: powershell
parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}
project: ${{ github.event.inputs.project }}
url: ${{ github.event.inputs.url }}
directCommit: ${{ github.event.inputs.directCommit }}

- name: Finalize the workflow
if: always()
uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.2
uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.4
with:
shell: powershell
eventId: "DO0090"
telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}
Loading

0 comments on commit e935df3

Please sign in to comment.