Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ALDoc support in AL-Go #760

Merged
merged 252 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 228 commits
Commits
Show all changes
252 commits
Select commit Hold shift + click to select a range
2049e83
deploy
freddydk Oct 3, 2023
005b109
need
freddydk Oct 3, 2023
a0371fe
add DeployALDoc action
freddydk Oct 4, 2023
8565233
rename
freddydk Oct 4, 2023
b6df0ec
read settings
freddydk Oct 4, 2023
4ce89c2
dump name
freddydk Oct 4, 2023
f76aff5
spell
freddydk Oct 4, 2023
89a95eb
projects
freddydk Oct 4, 2023
c8cb219
dump assets
freddydk Oct 4, 2023
1ea46f7
don't return
freddydk Oct 4, 2023
2dd320c
unpack
freddydk Oct 4, 2023
6f01da9
dump
freddydk Oct 4, 2023
cf46a9b
dump
freddydk Oct 4, 2023
249f79a
add build
freddydk Oct 4, 2023
bffb17b
versions
freddydk Oct 4, 2023
8706e89
dump
freddydk Oct 4, 2023
c08db76
ht
freddydk Oct 4, 2023
872052c
wild
freddydk Oct 4, 2023
a03cfce
fix
freddydk Oct 4, 2023
a36b895
delete
freddydk Oct 4, 2023
edd6fd8
global
freddydk Oct 4, 2023
6c3a0df
set loc
freddydk Oct 4, 2023
4fcfa38
dump
freddydk Oct 4, 2023
edac7b5
loc
freddydk Oct 4, 2023
8aab605
use .aldoc
freddydk Oct 4, 2023
469cf5d
hmm
freddydk Oct 4, 2023
20cf760
fix
freddydk Oct 4, 2023
da03827
install docfx
freddydk Oct 4, 2023
e1f96e3
remove dumps
freddydk Oct 4, 2023
d3b6c6d
use cmddo
freddydk Oct 4, 2023
d2ec79d
test
freddydk Oct 4, 2023
2fa6db1
impl
freddydk Oct 4, 2023
a112abd
chmod
freddydk Oct 4, 2023
fda0f2e
l
freddydk Oct 4, 2023
23cd1fe
relative
freddydk Oct 4, 2023
19dd85e
dumps
freddydk Oct 4, 2023
3a845bc
dumps
freddydk Oct 4, 2023
d42f869
toc
freddydk Oct 4, 2023
bc2bed3
dumps
freddydk Oct 5, 2023
990febe
dirname
freddydk Oct 5, 2023
ae06d2d
fullnames
freddydk Oct 5, 2023
b70a88a
rename
freddydk Oct 5, 2023
6dcd15d
dump
freddydk Oct 5, 2023
05445de
use linux cp and rm
freddydk Oct 5, 2023
5c82eb3
fix
freddydk Oct 5, 2023
cc467b7
info
freddydk Oct 5, 2023
7e1f185
fix info
freddydk Oct 5, 2023
e43c1a3
fix
freddydk Oct 5, 2023
312d914
add settings
freddydk Oct 5, 2023
fe456bf
or
freddydk Oct 5, 2023
5aed8f8
1
freddydk Oct 5, 2023
770f5a8
or2
freddydk Oct 5, 2023
3404182
default windows
freddydk Oct 5, 2023
57f3183
test obj
freddydk Oct 5, 2023
a9ac64d
dump releases
freddydk Oct 5, 2023
76a20be
x
freddydk Oct 5, 2023
3719f4e
permissions
freddydk Oct 5, 2023
e910f44
path
freddydk Oct 5, 2023
8a172dd
zip
freddydk Oct 5, 2023
2a0a490
add failure
freddydk Oct 5, 2023
50992bf
downloadandbuild
freddydk Oct 5, 2023
98d15e4
thisbuild
freddydk Oct 5, 2023
1a3c0d0
depth 1
freddydk Oct 6, 2023
6b59a77
..
freddydk Oct 6, 2023
6cbe653
releasenotes
freddydk Oct 6, 2023
c45db67
vn
freddydk Oct 6, 2023
1a09ce3
allow generate release notes
freddydk Oct 6, 2023
d4cfae6
dump
freddydk Oct 6, 2023
8d2b56e
do not modify
freddydk Oct 6, 2023
8af02da
body
freddydk Oct 6, 2023
987cb14
p
freddydk Oct 6, 2023
13dbb28
dumps
freddydk Oct 6, 2023
101cf2d
update
freddydk Oct 6, 2023
d8e1e43
remove dumps
freddydk Oct 6, 2023
5c9f0d4
add template
freddydk Oct 6, 2023
d003128
update index
freddydk Oct 6, 2023
d657eef
-join
freddydk Oct 6, 2023
e04d65d
bold
freddydk Oct 6, 2023
712fed9
update
freddydk Oct 6, 2023
7d6e855
dollar
freddydk Oct 6, 2023
20b2da7
include repo
freddydk Oct 8, 2023
02e0fe6
check single repo
freddydk Oct 8, 2023
46b5051
setting for maxreleases
freddydk Oct 8, 2023
180226c
Merge branch 'main' into ALDoc
freddydk Oct 8, 2023
5a56454
use reponame
freddydk Oct 8, 2023
1b40d5d
dumps
freddydk Oct 8, 2023
6f4e068
dump old toc
freddydk Oct 8, 2023
e8dc89d
comment
freddydk Oct 8, 2023
83253b0
update
freddydk Oct 8, 2023
abfcf14
test exclude
freddydk Oct 8, 2023
a93c73c
throw
freddydk Oct 8, 2023
f2986d1
remove exception
freddydk Oct 8, 2023
981a485
exclude
freddydk Oct 8, 2023
6088e0d
struc
freddydk Oct 8, 2023
e58731e
hash
freddydk Oct 8, 2023
47d1a3a
ordered
freddydk Oct 8, 2023
ce45cba
struc2
freddydk Oct 8, 2023
b9abbbf
default
freddydk Oct 8, 2023
018bd04
defaultMD
freddydk Oct 8, 2023
ff6a25e
md
freddydk Oct 8, 2023
f1e5e77
defaults
freddydk Oct 8, 2023
5a71b42
placeholders
freddydk Oct 8, 2023
d914f03
default md
freddydk Oct 8, 2023
edb4115
header
freddydk Oct 8, 2023
b53ef6a
get repository
freddydk Oct 10, 2023
c009038
not mandatory
freddydk Oct 10, 2023
3392060
repo
freddydk Oct 10, 2023
677c6e8
str
freddydk Oct 10, 2023
4241ef6
return
freddydk Oct 10, 2023
93f5ed2
json
freddydk Oct 10, 2023
5ad13c1
remove env
freddydk Oct 10, 2023
af1c3c9
Merge branch 'main' into ALDoc
freddydk Oct 15, 2023
c69f6b2
fix tests
freddydk Oct 15, 2023
b92cae9
fix test
freddydk Oct 15, 2023
a6d58dc
Merge branch 'main' into ALDoc
freddydk Oct 17, 2023
f47273a
Merge branch 'main' into ALDoc
freddydk Oct 26, 2023
1c6d60c
Merge branch 'main' into ALDoc
freddydk Nov 10, 2023
b68687e
add available check
freddydk Nov 10, 2023
7be9fda
calc deploy
freddydk Nov 10, 2023
31f984e
dump
freddydk Nov 10, 2023
ba33c42
dump the right value
freddydk Nov 10, 2023
531f5c5
add workflow
freddydk Nov 10, 2023
a53ece7
dups
freddydk Nov 10, 2023
f5fbbe8
permissions
freddydk Nov 10, 2023
74a31db
generate rel notes
freddydk Nov 10, 2023
6748ffe
expand
freddydk Nov 10, 2023
5ec9496
s
freddydk Nov 10, 2023
1436ee1
with folder
freddydk Nov 10, 2023
5efff1e
p
freddydk Nov 10, 2023
c3e71cd
noext
freddydk Nov 10, 2023
4350497
id token
freddydk Nov 10, 2023
385cea6
rename
freddydk Nov 10, 2023
b512434
Merge branch 'main' into ALDoc
freddydk Nov 17, 2023
28a83aa
docs
freddydk Nov 17, 2023
eb567c6
Update GetStarted.md
freddydk Nov 17, 2023
8c589ca
Update AddAnApp.md
freddydk Nov 17, 2023
89605b0
Update AddAnApp.md
freddydk Nov 17, 2023
141b893
Update Versioning.md
freddydk Nov 17, 2023
d97a9d2
Update Versioning.md
freddydk Nov 18, 2023
13b591e
Update Prerequisites.md
freddydk Nov 18, 2023
bb966d3
Update Releasing.md
freddydk Nov 18, 2023
4a56050
Update Projects.md
freddydk Nov 18, 2023
09c59fe
Update Projects.md
freddydk Nov 18, 2023
263ae2d
Update Dependencies1.md
freddydk Nov 18, 2023
b1601b4
Update Dependencies1.md
freddydk Nov 18, 2023
da8c6be
Update Dependencies2.md
freddydk Nov 19, 2023
780e4ac
Update Dependencies2.md
freddydk Nov 19, 2023
7685e3d
Update Prerequisites.md
freddydk Nov 19, 2023
05ed217
Update Dependencies1.md
freddydk Nov 19, 2023
b3128d7
Update Dependencies2.md
freddydk Nov 19, 2023
a37a706
Update Prerequisites.md
freddydk Nov 19, 2023
10b2617
Update Dependencies2.md
freddydk Nov 19, 2023
252e762
Update Dependencies2.md
freddydk Nov 19, 2023
8db8714
Update Dependencies2.md
freddydk Nov 20, 2023
96aadd3
Update ContinuousDelivery.md
freddydk Nov 20, 2023
63305b4
Update ContinuousDelivery.md
freddydk Nov 20, 2023
be944bb
Update ContinuousDeployment.md
freddydk Nov 20, 2023
47a704c
Update ContinuousDeployment.md
freddydk Nov 20, 2023
acba9c0
Update ContinuousDelivery.md
freddydk Nov 20, 2023
cde70e0
Update ContinuousDeployment.md
freddydk Nov 20, 2023
e64548e
Update ContinuousDeployment.md
freddydk Nov 20, 2023
a2fb67c
Update ContinuousDeployment.md
freddydk Nov 20, 2023
e511254
Update PublishToProduction.md
freddydk Nov 20, 2023
b363ae8
Update PublishToProduction.md
freddydk Nov 20, 2023
0d44b01
Update AutomatedTests.md
freddydk Nov 20, 2023
6c0f3d3
Update ScheduledTestRuns.md
freddydk Nov 21, 2023
6637a34
Update ScheduledTestRuns.md
freddydk Nov 21, 2023
9d47d63
Update Dependencies2.md
freddydk Nov 21, 2023
7656478
Update Prerequisites.md
freddydk Nov 21, 2023
2331d99
Update ContinuousDelivery.md
freddydk Nov 21, 2023
9aef640
Update ContinuousDeployment.md
freddydk Nov 21, 2023
411fe47
Update PublishToProduction.md
freddydk Nov 21, 2023
a68c460
Update AutomatedTests.md
freddydk Nov 21, 2023
704d843
Update ScheduledTestRuns.md
freddydk Nov 21, 2023
aa6b286
Update Versioning.md
freddydk Nov 21, 2023
d51ae72
Update ReferenceDoc.md
freddydk Nov 21, 2023
c1a6fa1
Update ReferenceDoc.md
freddydk Nov 21, 2023
a686dc2
Update ScheduledTestRuns.md
freddydk Nov 21, 2023
d751e02
Update ReferenceDoc.md
freddydk Nov 21, 2023
f87f357
Update ReferenceDoc.md
freddydk Nov 21, 2023
49cf0aa
Update ReferenceDoc.md
freddydk Nov 21, 2023
d42f247
Merge branch 'main' into ALDoc
freddydk Nov 21, 2023
2e9e5cf
Update ReferenceDoc.md
freddydk Nov 21, 2023
8ae4aa9
Merge branch 'main' into ALDoc
freddydk Nov 21, 2023
9615420
Merge branch 'main' into ALDoc
freddydk Nov 22, 2023
ac5b286
Update Workshop/GetStarted.md
freddydk Nov 22, 2023
9bd0785
review
freddydk Nov 22, 2023
249655d
Merge branch 'ALDoc' of https://github.com/freddydk/AL-Go into ALDoc
freddydk Nov 22, 2023
4de026e
review
freddydk Nov 22, 2023
b1e1984
review
freddydk Nov 22, 2023
bc4bcbc
review
freddydk Nov 22, 2023
b1f16a3
review
freddydk Nov 22, 2023
0084030
Update Actions/Github-Helper.psm1
freddydk Nov 22, 2023
ae29dca
Update Scenarios/settings.md
freddydk Nov 22, 2023
b412f9a
Update Actions/BuildALDoc/BuildALDoc.HelperFunctions.ps1
freddydk Nov 22, 2023
ead309b
review
freddydk Nov 22, 2023
e6c15e0
Merge branch 'ALDoc' of https://github.com/freddydk/AL-Go into ALDoc
freddydk Nov 22, 2023
df8cd20
rename action + script
freddydk Nov 23, 2023
069e1ce
rename
freddydk Nov 23, 2023
47d7c85
dep
freddydk Nov 23, 2023
4d3e913
check project
freddydk Nov 23, 2023
2615bb0
use projectname for artifacts
freddydk Nov 23, 2023
a0765c9
review
freddydk Nov 23, 2023
80f4f5b
review
freddydk Nov 23, 2023
b7b009a
review
freddydk Nov 24, 2023
6d9ee6d
add useProjectsAsFolders setting
freddydk Nov 24, 2023
b8accd3
dumps
freddydk Nov 24, 2023
60abdc8
sort apps
freddydk Nov 25, 2023
07179de
use key
freddydk Nov 25, 2023
6c2b81d
do not clear
freddydk Nov 25, 2023
c6a57ad
not
freddydk Nov 25, 2023
36b9aeb
add repo to footer
freddydk Nov 25, 2023
b1214e1
footer is html
freddydk Nov 25, 2023
bfd34e2
use foreach
freddydk Nov 25, 2023
2ed3c01
ci
freddydk Nov 25, 2023
23858e6
fix
freddydk Nov 25, 2023
ab71d75
add test
freddydk Nov 26, 2023
d33443e
test fail
freddydk Nov 26, 2023
83c3c7c
test failure
freddydk Nov 26, 2023
c5d6053
linux
freddydk Nov 26, 2023
af2c08b
Merge branch 'main' into ALDoc
freddydk Nov 27, 2023
678503f
Merge branch 'main' into ALDoc
freddydk Nov 28, 2023
346ae3a
Update RELEASENOTES.md
freddydk Nov 28, 2023
5ed2c65
Update RELEASENOTES.md
freddydk Nov 28, 2023
19e157b
review comments
freddydk Nov 28, 2023
102139a
use private containerhelper for test
freddydk Nov 30, 2023
54315e9
review comments
freddydk Dec 1, 2023
c95cc03
Review comments + casing
freddydk Dec 1, 2023
80da73e
Update Actions/AL-Go-Helper.ps1
freddydk Dec 1, 2023
2b1be34
add end2end test
freddydk Dec 2, 2023
ee0030f
Merge branch 'ALDoc' of https://github.com/freddydk/AL-Go into ALDoc
freddydk Dec 2, 2023
f08bf05
include file
freddydk Dec 2, 2023
7dcfd20
script analyzer
freddydk Dec 2, 2023
cbaa2d8
update docs
freddydk Dec 3, 2023
8692bcb
only warn if needed
freddydk Dec 3, 2023
c1152e1
workshop images
freddydk Dec 3, 2023
1414935
note
freddydk Dec 3, 2023
e3fc948
workshop
freddydk Dec 3, 2023
4314ef7
check that githubPages should be included
freddydk Dec 4, 2023
d6e9601
Merge branch 'main' into ALDoc
freddydk Dec 4, 2023
e38c81e
Workshop updates
freddydk Dec 4, 2023
2e382c9
Merge branch 'ALDoc' of https://github.com/freddydk/AL-Go into ALDoc
freddydk Dec 4, 2023
bcecd2b
-auto
freddydk Dec 4, 2023
ad7efcc
review comments
freddydk Dec 4, 2023
3afd5dd
grouping
freddydk Dec 4, 2023
fb206b8
group name
freddydk Dec 4, 2023
c5cb325
Update Actions/BuildReferenceDocumentation/BuildReferenceDocumentatio…
freddydk Dec 4, 2023
779e956
support release branch
freddydk Dec 4, 2023
ac0266d
Merge branch 'ALDoc' of https://github.com/freddydk/AL-Go into ALDoc
freddydk Dec 4, 2023
b63a2f7
review
freddydk Dec 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $defaultCICDPushBranches = @( 'main', 'release/*', 'feature/*' )
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'defaultCICDPullRequestBranches', Justification = 'False positive.')]
$defaultCICDPullRequestBranches = @( 'main' )
$runningLocal = $local.IsPresent
$defaultBcContainerHelperVersion = "preview" # Must be double quotes. Will be replaced by BcContainerHelperVersion if necessary in the deploy step
$defaultBcContainerHelperVersion = "https://github.com/freddydk/navcontainerhelper/archive/refs/heads/renewaccesstoken.zip" # Must be double quotes. Will be replaced by BcContainerHelperVersion if necessary in the deploy step
freddydk marked this conversation as resolved.
Show resolved Hide resolved
$microsoftTelemetryConnectionString = "InstrumentationKey=84bd9223-67d4-4378-8590-9e4a46023be2;IngestionEndpoint=https://westeurope-1.in.applicationinsights.azure.com/"

$runAlPipelineOverrides = @(
Expand Down Expand Up @@ -623,6 +623,18 @@ function ReadSettings {
"PullRequestTrigger" = "pull_request_target"
"fullBuildPatterns" = @()
"excludeEnvironments" = @()
"ALDoc" = [ordered]@{
"ContinuousDeployment" = $false
"DeployToGitHubPages" = $true
"MaxReleases" = 3
"UseProjectsAsFolders" = $true
"Projects" = @()
"ExcludeProjects" = @()
"Header" = "Documentation for {REPOSITORY} {VERSION}"
"Footer" = "Documentation for <a href=""https://github.com/{REPOSITORY}"">{REPOSITORY}</a> made with <a href=""https://aka.ms/AL-Go"">AL-Go for GitHub</a>, <a href=""https://go.microsoft.com/fwlink/?linkid=2247728"">ALDoc</a> and <a href=""https://dotnet.github.io/docfx"">DocFx</a>"
"DefaultIndexMD" = "## Reference documentation\n\nThis is the generated reference documentation for [{REPOSITORY}](https://github.com/{REPOSITORY}).\n\nYou can use the navigation bar at the top and the table of contents to the left to navigate your documentation.\n\nYou can change this content by creating/editing the **{INDEXTEMPLATERELATIVEPATH}** file in your repository or use the ALDoc:DefaultIndexMD setting in your repository settings file (.github/AL-Go-Settings.json)\n\n{RELEASENOTES}"
"DefaultReleaseMD" = "## Release reference documentation\n\nThis is the generated reference documentation for [{REPOSITORY}](https://github.com/{REPOSITORY}).\n\nYou can use the navigation bar at the top and the table of contents to the left to navigate your documentation.\n\nYou can change this content by creating/editing the **{INDEXTEMPLATERELATIVEPATH}** file in your repository or use the ALDoc:DefaultReleaseMD setting in your repository settings file (.github/AL-Go-Settings.json)\n\n{RELEASENOTES}"
}
}

# Read settings from files and merge them into the settings object
Expand Down Expand Up @@ -1075,6 +1087,7 @@ function CheckAppDependencyProbingPaths {
[hashTable] $settings,
$token,
[string] $baseFolder = $ENV:GITHUB_WORKSPACE,
[string] $repository = $ENV:GITHUB_REPOSITORY,
[string] $project = '.',
[string[]] $includeOnlyAppIds
)
Expand All @@ -1095,10 +1108,10 @@ function CheckAppDependencyProbingPaths {
throw "The Setting AppDependencyProbingPaths needs to contain a repo property, pointing to the repository on which your project have a dependency"
}
if ($dependency.Repo -eq ".") {
$dependency.Repo = "$ENV:GITHUB_SERVER_URL/$ENV:GITHUB_REPOSITORY"
$dependency.Repo = "https://github.com/$repository"
}
elseif ($dependency.Repo -notlike "https://*") {
$dependency.Repo = "$ENV:GITHUB_SERVER_URL/$($dependency.Repo)"
$dependency.Repo = "https://github.com/$($dependency.Repo)"
}
if (-not ($dependency.PsObject.Properties.name -eq "Version")) {
$dependency | Add-Member -name "Version" -MemberType NoteProperty -Value "latest"
Expand Down Expand Up @@ -1145,7 +1158,7 @@ function CheckAppDependencyProbingPaths {
}

if ($dependency.release_status -eq "include") {
if ($dependency.Repo -ne "$ENV:GITHUB_SERVER_URL/$ENV:GITHUB_REPOSITORY") {
if ($dependency.Repo -ne "https://github.com/$repository") {
OutputWarning "Dependencies with release_status 'include' must be to other projects in the same repository."
}
else {
Expand All @@ -1160,7 +1173,7 @@ function CheckAppDependencyProbingPaths {
$thisIncludeOnlyAppIds = @($dependencyIds + $includeOnlyAppIds + $dependency.alwaysIncludeApps)
$depSettings = ReadSettings -baseFolder $baseFolder -project $depProject -workflowName "CI/CD"
$depSettings = AnalyzeRepo -settings $depSettings -baseFolder $baseFolder -project $depProject -includeOnlyAppIds $thisIncludeOnlyAppIds -doNotCheckArtifactSetting -doNotIssueWarnings
$depSettings = CheckAppDependencyProbingPaths -settings $depSettings -token $token -baseFolder $baseFolder -project $depProject -includeOnlyAppIds $thisIncludeOnlyAppIds
$depSettings = CheckAppDependencyProbingPaths -settings $depSettings -token $token -baseFolder $baseFolder -repository $repository -project $depProject -includeOnlyAppIds $thisIncludeOnlyAppIds

$projectPath = Join-Path $baseFolder $project -Resolve
Push-Location $projectPath
Expand Down Expand Up @@ -1503,6 +1516,7 @@ function CreateDevEnv {
[string] $caller = 'local',
[Parameter(Mandatory = $true)]
[string] $baseFolder,
[string] $repository = "$ENV:GITHUB_REPOSITORY",
[string] $project,
[string] $userName = $env:Username,

Expand Down Expand Up @@ -1530,6 +1544,16 @@ function CreateDevEnv {
throw "Specified parameters doesn't match kind=$kind"
}

if ("$repository" -eq "") {
Push-Location $baseFolder
try {
$repoInfo = invoke-gh -silent -returnValue repo view --json "owner,name" | ConvertFrom-Json
$repository = "$($repoInfo.owner.login)/$($repoInfo.name)"
}
finally {
Pop-Location
}
}
$projectFolder = Join-Path $baseFolder $project -Resolve
$dependenciesFolder = Join-Path $projectFolder ".dependencies"
$runAlPipelineParams = @{}
Expand Down Expand Up @@ -1660,7 +1684,7 @@ function CreateDevEnv {
}
}
$settings = AnalyzeRepo -settings $settings -baseFolder $baseFolder -project $project @params
$settings = CheckAppDependencyProbingPaths -settings $settings -baseFolder $baseFolder -project $project
$settings = CheckAppDependencyProbingPaths -settings $settings -baseFolder $baseFolder -repository $repository -project $project

if (!$accept_insiderEula -and ($settings.artifact -like 'https://bcinsider.blob.core.windows.net/*' -or $settings.artifact -like 'https://bcinsider.azureedge.net/*')) {
Read-Host 'Press ENTER to accept the Business Central insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) or break the script to cancel'
Expand Down
4 changes: 2 additions & 2 deletions Actions/AddExistingApp/action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: PowerShell script
author: Freddy Kristiansen
name: Add Existing App
author: Microsoft Corporation
permissions:
contents: write
pull-requests: write
Expand Down
4 changes: 2 additions & 2 deletions Actions/AnalyzeTests/action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: PowerShell script
author: Freddy Kristiansen
name: Analyze Tests
author: Microsoft Corporation
inputs:
shell:
description: Shell in which you want to run the action (powershell or pwsh)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
function DownloadAlDoc {
if ("$ENV:aldocPath" -eq "") {
Write-Host "Locating aldoc"
$artifactUrl = Get-BCArtifactUrl -storageAccount bcinsider -type sandbox -country core -select Latest -accept_insiderEula
Write-Host "Downloading aldoc"
$folder = Download-Artifacts $artifactUrl
$alLanguageVsix = Join-Path $folder '*.vsix' -Resolve
$tempFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
Copy-Item -Path $alLanguageVsix -Destination "$($tempFolder).zip"
New-Item -Path $tempFolder -ItemType Directory | Out-Null
Write-Host "Extracting aldoc"
Expand-Archive -Path "$($tempFolder).zip" -DestinationPath $tempFolder -Force
Remove-Item -Path "$($tempFolder).zip" -Force
if ($IsLinux) {
$ENV:aldocPath = Join-Path $tempFolder 'extension/bin/linux/aldoc'
& /usr/bin/env sudo pwsh -command "& chmod +x $ENV:aldocPath"
}
else {
$ENV:aldocPath = Join-Path $tempFolder 'extension/bin/win32/aldoc.exe'
freddydk marked this conversation as resolved.
Show resolved Hide resolved
}

Write-Host "Installing/Updating docfx"
CmdDo -command dotnet -arguments @("tool","update","-g docfx")
}
$ENV:aldocPath
freddydk marked this conversation as resolved.
Show resolved Hide resolved
}

function SanitizeFileName([string] $filename) {
freddydk marked this conversation as resolved.
Show resolved Hide resolved
$filename.Replace('_','-').Replace('?','_').Replace('*','_').Replace(' ','-').Replace('\','-').Replace('/','-').Replace(':','-').Replace('<','-').Replace('>','-').Replace('|','-').Replace('%','pct')
freddydk marked this conversation as resolved.
Show resolved Hide resolved
}

function GetAppNameAndFolder {
Param(
[string] $appFile
)

$tmpFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
Extract-AppFileToFolder -appFilename $appFile -appFolder $tmpFolder -generateAppJson
$appJson = Get-Content -Path (Join-Path $tmpFolder 'app.json') -Encoding utf8 | ConvertFrom-Json
$appJson.name
(SanitizeFileName -filename $appJson.name).ToLower()
freddydk marked this conversation as resolved.
Show resolved Hide resolved
Remove-Item -Path $tmpFolder -Recurse -Force
}

#
# Generate Reference documentation for a branch or a release.
# All Apps to use for the ref. doc. are downloaded from the release or latest build of the branch.
#
function GenerateDocsSite {
Param(
[string] $version,
[string[]] $allVersions,
[hashtable] $allApps,
[string] $repoName,
[string] $releaseNotes,
[string] $header,
[string] $footer,
[string] $defaultIndexMD,
[string] $defaultReleaseMD,
[string] $docsPath,
[string] $logLevel,
[switch] $useProjectsAsFolders,
[switch] $hostIt
)

function ReplacePlaceHolders {
Param(
[string] $str,
[string] $version,
[string] $releaseNotes
)
return $str.Replace('{REPOSITORY}',$ENV:GITHUB_REPOSITORY).Replace('{VERSION}',$version).Replace('{RELEASENOTES}',$releaseNotes)
}

$indexTemplateRelativePath = '.aldoc/index.md'
if ($version) {
$thisTemplateRelativePath = '.aldoc/release.md'
$thisDefaultMD = $defaultReleaseMD
}
else {
$thisTemplateRelativePath = $indexTemplateRelativePath
$thisDefaultMD = $defaultIndexMD
}

$indexTemplatePath = Join-Path $ENV:GITHUB_WORKSPACE $thisTemplateRelativePath
if (-not (Test-Path $indexTemplatePath)) {
$indexTemplatePath = Join-Path $ENV:GITHUB_WORKSPACE $indexTemplateRelativePath
}
if (Test-Path $indexTemplatePath) {
$indexTemplate = Get-Content -Encoding utf8 -Path $indexTemplatePath -Raw
}
else {
$indexTemplate = $thisDefaultMD
}
$indexContent = ReplacePlaceHolders -str $indexTemplate.Replace('{INDEXTEMPLATERELATIVEPATH}',$thisTemplateRelativePath) -version $version -releaseNotes $releaseNotes
freddydk marked this conversation as resolved.
Show resolved Hide resolved

$alDocPath = DownloadAlDoc
$docfxPath = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
New-Item -path $docfxPath -ItemType Directory | Out-Null
freddydk marked this conversation as resolved.
Show resolved Hide resolved
try {
$apps = @()
# Generate new toc.yml and calculate apps - releases and projects
freddydk marked this conversation as resolved.
Show resolved Hide resolved
$prefix = ''
if ($version) {
# If $version is set, then we are generating reference documentation for a release
freddydk marked this conversation as resolved.
Show resolved Hide resolved
# all releases will be in a subfolder called releases/$version
# prefix is used to reference links in the root of the site relative to the site we are building now
# We cannot use / as prefix, because that will not work when hosting the site on GitHub pages
$prefix = "../../"
}
$newTocYml = @(
"items:"
)
if ($allVersions.Count -gt 0) {
$newTocYml += @(
" - name: Releases"
" items:"
" - name: main"
" href: $($prefix)index.html"
)
foreach($ver in $allVersions) {
$newTocYml += @(
" - name: $ver"
" href: $($prefix)releases/$ver/index.html"
)
}
}
$allApps | ConvertTo-Json -Depth 99 | Out-Host
if ($allApps.Keys.Count -eq 1 -and $allApps.Keys[0] -eq $repoName) {
# Single project repo - do not use project names as folders
$useProjectsAsFolders = $false
}
$projects = @($allApps.Keys.GetEnumerator() | Sort-Object)
foreach($project in $projects) {
if ($useProjectsAsFolders) {
$newTocYml += @(
" - name: $project"
" items:"
)
$indent = " "
}
else {
$indent = " "
}
$theseApps = @{}
# Get all apps for this project
foreach($appFile in $allApps."$project") {
$apps += @($appFile)
$appName, $appFolder = GetAppNameAndFolder -appFile $appFile
$theseApps."$appName" = $appFolder
}
# Add all apps sorted by name
$theseApps.Keys.GetEnumerator() | Sort-Object | ForEach-Object {
$newTocYml += @(
"$($indent)- name: $($_)"
"$($indent) href: reference/$($theseApps."$_")/toc.yml"
)
}
}

$arguments = @(
"init"
"--output ""$docfxpath"""
"--loglevel $loglevel"
"--targetpackages ""$($apps -join '","')"""
)
Write-Host "invoke aldoc $arguments"
CmdDo -command $aldocPath -arguments $arguments

# Update docfx.json
Write-Host "Update docfx.json"
$docfxJsonFile = Join-Path $docfxPath 'docfx.json'
$docfxJson = Get-Content -Encoding utf8 -Path $docfxJsonFile | ConvertFrom-Json
$docfxJson.build.globalMetadata._appName = ReplacePlaceHolders -str $header -version $version -releaseNotes $releaseNotes
$docfxJson.build.globalMetadata._appFooter = ReplacePlaceHolders -str $footer -version $version -releaseNotes $releaseNotes
$docfxJson | ConvertTo-Json -Depth 99 | Set-Content -Path $docfxJsonFile -Encoding utf8

Write-Host "docfx.json:"
Get-Content $docfxJsonFile | Out-Host

# Create new toc.yml
Write-Host "Create new toc.yml"
$tocYmlFile = Join-Path $docfxpath 'toc.yml'

Write-Host "Original TOC (from aldoc)):"
Get-Content $tocYmlFile | Out-Host

Set-Content -Path $tocYmlFile -Value ($newTocYml -join "`n") -Encoding utf8

Write-Host "TOC:"
Get-Content $tocYmlFile | Out-Host

$apps | ForEach-Object {
$arguments = @(
"build"
"--output ""$docfxpath"""
"--loglevel $loglevel"
"--source ""$_"""
)
Write-Host "invoke aldoc $arguments"
CmdDo -command $aldocPath -arguments $arguments
}

# Set release notes
Write-Host "Update index.md"
$indexMdFile = Join-Path $docfxpath 'index.md'
Set-Content -path $indexMdFile -value $indexContent -encoding utf8

Write-Host "index.md:"
Get-Content $indexMdFile | Out-Host

$arguments = @(
"build"
"--output ""$docsPath"""
"--logLevel $loglevel"
"""$docfxJsonFile"""
)
if ($hostIt) {
$arguments += @("-s")
Write-Host "Generate and host site"
}
Write-Host "invoke doxfx $arguments"
CmdDo -command docfx -arguments $arguments
}
finally {
Remove-Item -Path $docfxPath -Recurse -Force
}
}

# Build a list of all projects (folders) and apps to use when building reference documentation
# return value is a hashtable for all apps and a hashtable for all dependencies
# Every hashtable has project name as key and an array of app files as value
# if useProjectsAsFolders is false, all apps will be collected in one "project" called "dummy", which is never displayed
function CalculateProjectsAndApps {
Param(
[string] $tempFolder,
[string[]] $projects,
[string[]] $excludeProjects,
[switch] $useProjectsAsFolders
Fixed Show fixed Hide fixed
)

if ($projects.Count -eq 0) { $projects = @("*") }
$projectList = @($projects | ForEach-Object { $_.Replace('\','_').Replace('/','_') })
Write-Host "Include Project Patterns"
$projectList | ForEach-Object { Write-Host "- $_" }
$excludeProjectList = @($excludeProjects | ForEach-Object { $_.Replace('\','_').Replace('/','_') })
Write-Host "Exclude Project Patterns"
$excludeProjectList | ForEach-Object { Write-Host "- $_" }
foreach($mask in 'Apps','Dependencies') {
$allApps = @{}
foreach($folder in (Get-ChildItem -Path $tempFolder -Filter '*' | Where-Object { $_.PSIsContainer })) {
freddydk marked this conversation as resolved.
Show resolved Hide resolved
if ($folder.Name -match "^(.*)-main-$mask-(\d*\.\d*\.\d*\.\d*)$") {
freddydk marked this conversation as resolved.
Show resolved Hide resolved
$project = $Matches[1]
$includeIt = $null -ne ($projectList | Where-Object { $project -like $_ })
if ($includeIt) {
$excludeIt = $null -ne ($excludeProjectList | Where-Object { $project -like $_ })
if (-not $excludeIt) {
if (-not $useProjectsAsFolders) {
# use project name dummy for all apps when not using projects as folders
$project = 'dummy'
freddydk marked this conversation as resolved.
Show resolved Hide resolved
}
if (-not $allApps.ContainsKey("$project")) {
$allApps."$project" = @()
}
Get-ChildItem -Path $folder.FullName -Filter '*.app' | ForEach-Object {
$allApps."$project" += @($_.FullName)
}
}
}
}
}
$allApps
}
}
Loading
Loading