Skip to content

Commit

Permalink
Support include in appDependencyProbingPaths
Browse files Browse the repository at this point in the history
  • Loading branch information
freddydk committed Aug 8, 2023
1 parent a2415a8 commit 92f3393
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ function AnalyzeRepo {
$depSettings = AnalyzeRepo -settings $depSettings -token $token -baseFolder $baseFolder -project $depProject -includeOnlyAppIds @($dependencyIds + $includeOnlyAppIds + $dependency.alwaysIncludeApps) -doNotIssueWarnings -doNotCheckArtifactSetting -server_url $server_url -repository $repository

Set-Location $projectPath
"appFolders", "testFolders" | ForEach-Object {
"appFolders", "testFolders", "bcptTestFolders" | ForEach-Object {
$propertyName = $_
Write-Host "Adding folders from $depProject to $_"
$found = $false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function DownloadDependenciesFromProbingPaths($baseFolder, $project, $destinatio
if ($settings.ContainsKey('appDependencyProbingPaths') -and $settings.appDependencyProbingPaths) {
return Get-Dependencies -probingPathsJson $settings.appDependencyProbingPaths -saveToPath $destinationPath | Where-Object { $_ }
}
return $settings
}

function DownloadDependenciesFromCurrentBuild($baseFolder, $project, $projectsDependencies, $buildMode, $destinationPath) {
Expand Down Expand Up @@ -95,7 +96,7 @@ try {
Write-Host "::endgroup::"

Write-Host "::group::Downloading project dependencies from probing paths"
$downloadedDependencies += DownloadDependenciesFromProbingPaths -baseFolder $baseFolder -project $project -destinationPath $destinationPath
$settings = $downloadedDependencies += DownloadDependenciesFromProbingPaths -baseFolder $baseFolder -project $project -destinationPath $destinationPath
Write-Host "::endgroup::"

Write-Host "Downloaded dependencies: $($downloadedDependencies -join ', ')"
Expand All @@ -122,6 +123,13 @@ try {

Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "DownloadedApps=$DownloadedAppsJson"
Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "DownloadedTestApps=$DownloadedTestAppsJson"

'appFolders', 'testFolders', 'bcptTestFolders' | ForEach-Object {
$propName = $_
Write-Host "Setting $($propName) to $($settings."$propName" -join ', ')"
$foldersJson = ConvertTo-Json $settings."$propName" -Depth 99 -Compress
Add-Content -Encoding UTF8 -Path $env:GITHUB_ENV -Value "$propName=$foldersJson"
}
}
catch {
Write-Host "::ERROR::DownloadProjectDependencies action failed.$([environment]::Newline)Error: $($_.Exception.Message)$([environment]::Newline)Stacktrace: $($_.scriptStackTrace)"
Expand Down
6 changes: 5 additions & 1 deletion Actions/DownloadProjectDependencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ The action constructs arrays of paths to .app files, that are dependencies of th
## OUTPUT

### ENV variables
none
| Name | Description |
| :-- | :-- |
| appFolders | A JSON-formatted array of appFolders |
| testFolders | A JSON-formatted array of testFolders |
| bcptTestFolders | A JSON-formatted array of bcptTestFolders |

### OUTPUT variables
| Name | Description |
Expand Down
8 changes: 4 additions & 4 deletions Actions/DownloadProjectDependencies/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ inputs:
description: A JSON object that matches eash project with its dependency projects
required: true
outputs:
DownloadedApps:
DownloadedApps:
description: A JSON-formatted array of paths to .app files of the apps that were downloaded
value: ${{ steps.DownloadDependencies.outputs.DownloadedApps }}
DownloadedTestApps:
DownloadedTestApps:
description: A JSON-formatted array of paths to .app files of the test apps that were downloaded
value: ${{ steps.DownloadDependencies.outputs.DownloadedTestApps }}
runs:
Expand All @@ -41,10 +41,10 @@ runs:
_destinationPath: ${{ github.workspace }}/.dependencies
_gitHubToken: ${{ github.token }}
run:
try {
try {
${{ github.action_path }}/DownloadProjectDependencies.Action.ps1 -project $ENV:_project -buildMode $ENV:_buildMode -projectsDependenciesJson $ENV:_projectsDependenciesJson -baseFolder $ENV:_baseFolder -destinationPath $ENV:_destinationPath -token $ENV:_gitHubToken
}
catch {
catch {
Write-Host "::Error::Unexpected error when running action ($($_.Exception.Message.Replace("`r",'').Replace("`n",' ')))"
exit 1
}
Expand Down
4 changes: 2 additions & 2 deletions Actions/ReadSettings/ReadSettings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ try {
$settingValue = $settings."$setting"
$outSettings += @{ "$setting" = $settingValue }
if ($getSettings -contains $setting) {
if ($settingValue -is [System.Collections.Specialized.OrderedDictionary]) {
Add-Content -Encoding UTF8 -Path $env:GITHUB_ENV -Value "$setting=$($settingValue | ConvertTo-Json -Depth 99 -Compress)"
if ($settingValue -is [System.Collections.Specialized.OrderedDictionary] -or $settingValue -is [hashtable]) {
Add-Content -Encoding UTF8 -Path $env:GITHUB_ENV -Value "$setting=$(ConvertTo-Json $settingValue -Depth 99 -Compress)"
}
elseif ($settingValue -is [String] -and ($settingValue.contains("`n") -or $settingValue.contains("`r"))) {
throw "Setting $setting contains line breaks, which is not supported"
Expand Down
3 changes: 3 additions & 0 deletions Actions/RunPipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Run pipeline in AL-Go repository
| token | | The GitHub token running the action | github.token |
| parentTelemetryScopeJson | | Specifies the parent telemetry scope for the telemetry signal | {} |
| artifact | | ArtifactUrl to use for the build | settings.artifact |
| appFolders | | A JSON-formatted array of appFolders | settings.appFolders |
| testFolders | | A JSON-formatted array of testFolders | settings.testFolders |
| bcptTestFolders | | A JSON-formatted array of bcptTestFolders | settings.bcptTestFolders |
| project | | Project name if the repository is setup for multiple projects | . |
| buildMode | | Specifies a mode to use for the build steps | Default |
| installAppsJson | | A JSON-formatted list of apps to install | [] |
Expand Down
25 changes: 21 additions & 4 deletions Actions/RunPipeline/RunPipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Param(
[string] $parentTelemetryScopeJson = '7b7d',
[Parameter(HelpMessage = "ArtifactUrl to use for the build", Mandatory = $false)]
[string] $artifact = "",
[Parameter(HelpMessage = "A JSON-formatted array of appFolders", Mandatory = $false)]
[string] $appFolders = "",
[Parameter(HelpMessage = "A JSON-formatted array of testFolders", Mandatory = $false)]
[string] $testFolders = "",
[Parameter(HelpMessage = "A JSON-formatted array of bcptTestFolders", Mandatory = $false)]
[string] $bcptTestFolders = "",
[Parameter(HelpMessage = "Project folder", Mandatory = $false)]
[string] $project = "",
[Parameter(HelpMessage = "Specifies a mode to use for the build steps", Mandatory = $false)]
Expand Down Expand Up @@ -119,7 +125,18 @@ try {
}

$repo = AnalyzeRepo -settings $settings -token $token -baseFolder $baseFolder -project $project -insiderSasToken $insiderSasToken -doNotCheckAppDependencyProbingPaths @analyzeRepoParams
if ((-not $repo.appFolders) -and (-not $repo.testFolders)) {

if (-not $appFolders) {
$appFolders = $repo.appFolders
}
if (-not $testFolders) {
$testFolders = $repo.testFolders
}
if (-not $bcptTestFolders) {
$bcptTestFolders = $repo.bcptTestFolders
}

if ((-not $appFolders) -and (-not $testFolders) -and (-not $bcptTestFolders)) {
Write-Host "Repository is empty, exiting"
exit
}
Expand Down Expand Up @@ -383,9 +400,9 @@ try {
-generateDependencyArtifact:$repo.generateDependencyArtifact `
-updateDependencies:$repo.updateDependencies `
-previousApps $previousApps `
-appFolders $repo.appFolders `
-testFolders $repo.testFolders `
-bcptTestFolders $repo.bcptTestFolders `
-appFolders $appFolders `
-testFolders $testFolders `
-bcptTestFolders $bcptTestFolders `
-buildOutputFile $buildOutputFile `
-containerEventLogFile $containerEventLogFile `
-testResultsFile $testResultsFile `
Expand Down
17 changes: 16 additions & 1 deletion Actions/RunPipeline/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ inputs:
description: ArtifactUrl to use for the build
required: false
default: ''
appFolders:
description: A JSON-formatted array of appFolders
required: false
default: ''
testFolders:
description: A JSON-formatted array of testFolders
required: false
default: ''
bcptTestFolders:
description: A JSON-formatted array of bcptTestFolders
required: false
default: ''
project:
description: Project folder
required: false
Expand All @@ -47,11 +59,14 @@ runs:
_token: ${{ inputs.token }}
_parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }}
_artifact: ${{ inputs.artifact }}
_appFolders: ${{ inputs.appFolders }}
_testFolders: ${{ inputs.testFolders }}
_bcptTestFolders: ${{ inputs.bcptTestFolders }}
_project: ${{ inputs.project }}
_buildMode: ${{ inputs.buildMode }}
_installAppsJson: ${{ inputs.installAppsJson }}
_installTestAppsJson: ${{ inputs.installTestAppsJson }}
run: try { ${{ github.action_path }}/RunPipeline.ps1 -actor $ENV:_actor -token $ENV:_token -parentTelemetryScopeJson $ENV:_parentTelemetryScopeJson -artifact $ENV:_artifact -project $ENV:_project -buildMode $ENV:_buildMode -installAppsJson $ENV:_installAppsJson -installTestAppsJson $ENV:_installTestAppsJson } catch { Write-Host "::Error::Unexpected error when running action ($($_.Exception.Message.Replace("`r",'').Replace("`n",' ')))"; exit 1 }
run: try { ${{ github.action_path }}/RunPipeline.ps1 -actor $ENV:_actor -token $ENV:_token -parentTelemetryScopeJson $ENV:_parentTelemetryScopeJson -artifact $ENV:_artifact -appFolders $ENV:_appFolders -testFolders $ENV:_testFolders -bcptTestFolders $ENV:_bcptTestFolders -project $ENV:_project -buildMode $ENV:_buildMode -installAppsJson $ENV:_installAppsJson -installTestAppsJson $ENV:_installTestAppsJson } catch { Write-Host "::Error::Unexpected error when running action ($($_.Exception.Message.Replace("`r",'').Replace("`n",' ')))"; exit 1 }
branding:
icon: terminal
color: blue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
shell: ${{ inputs.shell }}
parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }}
project: ${{ inputs.project }}
get: useCompilerFolder,keyVaultCodesignCertificateName,doNotSignApps,artifact
get: useCompilerFolder,keyVaultCodesignCertificateName,doNotSignApps,artifact,appFolders,testFolders,bcptTestFolders

- name: Read secrets
if: github.event_name != 'pull_request'
Expand Down Expand Up @@ -128,6 +128,9 @@ jobs:
shell: ${{ inputs.shell }}
parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }}
artifact: ${{ env.artifact }}
appFolders: ${{ env.artifact }}
testFolders: ${{ env.testFolders }}
bcptTestFolders: ${{ env.bcptTestFolders }}
project: ${{ inputs.project }}
buildMode: ${{ inputs.buildMode }}
installAppsJson: ${{ steps.DownloadProjectDependencies.outputs.DownloadedApps }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
shell: ${{ inputs.shell }}
parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }}
project: ${{ inputs.project }}
get: useCompilerFolder,keyVaultCodesignCertificateName,doNotSignApps,artifact
get: useCompilerFolder,keyVaultCodesignCertificateName,doNotSignApps,artifact,appFolders,testFolders,bcptTestFolders

- name: Read secrets
if: github.event_name != 'pull_request'
Expand Down Expand Up @@ -128,6 +128,9 @@ jobs:
shell: ${{ inputs.shell }}
parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }}
artifact: ${{ env.artifact }}
appFolders: ${{ env.artifact }}
testFolders: ${{ env.testFolders }}
bcptTestFolders: ${{ env.bcptTestFolders }}
project: ${{ inputs.project }}
buildMode: ${{ inputs.buildMode }}
installAppsJson: ${{ steps.DownloadProjectDependencies.outputs.DownloadedApps }}
Expand Down

0 comments on commit 92f3393

Please sign in to comment.