Skip to content

Commit 55c6074

Browse files
committed
fixup! copilot: add setup steps
1 parent 99e4743 commit 55c6074

File tree

1 file changed

+77
-36
lines changed

1 file changed

+77
-36
lines changed

.github/workflows/copilot-setup-steps.yml

Lines changed: 77 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,64 +45,105 @@ jobs:
4545
Write-Host "Installation completed."
4646
shell: pwsh
4747

48-
- name: Start Azure Cosmos DB Emulator
48+
- name: Start Azure Cosmos DB Emulator using direct executable
4949
run: |
50-
Write-Host "Importing Cosmos DB Emulator PowerShell module..."
51-
Import-Module "C:\Program Files\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
50+
Write-Host "Starting Cosmos DB Emulator using direct executable approach..."
5251
53-
Write-Host "Starting Cosmos DB Emulator..."
54-
Start-CosmosDbEmulator -NoUI -AllowNetworkAccess -Timeout 600
52+
# Define emulator path
53+
$emulatorPath = "C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe"
5554
56-
Write-Host "Waiting for emulator to be ready..."
57-
$maxAttempts = 30
55+
# Start emulator process directly with optimized settings
56+
Write-Host "Starting emulator process..."
57+
$processArgs = @(
58+
"/NoUI"
59+
"/NoExplorer"
60+
"/DisableRateLimiting"
61+
"/PartitionCount=25"
62+
"/Consistency=Session"
63+
)
64+
65+
$process = Start-Process -FilePath $emulatorPath -ArgumentList $processArgs -PassThru -WindowStyle Hidden
66+
Write-Host "Emulator process started with PID: $($process.Id)"
67+
68+
# Wait for emulator to become responsive
69+
Write-Host "Waiting for emulator to become ready..."
70+
$maxWaitMinutes = 15
71+
$checkIntervalSeconds = 15
72+
$maxAttempts = [math]::Floor(($maxWaitMinutes * 60) / $checkIntervalSeconds)
5873
$attempt = 0
59-
$ready = $false
74+
$emulatorReady = $false
6075
61-
while ($attempt -lt $maxAttempts -and -not $ready) {
76+
while ($attempt -lt $maxAttempts -and -not $emulatorReady) {
6277
$attempt++
63-
Write-Host "Checking emulator status (attempt $attempt/$maxAttempts)..."
78+
$elapsedMinutes = [math]::Round(($attempt * $checkIntervalSeconds) / 60, 1)
79+
Write-Host "Checking emulator readiness (attempt $attempt/$maxAttempts, $elapsedMinutes min elapsed)..."
6480
6581
try {
66-
$status = Get-CosmosDbEmulatorStatus
67-
Write-Host "Emulator status: $status"
68-
69-
if ($status -eq "Running") {
70-
Write-Host "Emulator is running!"
71-
$ready = $true
72-
} else {
73-
Write-Host "Emulator not ready yet, waiting 10 seconds..."
74-
Start-Sleep -Seconds 10
82+
# Check if the emulator endpoint is responding
83+
$response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/" -UseBasicParsing -TimeoutSec 10 -SkipCertificateCheck
84+
if ($response.StatusCode -eq 200) {
85+
Write-Host "? Emulator is responding on HTTPS endpoint!"
86+
$emulatorReady = $true
7587
}
7688
} catch {
77-
Write-Host "Error checking status: $($_.Exception.Message)"
78-
Write-Host "Waiting 10 seconds before retry..."
79-
Start-Sleep -Seconds 10
89+
Write-Host "Emulator not ready yet (HTTPS check failed): $($_.Exception.Message)"
90+
}
91+
92+
if (-not $emulatorReady) {
93+
# Also try to check if the process is still running
94+
try {
95+
$runningProcess = Get-Process -Id $process.Id -ErrorAction Stop
96+
Write-Host "Emulator process is still running (CPU: $($runningProcess.CPU), Memory: $([math]::Round($runningProcess.WorkingSet64/1MB))MB)"
97+
} catch {
98+
Write-Warning "Emulator process appears to have crashed!"
99+
break
100+
}
101+
102+
Write-Host "Waiting $checkIntervalSeconds seconds before next check..."
103+
Start-Sleep -Seconds $checkIntervalSeconds
80104
}
81105
}
82106
83-
if (-not $ready) {
84-
Write-Error "Cosmos DB Emulator failed to start within timeout period"
107+
if (-not $emulatorReady) {
108+
Write-Error "Cosmos DB Emulator failed to become ready within $maxWaitMinutes minutes"
109+
110+
# Try to get some diagnostic information
111+
try {
112+
Write-Host "Checking for any emulator processes..."
113+
Get-Process -Name "*Cosmos*" -ErrorAction SilentlyContinue | ForEach-Object {
114+
Write-Host "Found process: $($_.ProcessName) (PID: $($_.Id))"
115+
}
116+
} catch {
117+
Write-Host "Could not enumerate emulator processes"
118+
}
119+
85120
exit 1
86121
}
87122
88-
Write-Host "Cosmos DB Emulator is ready!"
123+
Write-Host "? Cosmos DB Emulator is ready and responding!"
89124
shell: pwsh
90125

91126
- name: Verify Cosmos DB Emulator Connection
92127
run: |
93-
Write-Host "Testing Cosmos DB Emulator connection..."
128+
Write-Host "Final verification of Cosmos DB Emulator..."
129+
130+
# Test HTTPS endpoint
94131
try {
95-
$response = Invoke-WebRequest -Uri "https://localhost:8081/_explorer/emulator.js" -SkipCertificateCheck -TimeoutSec 30
96-
if ($response.StatusCode -eq 200) {
97-
Write-Host "? Cosmos DB Emulator is accessible on https://localhost:8081"
98-
} else {
99-
Write-Warning "Cosmos DB Emulator responded with status code: $($response.StatusCode)"
100-
}
132+
$response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/" -UseBasicParsing -SkipCertificateCheck -TimeoutSec 30
133+
Write-Host "? HTTPS endpoint accessible (Status: $($response.StatusCode))"
134+
} catch {
135+
Write-Warning "HTTPS endpoint test failed: $($_.Exception.Message)"
136+
}
137+
138+
# Test the data explorer endpoint
139+
try {
140+
$response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/_explorer/emulator.js" -UseBasicParsing -SkipCertificateCheck -TimeoutSec 30
141+
Write-Host "? Data Explorer endpoint accessible (Status: $($response.StatusCode))"
101142
} catch {
102-
Write-Warning "Could not verify emulator web interface: $($_.Exception.Message)"
143+
Write-Warning "Data Explorer endpoint test failed: $($_.Exception.Message)"
103144
}
104145
105-
# Display emulator information
106-
$emulatorInfo = Get-CosmosDbEmulatorStatus
107-
Write-Host "Final emulator status: $emulatorInfo"
146+
# Display emulator info
147+
Write-Host "Emulator should be accessible at: https://127.0.0.1:8081"
148+
Write-Host "Primary Key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
108149
shell: pwsh

0 commit comments

Comments
 (0)