Skip to content

Commit dfe3269

Browse files
authored
Merge pull request #248 from microsoft/user/dluces/sample_app_test_plan
Add validation scripts for all sample apps
2 parents 557aa67 + 876ecbd commit dfe3269

68 files changed

Lines changed: 8804 additions & 436 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ bld/
4040
# Visual Studio 2017 auto generated files
4141
Generated\ Files/
4242

43+
# Local validation logs
44+
**/.validation/
45+
4346
# MSTest test Results
4447
[Tt]est[Rr]esult*/
4548
[Bb]uild[Ll]og.*

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"githubPullRequests.ignoredPullRequestBranches": [
33
"main"
4-
]
4+
],
5+
"files.eol": "\n"
56
}

AI/mcp-server/package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AI/mcp-server/validate-sample.ps1

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
param(
2+
[switch]$SkipInstall,
3+
[switch]$SkipTests,
4+
[switch]$SkipBrowser,
5+
[switch]$KeepProcesses,
6+
[switch]$Headed,
7+
[int]$TimeoutSec = 90
8+
)
9+
10+
Set-StrictMode -Version Latest
11+
$ErrorActionPreference = 'Stop'
12+
13+
. (Join-Path $PSScriptRoot '../../Tools/powershell/SampleValidation.ps1')
14+
15+
$appRoot = $PSScriptRoot
16+
$envFile = Join-Path $appRoot '.env'
17+
$nodeEnvironment = Get-ValidationNodeEnvironment
18+
$runtimeHandle = $null
19+
20+
try {
21+
Write-Step 'Preflight checks'
22+
Assert-CommandExists 'node'
23+
Assert-CommandExists 'npm'
24+
25+
if (-not $SkipInstall) {
26+
Write-Step 'Installing dependencies'
27+
Invoke-ExternalCommand -FilePath 'npm' -Arguments @('install') -WorkingDirectory $appRoot -Environment $nodeEnvironment
28+
}
29+
30+
Write-Step 'Building MCP server'
31+
Invoke-ExternalCommand -FilePath 'npm' -Arguments @('run', 'build') -WorkingDirectory $appRoot -Environment $nodeEnvironment
32+
33+
if ($SkipTests) {
34+
Write-Host 'Skipping tests because -SkipTests was specified.' -ForegroundColor Yellow
35+
}
36+
else {
37+
Write-Host 'No automated test script is defined for this sample.' -ForegroundColor Yellow
38+
}
39+
40+
if (-not (Test-Path $envFile)) {
41+
Write-Host 'Skipping runtime smoke check because .env is missing.' -ForegroundColor Yellow
42+
Write-ValidationSummary -Status 'SKIP_CONFIG' -Message 'Build validation passed; runtime smoke skipped because .env is missing.'
43+
return
44+
}
45+
46+
$environment = Get-DotEnvMap -Path $envFile
47+
if (-not $environment.ContainsKey('PORT')) {
48+
$environment['PORT'] = '3100'
49+
}
50+
51+
Write-Step 'Starting MCP server'
52+
$logPath = New-ValidationLogPath -WorkingDirectory $appRoot -Name 'mcp-server'
53+
$runtimeHandle = Start-LoggedProcess -FilePath 'npm' -Arguments @('run', 'start') -WorkingDirectory $appRoot -LogPath $logPath -Environment (Merge-EnvironmentTables @($nodeEnvironment, $environment))
54+
55+
$healthUrl = "http://localhost:$($environment['PORT'])/health"
56+
$healthResponse = Wait-ForHttpEndpoint -Url $healthUrl -TimeoutSec $TimeoutSec -AllowedStatusCodes @(200) -ProcessHandle $runtimeHandle
57+
$body = [string]$healthResponse.Content
58+
if ($body -notmatch '"status"\s*:\s*"ok"') {
59+
throw "Health endpoint returned an unexpected response: $body"
60+
}
61+
62+
Write-Host "Runtime smoke check passed at $healthUrl" -ForegroundColor Green
63+
Write-ValidationSummary -Status 'PASS' -Message "Build and runtime smoke checks passed at $healthUrl."
64+
}
65+
catch {
66+
Write-ValidationSummary -Status 'FAIL' -Message $_.Exception.Message
67+
throw
68+
}
69+
finally {
70+
if ($null -ne $runtimeHandle -and -not $KeepProcesses) {
71+
Stop-LoggedProcess -Handle $runtimeHandle
72+
}
73+
}

AI/ocr/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
# production
1212
/build
13+
**/.dist/*.js
14+
**/.dist/**/*.js
1315

1416
# misc
1517
.DS_Store

0 commit comments

Comments
 (0)