Skip to content

Commit

Permalink
Merge pull request #341 from freddydk/issue328
Browse files Browse the repository at this point in the history
Issue #328
  • Loading branch information
freddydk authored Jan 11, 2023
2 parents 1e636f9 + 3f64187 commit f4f2edb
Show file tree
Hide file tree
Showing 21 changed files with 131 additions and 92 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/E2E.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,14 @@ jobs:
Scenario:
runs-on: [ ubuntu-latest ]
needs: [ Check, SetupRepositories, Analyze ]
if: github.event.inputs.runScenarios == 'Y'
strategy: ${{ fromJson(needs.Analyze.outputs.scenarios) }}
steps:
- uses: actions/checkout@v3
if: github.event.inputs.runScenarios == 'Y'
with:
ref: ${{ github.event.inputs.ref }}

- name: Calculate parameters
if: github.event.inputs.runScenarios == 'Y'
id: calculateParams
run: |
$errorActionPreference = "STOP"
Expand All @@ -188,7 +187,6 @@ jobs:
Write-Host "Repo URL: https://github.com/${{ needs.Check.outputs.githubowner }}/$repoName"
- name: Run test
if: github.event.inputs.runScenarios == 'Y'
run: |
try {
. (Join-Path "." "e2eTests/scenarios/${{ matrix.scenario }}/runtest.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -token '${{ Secrets.E2EPAT }}' -InsiderSasToken '${{ Secrets.InsiderSasToken }}' -pteTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.perTenantExtensionRepo }}' -appSourceTemplate '${{ needs.Check.outputs.githubowner }}/${{ needs.SetupRepositories.outputs.appSourceAppRepo }}' -adminCenterApiToken '${{ Secrets.adminCenterApiCredentials }}' -licenseFileUrl '${{ Secrets.licenseFileUrl }}'
Expand All @@ -203,15 +201,14 @@ jobs:
TestAlGo:
runs-on: [ ubuntu-latest ]
needs: [ Check, SetupRepositories, Analyze ]
if: github.event.inputs.runTestMatrix == 'Y'
strategy: ${{ fromJson(needs.Analyze.outputs.testruns) }}
steps:
- uses: actions/checkout@v3
if: github.event.inputs.runTestMatrix == 'Y'
with:
ref: ${{ github.event.inputs.ref }}

- name: Calculate parameters
if: github.event.inputs.runTestMatrix == 'Y'
id: calculateParams
run: |
$errorActionPreference = "STOP"
Expand All @@ -236,7 +233,6 @@ jobs:
Write-Host "Repo URL: https://github.com/${{ needs.Check.outputs.githubowner }}/$repoName"
- name: Run tests
if: github.event.inputs.runTestMatrix == 'Y'
run: |
try {
. (Join-Path "." "e2eTests/Test-AL-Go.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -token '${{ Secrets.E2EPAT }}' -InsiderSasToken '${{ Secrets.InsiderSasToken }}' -template ${{ steps.calculateParams.outputs.template }} -adminCenterApiToken ${{ steps.calculateParams.outputs.adminCenterApiCredentials }} -licenseFileUrl ${{ steps.calculateParams.outputs.licenseFileUrl }} -multiProject:('${{ matrix.style }}' -eq 'multiProject') -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -linux:('${{ matrix.os }}' -eq 'linux') -private:('${{ matrix.visibility }}' -eq 'private')
Expand All @@ -251,15 +247,14 @@ jobs:
TestAlGoUpgrade:
runs-on: [ ubuntu-latest ]
needs: [ Check, SetupRepositories, Analyze ]
if: github.event.inputs.runUpgradeTests == 'Y'
strategy: ${{ fromJson(needs.Analyze.outputs.releases) }}
steps:
- uses: actions/checkout@v3
if: github.event.inputs.runUpgradeTests == 'Y'
with:
ref: ${{ github.event.inputs.ref }}

- name: Calculate parameters
if: github.event.inputs.runUpgradeTests == 'Y'
id: calculateParams
run: |
$errorActionPreference = "STOP"
Expand All @@ -282,7 +277,6 @@ jobs:
Write-Host "Repo URL: https://github.com/${{ needs.Check.outputs.githubowner }}/$repoName"
- name: Run tests
if: github.event.inputs.runUpgradeTests == 'Y'
run: |
try {
. (Join-Path "." "e2eTests/Test-AL-Go-Upgrade.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -repoName ${{ steps.calculateParams.outputs.repoName }} -token '${{ Secrets.E2EPAT }}' -template ${{ steps.calculateParams.outputs.template }} -licenseFileUrl ${{ steps.calculateParams.outputs.licenseFileUrl }} -appSource:('${{ matrix.type }}' -eq 'appSourceApp') -release '${{ matrix.release }}' -contentPath ${{ steps.calculateParams.outputs.contentPath }}
Expand All @@ -297,7 +291,7 @@ jobs:
RemoveRepositories:
runs-on: [ ubuntu-latest ]
needs: [ Check, SetupRepositories, TestAlGo, TestAlGoUpgrade, Scenario ]
if: always() && (${{ needs.SetupRepositories.result == 'Success' }})
if: always() && (!Cancelled()) && (needs.SetupRepositories.result == 'Success') && (needs.TestAlGo.result == 'Success' || needs.TestAlGo.result == 'Skipped') && (needs.TestAlGoUpgrade.result == 'Success' || needs.TestAlGoUpgrade.result == 'Skipped') && (needs.Scenario.result == 'Success' || needs.Scenario.result == 'Skipped')
steps:
- uses: actions/checkout@v3
with:
Expand Down
7 changes: 5 additions & 2 deletions Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,14 @@ function AnalyzeRepo {
$settings.Add('enableAppSourceCop', $true)
}
if ($settings.enableAppSourceCop -and (-not ($settings.appSourceCopMandatoryAffixes))) {
throw "For AppSource Apps with AppSourceCop enabled, you need to specify AppSourceCopMandatoryAffixes in $ALGoSettingsFile"
# Do not throw an error if we only read the Repo Settings file
if (Test-Path (Join-Path $baseFolder $ALGoSettingsFile)) {
throw "For AppSource Apps with AppSourceCop enabled, you need to specify AppSourceCopMandatoryAffixes in $ALGoSettingsFile"
}
}
}
else {
throw "The type, specified in $ALGoSettingsFile, must be either 'Per Tenant Extension' or 'AppSource App'. It is '$($settings.type)'."
throw "The type, specified in $RepoSettingsFile, must be either 'Per Tenant Extension' or 'AppSource App'. It is '$($settings.type)'."
}

if (-not (@($settings.appFolders)+@($settings.testFolders)+@($settings.bcptTestFolders))) {
Expand Down
109 changes: 57 additions & 52 deletions Actions/Deliver/Deliver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ try {
$projectList = $settings.projects | Where-Object { $_ -like $projects }
}
else {
Get-ChildItem -Path $ENV:GITHUB_WORKSPACE -Recurse -Depth 2 | Where-Object { $_.PSIsContainer } | ForEach-Object { Write-Host $_.FullName }
$projectList = @(Get-ChildItem -Path $ENV:GITHUB_WORKSPACE -Recurse -Depth 2 | Where-Object { $_.PSIsContainer -and (Test-Path (Join-Path $_.FullName ".AL-Go/settings.json") -PathType Leaf) } | ForEach-Object { $_.FullName.Substring("$ENV:GITHUB_WORKSPACE".length+1) })
if (Test-Path (Join-Path $ENV:GITHUB_WORKSPACE ".AL-Go") -PathType Container) {
$projectList += @(".")
Expand Down Expand Up @@ -98,12 +97,14 @@ try {

$projectList | ForEach-Object {
$thisProject = $_
# $project should be the project part of the artifact name generated from the build
if ($thisProject -and ($thisProject -ne '.')) {
$project = $thisProject
$project = $thisProject.Replace('\','_').Replace('/','_')
}
else {
$project = $env:repoName
}
# projectName is the project name stripped for special characters
$projectName = $project -replace "[^a-z0-9]", "-"
Write-Host "Project '$project'"
$baseFolder = Join-Path $ENV:GITHUB_WORKSPACE ".artifacts"
Expand Down Expand Up @@ -199,7 +200,7 @@ try {
#Calculate the folders per artifact type
'Apps', 'TestApps', 'Dependencies' | ForEach-Object {
$artifactType = $_
$singleArtifactFilter = "*-$refname-$artifactType-*.*.*.*";
$singleArtifactFilter = "$project-$refname-$artifactType-*.*.*.*";

# Get the folder holding the artifacts from the standard build
$artifactFolder = @(Get-ChildItem -Path (Join-Path $baseFolder $singleArtifactFilter) -Directory)
Expand All @@ -221,7 +222,7 @@ try {
}

# Get the folders holding the artifacts from all build modes
$multipleArtifactFilter = "*-$refname-*$artifactType-*.*.*.*";
$multipleArtifactFilter = "$project-$refname-*$artifactType-*.*.*.*";
$artifactFolders = @(Get-ChildItem -Path (Join-Path $baseFolder $multipleArtifactFilter) -Directory)
if ($artifactFolders.Count -gt 0) {
$parameters[$artifactType.ToLowerInvariant() + "Folders"] = $artifactFolders.FullName
Expand All @@ -234,7 +235,7 @@ try {
elseif ($deliveryTarget -eq "GitHubPackages") {
$githubPackagesCredential = $githubPackagesContext | ConvertFrom-Json
'Apps' | ForEach-Object {
$folder = @(Get-ChildItem -Path (Join-Path $baseFolder "*-$refname-$($_)-*.*.*.*") | Where-Object { $_.PSIsContainer })
$folder = @(Get-ChildItem -Path (Join-Path $baseFolder "$project-$refname-$($_)-*.*.*.*") | Where-Object { $_.PSIsContainer })
if ($folder.Count -gt 1) {
$folder | Out-Host
throw "Internal error - multiple $_ folders located"
Expand Down Expand Up @@ -264,20 +265,20 @@ try {
catch {
throw "NuGetContext secret is malformed. Needs to be formatted as Json, containing serverUrl and token as a minimum."
}
$appsfolder = @(Get-ChildItem -Path (Join-Path $baseFolder "*-$refname-Apps-*.*.*.*") | Where-Object { $_.PSIsContainer })
$appsfolder = @(Get-ChildItem -Path (Join-Path $baseFolder "$project-$refname-Apps-*.*.*.*") | Where-Object { $_.PSIsContainer })
if ($appsFolder.Count -eq 0) {
throw "Internal error - unable to locate apps folder"
}
elseif ($appsFolder.Count -gt 1) {
$appsFolder | Out-Host
throw "Internal error - multiple apps folders located"
}
$testAppsFolder = @(Get-ChildItem -Path (Join-Path $baseFolder "*-$refname-TestApps-*.*.*.*") | Where-Object { $_.PSIsContainer })
$testAppsFolder = @(Get-ChildItem -Path (Join-Path $baseFolder "$project-$refname-TestApps-*.*.*.*") | Where-Object { $_.PSIsContainer })
if ($testAppsFolder.Count -gt 1) {
$testAppsFolder | Out-Host
throw "Internal error - multiple testApps folders located"
}
$dependenciesFolder = @(Get-ChildItem -Path (Join-Path $baseFolder "*-$refname-Dependencies-*.*.*.*") | Where-Object { $_.PSIsContainer })
$dependenciesFolder = @(Get-ChildItem -Path (Join-Path $baseFolder "$project-$refname-Dependencies-*.*.*.*") | Where-Object { $_.PSIsContainer })
if ($dependenciesFolder.Count -gt 1) {
$dependenciesFolder | Out-Host
throw "Internal error - multiple dependencies folders located"
Expand Down Expand Up @@ -394,55 +395,59 @@ try {
}
}
elseif ($deliveryTarget -eq "AppSource") {
EnsureAzStorageModule
$appSourceContextHt = $appSourceContext | ConvertFrom-Json | ConvertTo-HashTable
$authContext = New-BcAuthContext @appSourceContextHt

$projectSettings = AnalyzeRepo -settings $settings -baseFolder $ENV:GITHUB_WORKSPACE -project $thisProject -doNotCheckArtifactSetting -doNotIssueWarnings
if ($projectSettings.ContainsKey("AppSourceMainAppFolder")) {
$AppSourceMainAppFolder = $projectSettings.AppSourceMainAppFolder
}
else {
try {
$AppSourceMainAppFolder = $projectSettings.appFolders[0]
# if type is Release, we only get here with the projects that needs to be delivered to AppSource
# if type is CD, we get here for all projects, but should only deliver to AppSource if AppSourceContinuousDelivery is set to true
if ($type -eq 'Release' -or ($projectSettings.ContainsKey('AppSourceContinuousDelivery') -and $projectSettings.AppSourceContinuousDelivery)) {
EnsureAzStorageModule
$appSourceContextHt = $appSourceContext | ConvertFrom-Json | ConvertTo-HashTable
$authContext = New-BcAuthContext @appSourceContextHt

if ($projectSettings.ContainsKey("AppSourceMainAppFolder")) {
$AppSourceMainAppFolder = $projectSettings.AppSourceMainAppFolder
}
else {
try {
$AppSourceMainAppFolder = $projectSettings.appFolders[0]
}
catch {
throw "Unable to determine main App folder"
}
}
catch {
throw "Unable to determine main App folder"
if (-not $projectSettings.ContainsKey('AppSourceProductId')) {
throw "AppSourceProductId needs to be specified in $thisProject/.AL-Go/settings.json in order to deliver to AppSource"
}
}
if (-not $projectSettings.ContainsKey('AppSourceProductId')) {
throw "AppSourceProductId needs to be specified in $thisProject/.AL-Go/settings.json in order to deliver to AppSource"
}
Write-Host "AppSource MainAppFolder $AppSourceMainAppFolder"
Write-Host "AppSource MainAppFolder $AppSourceMainAppFolder"

$mainAppJson = Get-Content -Path (Join-Path $ENV:GITHUB_WORKSPACE "$thisProject/$AppSourceMainAppFolder/app.json") | ConvertFrom-Json
$mainAppVersion = [Version]$mainAppJson.Version
$mainAppFileName = ("$($mainAppJson.Publisher)_$($mainAppJson.Name)_".Split([System.IO.Path]::GetInvalidFileNameChars()) -join '') + "*.*.*.*.app"
$artfolder = @(Get-ChildItem -Path (Join-Path $baseFolder "*-$refname-Apps-*.*.*.*") | Where-Object { $_.PSIsContainer })
if ($artFolder.Count -eq 0) {
throw "Internal error - unable to locate apps"
}
if ($artFolder.Count -gt 1) {
$artFolder | Out-Host
throw "Internal error - multiple apps located"
}
$artfolder = $artfolder[0].FullName
$appFile = Get-ChildItem -path $artFolder | Where-Object { $_.name -like $mainAppFileName } | ForEach-Object { $_.FullName }
$libraryAppFiles = @(Get-ChildItem -path $artFolder | Where-Object { $_.name -notlike $mainAppFileName } | ForEach-Object { $_.FullName })
Write-Host "Main App File:"
Write-Host "- $([System.IO.Path]::GetFileName($appFile))"
Write-Host "Library App Files:"
if ($libraryAppFiles.Count -eq 0) {
Write-Host "- None"
}
else {
$libraryAppFiles | ForEach-Object { Write-Host "- $([System.IO.Path]::GetFileName($_))" }
}
if (-not $appFile) {
throw "Unable to locate main app file ($mainAppFileName doesn't exist)"
$mainAppJson = Get-Content -Path (Join-Path $ENV:GITHUB_WORKSPACE "$thisProject/$AppSourceMainAppFolder/app.json") | ConvertFrom-Json
$mainAppVersion = [Version]$mainAppJson.Version
$mainAppFileName = ("$($mainAppJson.Publisher)_$($mainAppJson.Name)_".Split([System.IO.Path]::GetInvalidFileNameChars()) -join '') + "*.*.*.*.app"
$artfolder = @(Get-ChildItem -Path (Join-Path $baseFolder "$project-$refname-Apps-*.*.*.*") | Where-Object { $_.PSIsContainer })
if ($artFolder.Count -eq 0) {
throw "Internal error - unable to locate apps"
}
if ($artFolder.Count -gt 1) {
$artFolder | Out-Host
throw "Internal error - multiple apps located"
}
$artfolder = $artfolder[0].FullName
$appFile = Get-ChildItem -path $artFolder | Where-Object { $_.name -like $mainAppFileName } | ForEach-Object { $_.FullName }
$libraryAppFiles = @(Get-ChildItem -path $artFolder | Where-Object { $_.name -notlike $mainAppFileName } | ForEach-Object { $_.FullName })
Write-Host "Main App File:"
Write-Host "- $([System.IO.Path]::GetFileName($appFile))"
Write-Host "Library App Files:"
if ($libraryAppFiles.Count -eq 0) {
Write-Host "- None"
}
else {
$libraryAppFiles | ForEach-Object { Write-Host "- $([System.IO.Path]::GetFileName($_))" }
}
if (-not $appFile) {
throw "Unable to locate main app file ($mainAppFileName doesn't exist)"
}
Write-Host "Submitting to AppSource"
New-AppSourceSubmission -authContext $authContext -productId $projectSettings.AppSourceProductId -appFile $appFile -libraryAppFiles $libraryAppFiles -doNotWait -autoPromote:$goLive -Force
}
Write-Host "Submitting to AppSource"
New-AppSourceSubmission -authContext $authContext -productId $projectSettings.AppSourceProductId -appFile $appFile -libraryAppFiles $libraryAppFiles -doNotWait -autoPromote:$goLive -Force
}
else {
throw "Internal error, no handler for $deliveryTarget"
Expand Down
2 changes: 1 addition & 1 deletion Actions/Deploy/Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ try {
if ($artifacts -like "$($ENV:GITHUB_WORKSPACE)*") {
if (Test-Path $artifacts -PathType Container) {
$projects.Split(',') | ForEach-Object {
$project = $_.Replace('\','_')
$project = $_.Replace('\','_').Replace('/','_')
$refname = "$ENV:GITHUB_REF_NAME".Replace('/','_')
Write-Host "project '$project'"
$apps += @((Get-ChildItem -Path $artifacts -Filter "$project-$refname-Apps-*.*.*.*") | ForEach-Object { $_.FullName })
Expand Down
4 changes: 2 additions & 2 deletions Actions/Github-Helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ function DownloadRelease {
"Authorization" = "token $token"
}
$projects.Split(',') | ForEach-Object {
$project = $_.Replace('\','_')
$project = $_.Replace('\','_').Replace('/','_')
Write-Host "project '$project'"

$release.assets | Where-Object { $_.name -like "$project-*-$mask-*.zip" -or $_.name -like "$project-$mask-*.zip" } | ForEach-Object {
Expand Down Expand Up @@ -601,7 +601,7 @@ function GetArtifacts {
$result = @()
$allArtifactsFound = $true
$projects.Split(',') | ForEach-Object {
$project = $_.Replace('\','_')
$project = $_.Replace('\','_').Replace('/','_')
Write-Host "project '$project'"
$projectArtifact = $allArtifacts | Where-Object { $_.name -like "$project-$branch-$mask-$version" } | Select-Object -First 1
if ($projectArtifact) {
Expand Down
2 changes: 1 addition & 1 deletion Actions/ReadSettings/ReadSettings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ try {
Write-Host "BuildOrderDepth=$($buildOrder.Count)"
}
}
if (Test-Path ".AL-Go" -PathType Container) {
if (Test-Path (Join-Path ".AL-Go" "settings.json") -PathType Leaf) {
$buildProjects += @(".")
}
if ($buildProjects.Count -eq 1) {
Expand Down
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Note that when using the preview version of AL-Go for GitHub, you need to Update
- 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

Expand Down
Loading

0 comments on commit f4f2edb

Please sign in to comment.