Skip to content

Commit 0e67397

Browse files
authored
Merge branch 'main' into fix-nuget-packet-id-shortening
2 parents 77bb926 + 9e08d60 commit 0e67397

File tree

7 files changed

+94
-12
lines changed

7 files changed

+94
-12
lines changed

AppHandling/Extract-AppFileToFolder.ps1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,42 @@ try {
8484
$memoryStream = [System.IO.MemoryStream]::new($content)
8585
$zipArchive = [System.IO.Compression.ZipArchive]::new($memoryStream, [System.IO.Compression.ZipArchiveMode]::Read)
8686
$prevdir = ""
87+
88+
# If the app file is a ready-to-run app, it has a readytorunappmanifest.json file inside the archive
89+
$readyToRunAppManifest = $zipArchive.Entries | Where-Object { $_.FullName -eq "readytorunappmanifest.json" }
90+
if ($readyToRunAppManifest) {
91+
# Create a temporary folder to extract the ready-to-run app manifest
92+
$tmpFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
93+
New-Item -Path $tmpFolder -ItemType Directory -Force | Out-Null
94+
95+
# Extract the ready-to-run app manifest and get the embedded app file name
96+
$fullname = Join-Path $tmpFolder "readytorunappmanifest.json"
97+
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($readyToRunAppManifest, $fullname)
98+
$embeddedAppFileName = (Get-Content -Path $fullname -Raw | ConvertFrom-Json).EmbeddedAppFileName
99+
$embeddedAppFile = $zipArchive.Entries | Where-Object { $_.FullName -eq $embeddedAppFileName }
100+
if (-not $embeddedAppFile) {
101+
throw "Unable to find embedded app file '$embeddedAppFile' in the ready-to-run app."
102+
}
103+
104+
# Create a temporary folder to extract the app file to
105+
$fullname = Join-Path $tmpFolder ([Uri]::UnescapeDataString($embeddedAppFile.FullName))
106+
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($embeddedAppFile, $fullname)
107+
108+
# Close stream and binary reader before recursive call
109+
$binaryReader.Close()
110+
$filestream.Close()
111+
$memoryStream.Close()
112+
113+
try {
114+
# Call the Extract-AppFileToFolder function again to extract the content of the app file
115+
Extract-AppFileToFolder -appFilename $fullname -appFolder $appFolder -generateAppJson:$generateAppJson -excludeRuntimeProperty:$excludeRuntimeProperty -latestSupportedRuntimeVersion:$latestSupportedRuntimeVersion -openFolder:$openFolder
116+
} finally {
117+
# Clean up the temporary folder
118+
Remove-Item $tmpFolder -Recurse -Force -ErrorAction SilentlyContinue
119+
}
120+
return
121+
}
122+
87123
$zipArchive.Entries | ForEach-Object {
88124
$fullname = Join-Path $appFolder ([Uri]::UnescapeDataString($_.FullName))
89125
$dir = [System.IO.Path]::GetDirectoryName($fullname)

AppHandling/Run-AlPipeline.ps1

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,13 +2925,22 @@ $pageScriptingTests | ForEach-Object {
29252925
Write-Host "Running Page Scripting Tests for $testSpec (test name: $name)"
29262926
$resultsFolder = Join-Path $pageScriptingTestResultsFolder $name
29272927
New-Item -Path $resultsFolder -ItemType Directory | Out-Null
2928-
pwsh -command {
2929-
npx replay $args[0] -ResultDir $args[1] -StartAddress $args[2] -Authentication UserPassword -usernameKey 'containerUsername' -passwordkey 'containerPassword'
2930-
} -args $path, $resultsFolder, $startAddress
2931-
if ($? -ne "True") {
2928+
try {
2929+
pwsh -command {
2930+
npx replay $args[0] -ResultDir $args[1] -StartAddress $args[2] -Authentication UserPassword -usernameKey 'containerUsername' -passwordkey 'containerPassword'
2931+
} -args $path, $resultsFolder, $startAddress
2932+
if ($? -ne "True") {
2933+
Write-Host "Page Scripting Tests failed for $testSpec"
2934+
$thisFailed = $true
2935+
}
2936+
} catch {
2937+
$thisFailed = $true
2938+
Write-Host -ForegroundColor Red "Page Scripting Tests failed for $testSpec : $($_.Exception.Message)"
2939+
}
2940+
2941+
if ($thisFailed) {
29322942
Write-Host "Page Scripting Tests failed for $testSpec"
29332943
$allPassed = $false
2934-
$thisFailed = $true
29352944
}
29362945
$testResultsFile = Join-Path $resultsFolder "results.xml"
29372946
$playwrightReportFolder = Join-Path $resultsFolder 'playwright-report'

Artifacts/Download-Artifacts.ps1

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,48 @@ try {
127127
$appUri = [Uri]::new($artifactUrl)
128128

129129
$appArtifactPath = Join-Path $basePath $appUri.AbsolutePath
130+
$appManifestPath = Join-Path $appArtifactPath "manifest.json"
130131
$exists = Test-Path $appArtifactPath
132+
133+
# if the force switch is set, we remove the existing artifact and redownload it
131134
if ($exists -and $force) {
132135
Remove-Item $appArtifactPath -Recurse -Force
133136
$exists = $false
134137
}
138+
139+
# If the artifact exists and includePlatform or forceRedirection is set, we also need the manifest file
140+
if ($exists -and ($includePlatform -or $forceRedirection) -and (-not (Test-Path $appManifestPath))) {
141+
Remove-Item $appArtifactPath -Recurse -Force
142+
$exists = $false
143+
}
144+
145+
# Test if the manifest file exists and is not corrupt
146+
if ($exists -and (Test-Path $appManifestPath)) {
147+
try {
148+
Get-Content $appManifestPath | ConvertFrom-Json | Out-Null
149+
}
150+
catch {
151+
Write-Host "ERROR: Manifest file is corrupt, removing $appArtifactPath and redownloading"
152+
Remove-Item $appArtifactPath -Recurse -Force
153+
$exists = $false
154+
}
155+
}
156+
135157
if ($exists -and $forceRedirection) {
136-
$appManifestPath = Join-Path $appArtifactPath "manifest.json"
137158
$appManifest = Get-Content $appManifestPath | ConvertFrom-Json
138159
if ($appManifest.PSObject.Properties.name -eq "applicationUrl") {
139160
# redirect artifacts are always downloaded
140161
Remove-Item $appArtifactPath -Recurse -Force
141162
$exists = $false
142163
}
143164
}
165+
144166
if (-not $exists) {
145167
Write-Host "Downloading artifact $($appUri.AbsolutePath)"
146168
DownloadPackage -artifactUrl $artifactUrl -destinationPath $appArtifactPath -timeout $timeout | Out-Null
147169
}
148170
try { [System.IO.File]::WriteAllText((Join-Path $appArtifactPath 'lastused'), "$([datetime]::UtcNow.Ticks)") } catch {}
149171

150-
$appManifestPath = Join-Path $appArtifactPath "manifest.json"
151172
if (Test-Path $appManifestPath) {
152173
$appManifest = Get-Content $appManifestPath | ConvertFrom-Json
153174

ContainerHandling/Flush-ContainerHelperCache.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,19 @@ try {
6363
$exitedDaysAgo = [DateTime]::Now.Subtract($finishedAt).Days
6464
if ($exitedDaysAgo -ge $keepDays) {
6565
if (($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -ne 0 -and $inspect.Config.Labels.maintainer -eq "Dynamics SMB")) {
66-
Write-Host "Removing container $containerName"
67-
docker rm $containerID -f
66+
if ($caches.Contains('algocontainersonly')) {
67+
if ($inspect.Config.Labels.psobject.Properties.Match('creator').Count -ne 0 -and $inspect.Config.Labels.creator -eq "AL-Go") {
68+
Write-Host "Removing AL-Go container $containerName"
69+
docker rm $containerID -f
70+
}
71+
else {
72+
Write-Host "Container $containerName (exited $exitedDaysAgo day$(if($exitedDaysAgo -ne 1){'s'}) ago) is recognized as a Business Central Container, but was not created by AL-Go - not removing"
73+
}
74+
}
75+
else {
76+
Write-Host "Removing container $containerName"
77+
docker rm $containerID -f
78+
}
6879
}
6980
else {
7081
Write-Host "Container $containerName (exited $exitedDaysAgo day$(if($exitedDaysAgo -ne 1){'s'}) ago) is not recognized as a Business Central Container - not removing"

ReleaseNotes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
6.1.8
2+
3+
14
6.1.7
25
Issue 3952 Get-AlLanguageExtensionFromArtifacts fails on new BC artifacts
36
Add support for TestType field when running tests
47
Issue 3943 Error downloading symbols for Microsoft_System
58
Add support for RequiredTestIsolation field when running tests
69
Fix package ID length adjustment logic in Get-BcNuGetPackageId function
10+
Catch errors when page scripting tests are failing
711

812
6.1.6
913
Added a new outcome to failOn = newWarning. For BcContainerHelper it will work as error - in AL-Go for GitHub it will have a meaning.

Tests/GetAndRunTests (version 9).Tests.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ AfterAll {
1616
. (Join-Path $PSScriptRoot '_RemoveNavContainer.ps1')
1717
}
1818

19-
Describe 'AppHandling' {
19+
Describe 'AppHandling' -Skip {
2020

2121
It 'Get/RunTests' {
2222
$artifactUrl = Get-BCArtifactUrl -type OnPrem -version "$runTestsInVersion" -country "w1" -select Latest
@@ -53,4 +53,5 @@ Describe 'AppHandling' {
5353
}
5454
$resultsFile | Should -Exist
5555
}
56-
}
56+
57+
}

Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.1.7-dev
1+
6.1.8-dev

0 commit comments

Comments
 (0)