Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Updated AL-Go System Files #22488

Merged
merged 1 commit into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/RELEASENOTES.copy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

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](https://github.com/microsoft/AL-Go/issues/391) Create release action - CreateReleaseBranch error

### 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
Expand Down
74 changes: 19 additions & 55 deletions .github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,16 @@ jobs:
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 }}
buildModes: ${{ steps.ReadSettings.outputs.BuildModes }}
projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}
projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }}
buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -60,8 +57,14 @@ jobs:
with:
shell: powershell
parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}
getProjects: 'Y'
getEnvironments: '*'

- name: Determine Projects To Build
id: determineProjectsToBuild
uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@preview
with:
shell: powershell
maxBuildDepth: ${{ env.workflowDepth }}

- name: Determine Delivery Target Secrets
id: DetermineDeliveryTargetSecrets
Expand Down Expand Up @@ -94,7 +97,7 @@ jobs:
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.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json) | where-Object { $_ } | ForEach-Object {
('${{ 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"
Expand Down Expand Up @@ -144,45 +147,6 @@ 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"
Set-StrictMode -version 2.0
$projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json
$buildOrder = '${{ steps.ReadSettings.outputs.BuildOrderJson }}' | ConvertFrom-Json
$depth = ${{ steps.ReadSettings.outputs.BuildOrderDepth }}
$workflowDepth = ${{ env.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 ]
Expand All @@ -206,15 +170,14 @@ jobs:

Build:
needs: [ Initialization ]
if: (!failure()) && (!cancelled()) && 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) }}
buildMode: ${{ fromJson(needs.Initialization.outputs.buildModes) }}
include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }}
fail-fast: false
name: Build ${{ matrix.project }} - ${{ matrix.buildMode }}
outputs:
Expand Down Expand Up @@ -260,13 +223,14 @@ jobs:
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: calculateArtifactsNames
uses: microsoft/AL-Go-Actions/CalculateArtifactNames@preview
if: success() || failure()
with:
Expand All @@ -280,7 +244,7 @@ jobs:
if: env.workflowDepth > 1
uses: actions/upload-artifact@v3
with:
name: 'thisbuild-${{ matrix.project }}-${{ env.BuildMode }}Apps'
name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }}
path: '${{ matrix.project }}/.buildartifacts/Apps/'
if-no-files-found: ignore
retention-days: 1
Expand All @@ -289,7 +253,7 @@ jobs:
if: env.workflowDepth > 1
uses: actions/upload-artifact@v3
with:
name: 'thisbuild-${{ matrix.project }}-${{ env.BuildMode }}TestApps'
name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }}
path: '${{ matrix.project }}/.buildartifacts/TestApps/'
if-no-files-found: ignore
retention-days: 1
Expand Down
90 changes: 35 additions & 55 deletions .github/workflows/PullRequestHandler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,11 @@ jobs:
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 }}
githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }}
projectDependenciesJson: ${{ steps.ReadSettings.outputs.ProjectDependenciesJson }}
buildOrderJson: ${{ steps.ReadSettings.outputs.BuildOrderJson }}
buildOrderDepth: ${{ steps.ReadSettings.outputs.BuildOrderDepth }}
buildModes: ${{ steps.ReadSettings.outputs.BuildModes }}
projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}
projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }}
buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -74,59 +71,25 @@ jobs:
with:
shell: powershell
parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }}
getProjects: 'Y'
getEnvironments: '*'

- name: Determine Build Order
if: env.workflowDepth > 1
id: BuildOrder
run: |
$ErrorActionPreference = "STOP"
Set-StrictMode -version 2.0
$projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json
$buildOrder = '${{ steps.ReadSettings.outputs.BuildOrderJson }}' | ConvertFrom-Json
$depth = ${{ steps.ReadSettings.outputs.BuildOrderDepth }}
$workflowDepth = ${{ env.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@preview
with:
shell: powershell
maxBuildDepth: ${{ env.workflowDepth }}

Build:
needs: [ Initialization ]
if: (!failure()) && (!cancelled()) && 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) }}
buildMode: ${{ fromJson(needs.Initialization.outputs.buildModes) }}
include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }}
fail-fast: false
name: Build ${{ matrix.project }} - ${{ matrix.buildMode }}
outputs:
Expand Down Expand Up @@ -162,7 +125,7 @@ jobs:
shell: ${{ needs.Initialization.outputs.githubRunnerShell }}
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }}
settingsJson: ${{ env.Settings }}
secrets: 'licenseFileUrl,insiderSasToken,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId'
secrets: 'licenseFileUrl,insiderSasToken,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext'

- name: Run pipeline
id: RunPipeline
Expand All @@ -172,13 +135,14 @@ jobs:
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: calculateArtifactsNames
uses: microsoft/AL-Go-Actions/CalculateArtifactNames@preview
if: success() || failure()
with:
Expand All @@ -192,7 +156,7 @@ jobs:
if: env.workflowDepth > 1
uses: actions/upload-artifact@v3
with:
name: 'thisbuild-${{ matrix.project }}-${{ env.BuildMode }}Apps'
name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }}
path: '${{ matrix.project }}/.buildartifacts/Apps/'
if-no-files-found: ignore
retention-days: 1
Expand All @@ -201,11 +165,27 @@ jobs:
if: env.workflowDepth > 1
uses: actions/upload-artifact@v3
with:
name: 'thisbuild-${{ matrix.project }}-${{ env.BuildMode }}TestApps'
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)) != '')
Expand Down