diff --git a/.github/RELEASENOTES.copy.md b/.github/RELEASENOTES.copy.md index 740f5c637a..6e08f96a50 100644 --- a/.github/RELEASENOTES.copy.md +++ b/.github/RELEASENOTES.copy.md @@ -1,7 +1,21 @@ -## v2.0 +## Preview 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. +### Issues +- Issue #233 AL-Go for GitHub causes GitHub to issue warnings +- Issue #244 Give error if AZURE_CREDENTIALS contains line breaks + +### Changes +- New workflow: PullRequestHandler to handle all Pull Requests and pass control safely to CI/CD +- Changes to yaml files, PowerShell scripts and codeowners files are not permitted from fork Pull Requests +- Test Results summary (and failed tests) are now displayed directly in the CI/CD workflow and in the Pull Request Check + +### Continuous Delivery +- Proof Of Concept Delivery to GitHub Packages and Nuget + +## v2.0 + ### Issues - Issue #143 Commit Message for **Increment Version Number** workflow - Issue #160 Create local DevEnv aith appDependencyProbingPaths diff --git a/.github/workflows/AddExistingAppOrTestApp.yaml b/.github/workflows/AddExistingAppOrTestApp.yaml index c71b30ff62..adcdc0569f 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: @@ -28,16 +28,16 @@ jobs: runs-on: [ self-hosted,1ES.Pool=ALAppExt ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0090" - name: Add existing app - uses: microsoft/AL-Go-Actions/AddExistingApp@v2.0 + uses: microsoft/AL-Go-Actions/AddExistingApp@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} @@ -46,7 +46,7 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0090" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CICD.yaml b/.github/workflows/CICD.yaml index a818958709..4a4d8bb0f8 100644 --- a/.github/workflows/CICD.yaml +++ b/.github/workflows/CICD.yaml @@ -1,21 +1,22 @@ -name: CI/CD +name: ' CI/CD' on: workflow_dispatch: + workflow_run: + workflows: ["Pull Request Handler"] + types: + - completed push: paths-ignore: - 'README.md' - '.github/**' branches: [ 'main', 'release/*', 'feature/*' ] - pull_request: - paths-ignore: - - 'README.md' - - '.github/**' - branches: [ 'main' ] permissions: contents: read actions: read + pull-requests: write + checks: write defaults: run: @@ -23,7 +24,10 @@ defaults: jobs: Initialization: + if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' runs-on: [ self-hosted,1ES.Pool=ALAppExt ] + env: + workflowDepth: 1 outputs: telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} settings: ${{ steps.ReadSettings.outputs.SettingsJson }} @@ -34,39 +38,136 @@ jobs: deliveryTargets: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetsJson }} deliveryTargetCount: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetCount }} githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} + checkRunId: ${{ steps.CreateCheckRun.outputs.checkRunId }} + projectDependenciesJson: ${{ steps.ReadSettings.outputs.ProjectDependenciesJson }} + buildOrderJson: ${{ steps.ReadSettings.outputs.BuildOrderJson }} + buildOrderDepth: ${{ steps.ReadSettings.outputs.BuildOrderDepth }} 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@v2 + 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 + } + } - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0091" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} getProjects: 'Y' getEnvironments: '*' - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 + uses: microsoft/AL-Go-Actions/ReadSecrets@v2.1 env: secrets: ${{ toJson(secrets) }} with: settingsJson: ${{ env.Settings }} - secrets: 'StorageContext,AppSourceContext' + secrets: 'GitHubPackagesContext,NuGetContext,StorageContext,AppSourceContext' - 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) { $deliveryTargets += @("AppSource") @@ -78,27 +179,66 @@ jobs: $deliveryTargets = $deliveryTargets | Select-Object -unique $deliveryTargetsJson = $deliveryTargets | ConvertTo-Json -Depth 99 -compress if ($deliveryTargets.Count -lt 2) { $deliveryTargetsJson = "[$($deliveryTargetsJson)]" } - Write-Host "::set-output name=DeliveryTargetsJson::$deliveryTargetsJson" - Write-Host "set-output name=DeliveryTargetsJson::$deliveryTargetsJson" - Write-Host "::set-output name=DeliveryTargetCount::$($deliveryTargets.Count)" - Write-Host "set-output name=DeliveryTargetCount::$($deliveryTargets.Count)" + Add-Content -Path $env:GITHUB_OUTPUT -Value "DeliveryTargetsJson=$deliveryTargetsJson" + Write-Host "DeliveryTargetsJson=$deliveryTargetsJson" + Add-Content -Path $env:GITHUB_OUTPUT -Value "DeliveryTargetCount=$($deliveryTargets.Count)" + 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: [ self-hosted,1ES.Pool=ALAppExt ] needs: [ Initialization ] + if: github.event_name != 'workflow_run' steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} get: TemplateUrl - name: Check for updates to AL-Go system files - uses: microsoft/AL-Go-Actions/CheckForUpdates@v2.0 + uses: microsoft/AL-Go-Actions/CheckForUpdates@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} templateUrl: ${{ env.TemplateUrl }} @@ -119,42 +259,150 @@ 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@v2 + uses: actions/checkout@v3 with: lfs: true - - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + - name: Download artifacts + uses: actions/download-artifact@v3 with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} + path: '${{ github.workspace }}\.dependencies' - - name: Read secrets (PR) - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 - if: github.event_name == 'pull_request' - env: - secrets: ${{ toJson(secrets) }} + - 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 + } + } + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId' + project: ${{ matrix.project }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 - if: github.event_name != 'pull_request' + uses: microsoft/AL-Go-Actions/ReadSecrets@v2.1 env: secrets: ${{ toJson(secrets) }} with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,StorageContext' + secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,StorageContext,GitHubPackagesContext' - name: Run pipeline - uses: microsoft/AL-Go-Actions/RunPipeline@v2.0 + id: RunPipeline + uses: microsoft/AL-Go-Actions/RunPipeline@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} + ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} settingsJson: ${{ env.Settings }} SecretsJson: ${{ env.RepoSecrets }} @@ -162,42 +410,43 @@ jobs: id: calculateArtifactNames 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)" - Write-Host "::set-output name=$name::$value" + Add-Content -Path $env:GITHUB_OUTPUT -Value "$name=$value" Add-Content -Path $env:GITHUB_ENV -Value "$name=$value" } - name: Publish artifacts - apps - uses: actions/upload-artifact@v2 - if: github.event_name != 'pull_request' && (github.ref_name == 'main' || startswith(github.ref_name, 'release/')) + uses: actions/upload-artifact@v3 + if: (github.event_name != 'workflow_run') && (github.ref_name == 'main' || startswith(github.ref_name, 'release/')) with: name: ${{ env.appsArtifactsName }} path: '${{ matrix.project }}/.buildartifacts/Apps/' if-no-files-found: ignore - name: Publish artifacts - dependencies - uses: actions/upload-artifact@v2 - if: github.event_name != 'pull_request' && (github.ref_name == 'main' || startswith(github.ref_name, 'release/')) + uses: actions/upload-artifact@v3 + if: (github.event_name != 'workflow_run') && (github.ref_name == 'main' || startswith(github.ref_name, 'release/')) with: name: ${{ env.dependenciesArtifactsName }} path: '${{ matrix.project }}/.buildartifacts/Dependencies/' if-no-files-found: ignore - name: Publish artifacts - test apps - uses: actions/upload-artifact@v2 - if: github.event_name != 'pull_request' && (github.ref_name == 'main' || startswith(github.ref_name, 'release/')) + uses: actions/upload-artifact@v3 + if: (github.event_name != 'workflow_run') && (github.ref_name == 'main' || startswith(github.ref_name, 'release/')) with: name: ${{ env.testAppsArtifactsName }} path: '${{ matrix.project }}/.buildartifacts/TestApps/' if-no-files-found: ignore - name: Publish artifacts - build output - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') with: name: ${{ env.buildOutputArtifactsName }} @@ -205,7 +454,7 @@ jobs: if-no-files-found: ignore - name: Publish artifacts - test results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') with: name: ${{ env.testResultsArtifactsName }} @@ -213,23 +462,53 @@ jobs: if-no-files-found: ignore - name: Publish artifacts - bcpt test results - uses: actions/upload-artifact@v2 + 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@v2.1 + with: + 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@v2.0 + uses: microsoft/AL-Go-Actions/PipelineCleanup@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} Deploy: needs: [ Initialization, Build ] - if: ${{ github.event_name != 'pull_request' && github.ref_name == 'main' && needs.Initialization.outputs.environmentCount > 0 }} + if: always() && needs.Build.result == 'Success' && github.event_name != 'workflow_run' && github.ref_name == 'main' && needs.Initialization.outputs.environmentCount > 0 strategy: ${{ fromJson(needs.Initialization.outputs.environments) }} runs-on: ${{ fromJson(matrix.os) }} name: Deploy to ${{ matrix.environment }} @@ -237,24 +516,25 @@ jobs: name: ${{ matrix.environment }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Download artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: - path: '${{ github.workspace }}\artifacts' + path: '${{ github.workspace }}\.artifacts' - name: EnvName id: envName run: | + $ErrorActionPreference = "STOP" $envName = '${{ matrix.environment }}'.split(' ')[0] - Write-Host "::set-output name=envName::$envName" + Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 + uses: microsoft/AL-Go-Actions/ReadSecrets@v2.1 env: secrets: ${{ toJson(secrets) }} with: @@ -264,6 +544,7 @@ jobs: - name: AuthContext id: authContext run: | + $ErrorActionPreference = "STOP" $envName = '${{ steps.envName.outputs.envName }}' $authContext = $null "$($envName)-AuthContext", "$($envName)_AuthContext", "AuthContext" | ForEach-Object { @@ -307,26 +588,26 @@ jobs: $projects = ($projects.Split(',') | Where-Object { $buildProjects -contains $_ }) -join ',' } - Write-Host "::set-output name=authContext::$authContext" - Write-Host "set-output name=authContext::$authContext" - Write-Host "::set-output name=environmentName::$environmentName" - Write-Host "set-output name=environmentName::$environmentName" - Write-Host "::set-output name=projects::$projects" - Write-Host "set-output name=projects::$projects" + 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" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects=$projects" + Write-Host "projects=$projects" - name: Deploy - uses: microsoft/AL-Go-Actions/Deploy@v2.0 + uses: microsoft/AL-Go-Actions/Deploy@v2.1 env: authContext: ${{ steps.authContext.outputs.authContext }} with: type: 'CD' projects: ${{ steps.authContext.outputs.projects }} environmentName: ${{ steps.authContext.outputs.environmentName }} - artifacts: '${{ github.workspace }}\artifacts' + artifacts: '${{ github.workspace }}\.artifacts' Deliver: needs: [ Initialization, Build ] - if: ${{ github.event_name != 'pull_request' && github.ref_name == 'main' && needs.Initialization.outputs.deliveryTargetCount > 0 }} + if: always() && needs.Build.result == 'Success' && github.event_name != 'workflow_run' && github.ref_name == 'main' && needs.Initialization.outputs.deliveryTargetCount > 0 strategy: matrix: deliveryTarget: ${{ fromJson(needs.Initialization.outputs.deliveryTargets) }} @@ -335,18 +616,18 @@ jobs: name: Deliver to ${{ matrix.deliveryTarget }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Download artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: - path: '${{ github.workspace }}\artifacts' + path: '${{ github.workspace }}\.artifacts' - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 + uses: microsoft/AL-Go-Actions/ReadSecrets@v2.1 env: secrets: ${{ toJson(secrets) }} with: @@ -356,32 +637,50 @@ jobs: - name: DeliveryContext id: deliveryContext run: | + $ErrorActionPreference = "STOP" $contextName = '${{ matrix.deliveryTarget }}Context' $deliveryContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($contextName))) - Write-Host "::set-output name=deliveryContext::$deliveryContext" - Write-Host "set-output name=deliveryContext::$deliveryContext" + Add-Content -Path $env:GITHUB_OUTPUT -Value "deliveryContext=$deliveryContext" + Write-Host "deliveryContext=$deliveryContext" - name: Deliver - uses: microsoft/AL-Go-Actions/Deliver@v2.0 + uses: microsoft/AL-Go-Actions/Deliver@v2.1 env: deliveryContext: ${{ steps.deliveryContext.outputs.deliveryContext }} with: type: 'CD' projects: ${{ needs.Initialization.outputs.projects }} deliveryTarget: ${{ matrix.deliveryTarget }} - artifacts: '${{ github.workspace }}\artifacts' + artifacts: '${{ github.workspace }}\.artifacts' + + UpdatePRcheck: + if: always() && github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' + runs-on: [ self-hosted,1ES.Pool=ALAppExt ] + 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 }}' + }); PostProcess: - if: always() + if: (!cancelled()) && (github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success') runs-on: [ self-hosted,1ES.Pool=ALAppExt ] needs: [ Initialization, Build, Deploy, Deliver ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0091" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateApp.yaml b/.github/workflows/CreateApp.yaml index 5b506371ba..4c14b7e144 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: @@ -38,22 +38,22 @@ jobs: runs-on: [ self-hosted,1ES.Pool=ALAppExt ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0092" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} get: type - name: Creating a new app - uses: microsoft/AL-Go-Actions/CreateApp@v2.0 + uses: microsoft/AL-Go-Actions/CreateApp@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} @@ -66,7 +66,7 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0092" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml b/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml index 335e82a075..a82fe27536 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: @@ -28,21 +28,21 @@ jobs: runs-on: [ self-hosted,1ES.Pool=ALAppExt ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0093" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 + uses: microsoft/AL-Go-Actions/ReadSecrets@v2.1 env: secrets: ${{ toJson(secrets) }} with: @@ -60,17 +60,18 @@ 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/v2.0/AL-Go-Helper.ps1', $ALGoHelperPath) + $webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v2.1/AL-Go-Helper.ps1', $ALGoHelperPath) . $ALGoHelperPath $BcContainerHelperPath = DownloadAndImportBcContainerHelper -baseFolder $ENV:GITHUB_WORKSPACE $authContext = New-BcAuthContext -includeDeviceLogin -deviceLoginTimeout ([TimeSpan]::FromSeconds(0)) MaskValueInLog -value $authContext.deviceCode - Add-Content -Path $env:GITHUB_ENV -Value "adminCenterApiCredentials={""deviceCode"":""$($authContext.deviceCode)""}" + $adminCenterApiCredentials = "{""deviceCode"":""$($authContext.deviceCode)""}" + Add-Content -Path $env:GITHUB_ENV -Value "adminCenterApiCredentials=$([Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($adminCenterApiCredentials)))" CleanupAfterBcContainerHelper -bcContainerHelperPath $bcContainerHelperPath } - name: Create Development Environment - uses: microsoft/AL-Go-Actions/CreateDevelopmentEnvironment@v2.0 + uses: microsoft/AL-Go-Actions/CreateDevelopmentEnvironment@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} environmentName: ${{ github.event.inputs.environmentName }} @@ -80,7 +81,7 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0093" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreatePerformanceTestApp.yaml b/.github/workflows/CreatePerformanceTestApp.yaml index 51c97343ef..40bf0852cd 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: @@ -44,16 +44,16 @@ jobs: runs-on: [ self-hosted,1ES.Pool=ALAppExt ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0102" - name: Creating a new test app - uses: microsoft/AL-Go-Actions/CreateApp@v2.0 + uses: microsoft/AL-Go-Actions/CreateApp@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} @@ -67,7 +67,7 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0102" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateRelease.yaml b/.github/workflows/CreateRelease.yaml index 7e1ac99ef5..3571cd2315 100644 --- a/.github/workflows/CreateRelease.yaml +++ b/.github/workflows/CreateRelease.yaml @@ -1,4 +1,4 @@ -name: Create release +name: ' Create release' on: workflow_dispatch: @@ -54,11 +54,11 @@ jobs: telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0094" @@ -70,18 +70,18 @@ jobs: upload_url: ${{ steps.createrelease.outputs.upload_url }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} get: TemplateUrl,RepoName getProjects: 'Y' - name: Check for updates to AL-Go system files - uses: microsoft/AL-Go-Actions/CheckForUpdates@v2.0 + uses: microsoft/AL-Go-Actions/CheckForUpdates@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} templateUrl: ${{ env.TemplateUrl }} @@ -89,6 +89,7 @@ jobs: - name: Analyze Artifacts id: analyzeartifacts run: | + $ErrorActionPreference = "STOP" $projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json $projects | out-host $include = @() @@ -124,12 +125,12 @@ jobs: } $artifacts = @{ "include" = $include } $artifactsJson = $artifacts | ConvertTo-Json -compress - Write-Host "::set-output name=artifacts::$artifactsJson" - Write-Host "set-output name=artifacts::$artifactsJson" + Add-Content -Path $env:GITHUB_OUTPUT -Value "artifacts=$artifactsJson" + Write-Host "artifacts=$artifactsJson" - name: Prepare release notes id: createreleasenotes - uses: microsoft/AL-Go-Actions/CreateReleaseNotes@v2.0 + uses: microsoft/AL-Go-Actions/CreateReleaseNotes@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} tag_name: ${{ github.event.inputs.tag }} @@ -154,24 +155,25 @@ jobs: fail-fast: true steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 + uses: microsoft/AL-Go-Actions/ReadSecrets@v2.1 env: secrets: ${{ toJson(secrets) }} with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'StorageContext' + secrets: 'NuGetContext,StorageContext' - name: Download artifact run: | + $ErrorActionPreference = "STOP" Write-Host "Downloading artifact ${{ matrix.name}}" $headers = @{ "Authorization" = "token ${{ github.token }}" @@ -189,26 +191,52 @@ jobs: asset_name: '${{ matrix.name }}.zip' asset_content_type: application/zip - - name: DeliveryContext - id: deliveryContext - if: ${{ env.StorageContext }} + - name: NuGetContext + id: nuGetContext + if: ${{ env.NuGetContext }} run: | - $contextName = 'StorageContext' - $deliveryContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($contextName))) - Write-Host "::set-output name=deliveryContext::$deliveryContext" - Write-Host "set-output name=deliveryContext::$deliveryContext" + $ErrorActionPreference = "STOP" + $nuGetContext = '' + if ('${{ matrix.atype }}' -eq 'Apps') { + $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 - uses: microsoft/AL-Go-Actions/Deliver@v2.0 + - name: Deliver to NuGet + uses: microsoft/AL-Go-Actions/Deliver@v2.1 + if: ${{ steps.nuGetContext.outputs.nuGetContext }} + env: + deliveryContext: ${{ steps.nuGetContext.outputs.nuGetContext }} + with: + type: 'Release' + projects: ${{ matrix.project }} + deliveryTarget: 'NuGet' + artifacts: ${{ github.event.inputs.appVersion }} + atypes: 'Apps,TestApps' + + - name: StorageContext + id: storageContext if: ${{ env.StorageContext }} + run: | + $ErrorActionPreference = "STOP" + $storageContext = '' + if ('${{ matrix.atype }}' -eq 'Apps') { + $storageContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('StorageContext'))) + } + Add-Content -Path $env:GITHUB_OUTPUT -Value "storageContext=$storageContext" + + - name: Deliver to Storage + uses: microsoft/AL-Go-Actions/Deliver@v2.1 + if: ${{ steps.storageContext.outputs.storageContext }} env: - deliveryContext: ${{ steps.deliveryContext.outputs.deliveryContext }} + deliveryContext: ${{ steps.storageContext.outputs.storageContext }} with: type: 'Release' projects: ${{ matrix.project }} deliveryTarget: 'Storage' artifacts: ${{ github.event.inputs.appVersion }} - atypes: ${{ matrix.atype }} + atypes: 'Apps,TestApps,Dependencies' CreateReleaseBranch: if: ${{ github.event.inputs.createReleaseBranch=='Y' }} @@ -216,10 +244,11 @@ jobs: needs: [ Initialization, CreateRelease, UploadArtifacts ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Create Release Branch run: | + $ErrorActionPreference = "STOP" git checkout -b release/${{ github.event.inputs.tag }} git config user.name ${{ github.actor}} git config user.email ${{ github.actor}}@users.noreply.github.com @@ -232,7 +261,7 @@ jobs: needs: [ Initialization, CreateRelease, UploadArtifacts ] steps: - name: Update Version Number - uses: microsoft/AL-Go-Actions/IncrementVersionNumber@v2.0 + uses: microsoft/AL-Go-Actions/IncrementVersionNumber@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} versionNumber: ${{ github.event.inputs.updateVersionNumber }} @@ -244,11 +273,11 @@ jobs: needs: [ Initialization, CreateRelease, UploadArtifacts, CreateReleaseBranch, UpdateVersionNumber ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0094" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateTestApp.yaml b/.github/workflows/CreateTestApp.yaml index ebc4612b49..b06a25829d 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: @@ -40,16 +40,16 @@ jobs: runs-on: [ self-hosted,1ES.Pool=ALAppExt ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0095" - name: Creating a new test app - uses: microsoft/AL-Go-Actions/CreateApp@v2.0 + uses: microsoft/AL-Go-Actions/CreateApp@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} @@ -62,7 +62,7 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0095" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/Current.yaml b/.github/workflows/Current.yaml index 098129e94b..b0047cc638 100644 --- a/.github/workflows/Current.yaml +++ b/.github/workflows/Current.yaml @@ -1,4 +1,4 @@ -name: Test Current +name: ' Test Current' on: workflow_dispatch: @@ -13,29 +13,72 @@ defaults: jobs: Initialization: runs-on: [ self-hosted,1ES.Pool=ALAppExt ] + 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 }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0101" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: 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-- + } + Build: needs: [ Initialization ] if: ${{ needs.Initialization.outputs.projectCount > 0 }} @@ -51,28 +94,34 @@ jobs: BuildOutputArtifactsName: ${{ steps.calculateArtifactNames.outputs.BuildOutputArtifactsName }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: '${{ github.workspace }}\.dependencies' - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} project: ${{ matrix.project }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 + uses: microsoft/AL-Go-Actions/ReadSecrets@v2.1 env: secrets: ${{ toJson(secrets) }} with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId' + secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,GitHubPackagesContext' - name: Run pipeline - uses: microsoft/AL-Go-Actions/RunPipeline@v2.0 + uses: microsoft/AL-Go-Actions/RunPipeline@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} + ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} settingsJson: ${{ env.Settings }} SecretsJson: ${{ env.RepoSecrets }} @@ -80,18 +129,19 @@ jobs: id: calculateArtifactNames 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'))" - Write-Host "::set-output name=$name::$value" + Add-Content -Path $env:GITHUB_OUTPUT -Value "$name=$value" Add-Content -Path $env:GITHUB_ENV -Value "$name=$value" } - name: Publish artifacts - build output - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') with: name: ${{ env.buildOutputArtifactsName }} @@ -99,7 +149,7 @@ jobs: if-no-files-found: ignore - name: Publish artifacts - test results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') with: name: ${{ env.testResultsArtifactsName }} @@ -107,16 +157,24 @@ jobs: if-no-files-found: ignore - name: Publish artifacts - bcpt test results - uses: actions/upload-artifact@v2 + 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@v2.1 + with: + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + Project: ${{ matrix.project }} + - name: Cleanup if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@v2.0 + uses: microsoft/AL-Go-Actions/PipelineCleanup@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -127,11 +185,11 @@ jobs: needs: [ Initialization, Build ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0101" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/IncrementVersionNumber.yaml b/.github/workflows/IncrementVersionNumber.yaml index d4475af28e..2933b83f3b 100644 --- a/.github/workflows/IncrementVersionNumber.yaml +++ b/.github/workflows/IncrementVersionNumber.yaml @@ -1,4 +1,4 @@ -name: Increment Version Number +name: ' Increment Version Number' on: workflow_dispatch: @@ -28,16 +28,16 @@ jobs: runs-on: [ self-hosted,1ES.Pool=ALAppExt ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0096" - name: Increment Version Number - uses: microsoft/AL-Go-Actions/IncrementVersionNumber@v2.0 + uses: microsoft/AL-Go-Actions/IncrementVersionNumber@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} @@ -46,7 +46,7 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0096" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/NextMajor.yaml b/.github/workflows/NextMajor.yaml index 1bbac6638a..6c8bd45442 100644 --- a/.github/workflows/NextMajor.yaml +++ b/.github/workflows/NextMajor.yaml @@ -1,4 +1,4 @@ -name: Test Next Major +name: ' Test Next Major' on: workflow_dispatch: @@ -13,29 +13,72 @@ defaults: jobs: Initialization: runs-on: [ self-hosted,1ES.Pool=ALAppExt ] + 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 }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0099" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: 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-- + } + Build: needs: [ Initialization ] if: ${{ needs.Initialization.outputs.projectCount > 0 }} @@ -51,28 +94,34 @@ jobs: BuildOutputArtifactsName: ${{ steps.calculateArtifactNames.outputs.BuildOutputArtifactsName }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: '${{ github.workspace }}\.dependencies' - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} project: ${{ matrix.project }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 + uses: microsoft/AL-Go-Actions/ReadSecrets@v2.1 env: secrets: ${{ toJson(secrets) }} with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId' + secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,GitHubPackagesContext' - name: Run pipeline - uses: microsoft/AL-Go-Actions/RunPipeline@v2.0 + uses: microsoft/AL-Go-Actions/RunPipeline@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} + ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} settingsJson: ${{ env.Settings }} SecretsJson: ${{ env.RepoSecrets }} @@ -80,18 +129,19 @@ jobs: id: calculateArtifactNames 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'))" - Write-Host "::set-output name=$name::$value" + Add-Content -Path $env:GITHUB_OUTPUT -Value "$name=$value" Add-Content -Path $env:GITHUB_ENV -Value "$name=$value" } - name: Publish artifacts - build output - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') with: name: ${{ env.buildOutputArtifactsName }} @@ -99,7 +149,7 @@ jobs: if-no-files-found: ignore - name: Publish artifacts - test results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') with: name: ${{ env.testResultsArtifactsName }} @@ -107,16 +157,24 @@ jobs: if-no-files-found: ignore - name: Publish artifacts - bcpt test results - uses: actions/upload-artifact@v2 + 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@v2.1 + with: + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + Project: ${{ matrix.project }} + - name: Cleanup if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@v2.0 + uses: microsoft/AL-Go-Actions/PipelineCleanup@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -127,11 +185,11 @@ jobs: needs: [ Initialization, Build ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0099" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/NextMinor.yaml b/.github/workflows/NextMinor.yaml index 1f5a3e8f86..6bb56f5042 100644 --- a/.github/workflows/NextMinor.yaml +++ b/.github/workflows/NextMinor.yaml @@ -1,4 +1,4 @@ -name: Test Next Minor +name: ' Test Next Minor' on: workflow_dispatch: @@ -13,29 +13,72 @@ defaults: jobs: Initialization: runs-on: [ self-hosted,1ES.Pool=ALAppExt ] + 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 }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0100" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: 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-- + } + Build: needs: [ Initialization ] if: ${{ needs.Initialization.outputs.projectCount > 0 }} @@ -51,28 +94,34 @@ jobs: BuildOutputArtifactsName: ${{ steps.calculateArtifactNames.outputs.BuildOutputArtifactsName }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: '${{ github.workspace }}\.dependencies' - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} project: ${{ matrix.project }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 + uses: microsoft/AL-Go-Actions/ReadSecrets@v2.1 env: secrets: ${{ toJson(secrets) }} with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId' + secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,GitHubPackagesContext' - name: Run pipeline - uses: microsoft/AL-Go-Actions/RunPipeline@v2.0 + uses: microsoft/AL-Go-Actions/RunPipeline@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} + ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} settingsJson: ${{ env.Settings }} SecretsJson: ${{ env.RepoSecrets }} @@ -80,18 +129,19 @@ jobs: id: calculateArtifactNames 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'))" - Write-Host "::set-output name=$name::$value" + Add-Content -Path $env:GITHUB_OUTPUT -Value "$name=$value" Add-Content -Path $env:GITHUB_ENV -Value "$name=$value" } - name: Publish artifacts - build output - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') with: name: ${{ env.buildOutputArtifactsName }} @@ -99,7 +149,7 @@ jobs: if-no-files-found: ignore - name: Publish artifacts - test results - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') with: name: ${{ env.testResultsArtifactsName }} @@ -107,16 +157,24 @@ jobs: if-no-files-found: ignore - name: Publish artifacts - bcpt test results - uses: actions/upload-artifact@v2 + 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@v2.1 + with: + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + Project: ${{ matrix.project }} + - name: Cleanup if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@v2.0 + uses: microsoft/AL-Go-Actions/PipelineCleanup@v2.1 with: parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -127,11 +185,11 @@ jobs: needs: [ Initialization, Build ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0100" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/PublishToEnvironment.yaml b/.github/workflows/PublishToEnvironment.yaml index 386b9ee6a7..07627e26d7 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: @@ -29,17 +29,17 @@ jobs: environmentCount: ${{ steps.ReadSettings.outputs.EnvironmentCount }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0097" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} getEnvironments: ${{ github.event.inputs.environmentName }} @@ -55,19 +55,20 @@ jobs: name: ${{ matrix.environment }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: EnvName id: envName run: | + $ErrorActionPreference = "STOP" $envName = '${{ matrix.environment }}'.split(' ')[0] - Write-Host "::set-output name=envName::$envName" + Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 + uses: microsoft/AL-Go-Actions/ReadSecrets@v2.1 env: secrets: ${{ toJson(secrets) }} with: @@ -77,6 +78,7 @@ jobs: - name: AuthContext id: authContext run: | + $ErrorActionPreference = "STOP" $envName = '${{ steps.envName.outputs.envName }}' $authContext = $null "$($envName)-AuthContext", "$($envName)_AuthContext", "AuthContext" | ForEach-Object { @@ -116,15 +118,15 @@ jobs: $projects = '*' } - Write-Host "::set-output name=authContext::$authContext" - Write-Host "set-output name=authContext::$authContext" - Write-Host "::set-output name=environmentName::$environmentName" - Write-Host "set-output name=environmentName::$environmentName" - Write-Host "::set-output name=projects::$projects" - Write-Host "set-output name=projects::$projects" + 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" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects=$projects" + Write-Host "projects=$projects" - name: Deploy - uses: microsoft/AL-Go-Actions/Deploy@v2.0 + uses: microsoft/AL-Go-Actions/Deploy@v2.1 env: authContext: ${{ steps.authContext.outputs.authContext }} with: @@ -140,11 +142,11 @@ jobs: needs: [ Initialization, Deploy ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0097" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/PullRequestHandler.yaml b/.github/workflows/PullRequestHandler.yaml new file mode 100644 index 0000000000..29ada0b52a --- /dev/null +++ b/.github/workflows/PullRequestHandler.yaml @@ -0,0 +1,84 @@ +name: 'Pull Request Handler' + +on: + pull_request: + paths-ignore: + - '*.md' + - '*.ps1' + - '*.yaml' + branches: [ 'main' ] + +defaults: + run: + shell: PowerShell + +permissions: + contents: read + actions: read + pull-requests: read + +jobs: + PullRequestHandler: + runs-on: [ self-hosted,1ES.Pool=ALAppExt ] + 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 + uses: actions/upload-artifact@v3 + with: + name: Pull_Request_Files + path: '${{ steps.ChangedFiles.outputs.prfolder }}/' diff --git a/.github/workflows/UpdateGitHubGoSystemFiles.yaml b/.github/workflows/UpdateGitHubGoSystemFiles.yaml index c86dc6cdb7..d628ab8ad8 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@v2.0) + description: Template Repository URL (current is https://github.com/microsoft/AL-Go-PTE@main) required: false default: '' directCommit: @@ -24,22 +24,22 @@ jobs: runs-on: [ windows-latest ] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v2.1 with: eventId: "DO0098" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@v2.0 + uses: microsoft/AL-Go-Actions/ReadSettings@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} get: KeyVaultName,GhTokenWorkflowSecretName,TemplateUrl - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@v2.0 + uses: microsoft/AL-Go-Actions/ReadSecrets@v2.1 env: secrets: ${{ toJson(secrets) }} with: @@ -51,6 +51,7 @@ jobs: env: templateUrl: ${{ github.event.inputs.templateUrl }} run: | + $ErrorActionPreference = "STOP" $templateUrl = $ENV:templateUrl if ($templateUrl) { Write-Host "Using Template Url: $templateUrl" @@ -62,6 +63,7 @@ jobs: directCommit: ${{ github.event.inputs.directCommit }} eventName: ${{ github.event_name }} run: | + $ErrorActionPreference = "STOP" $directCommit = $ENV:directCommit Write-Host $ENV:eventName if ($ENV:eventName -eq 'schedule') { @@ -71,7 +73,7 @@ jobs: Add-Content -Path $env:GITHUB_ENV -Value "DirectCommit=$directCommit" - name: Update AL-Go system files - uses: microsoft/AL-Go-Actions/CheckForUpdates@v2.0 + uses: microsoft/AL-Go-Actions/CheckForUpdates@v2.1 with: parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} token: ${{ env.ghTokenWorkflow }} @@ -81,7 +83,7 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.0 + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v2.1 with: eventId: "DO0098" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/Modules/.AL-Go/cloudDevEnv.ps1 b/Modules/.AL-Go/cloudDevEnv.ps1 index 75bad7a996..7d56b28785 100644 --- a/Modules/.AL-Go/cloudDevEnv.ps1 +++ b/Modules/.AL-Go/cloudDevEnv.ps1 @@ -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 @@ -43,7 +43,7 @@ $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/v2.0/AL-Go-Helper.ps1', $ALGoHelperPath) +$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v2.1/AL-Go-Helper.ps1', $ALGoHelperPath) . $ALGoHelperPath -local $baseFolder = Join-Path $PSScriptRoot ".." -Resolve @@ -103,4 +103,4 @@ finally { if ($fromVSCode) { Read-Host "Press ENTER to close this window" } -} \ No newline at end of file +} diff --git a/Modules/.AL-Go/localDevEnv.ps1 b/Modules/.AL-Go/localDevEnv.ps1 index 6a9bf9b63f..f0471d43d7 100644 --- a/Modules/.AL-Go/localDevEnv.ps1 +++ b/Modules/.AL-Go/localDevEnv.ps1 @@ -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 @@ -50,10 +50,10 @@ $webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumen $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.0/Github-Helper.psm1', $GitHubHelperPath) +$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v2.1/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.0/AL-Go-Helper.ps1', $ALGoHelperPath) +$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v2.1/AL-Go-Helper.ps1', $ALGoHelperPath) Import-Module $GitHubHelperPath . $ALGoHelperPath -local @@ -164,4 +164,4 @@ finally { if ($fromVSCode) { Read-Host "Press ENTER to close this window" } -} \ No newline at end of file +}