From 09899cd455597c997dcaa1a68a1f32a6e7870673 Mon Sep 17 00:00:00 2001 From: Andrii Chebukin Date: Sun, 15 Jun 2025 16:57:11 +0400 Subject: [PATCH 1/5] copilot: add setup steps --- .github/workflows/copilot-setup-steps.yml | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/copilot-setup-steps.yml diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 0000000..496096c --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,50 @@ +name: "Copilot Setup Steps" + +# Automatically run the setup steps when they are changed to allow for easy validation, and +# allow manual testing through the repository's "Actions" tab +on: + workflow_dispatch: + push: + paths: + - .github/workflows/copilot-setup-steps.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + +jobs: + # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. + copilot-setup-steps: + runs-on: windows-2025 + + # Set the permissions to the lowest permissions possible needed for your steps. + # Copilot will be given its own token for its operations. + permissions: + # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete. + contents: read + + # You can define any steps you want, and they will run before the agent starts. + # If you do not check out your code, Copilot will do this for you. + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup necessary dotnet SDKs + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + dotnet-version: | + 9.x + 8.x + + - name: Install Azure Cosmos DB Emulator + run: | + Invoke-WebRequest -Uri https://aka.ms/cosmosdb-emulator -OutFile CosmosDBEmulator.msi + Start-Process msiexec.exe -Wait -ArgumentList '/I CosmosDBEmulator.msi /quiet /qn /norestart' + shell: pwsh + + - name: Start Azure Cosmos DB Emulator using PowerShell module + run: | + Import-Module "C:\Program Files\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator" + Start-CosmosDbEmulator -NoUI -AllowNetworkAccess + Start-Sleep -Seconds 20 + shell: pwsh From 3b3688e6b17cd0888b91e3b691478eb5617f994a Mon Sep 17 00:00:00 2001 From: Andrii Chebukin Date: Fri, 1 Aug 2025 00:22:04 +0400 Subject: [PATCH 2/5] fixup! copilot: add setup steps --- .github/workflows/copilot-setup-steps.yml | 64 +++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 496096c..9d04990 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -38,13 +38,71 @@ jobs: - name: Install Azure Cosmos DB Emulator run: | + Write-Host "Downloading Azure Cosmos DB Emulator..." Invoke-WebRequest -Uri https://aka.ms/cosmosdb-emulator -OutFile CosmosDBEmulator.msi + Write-Host "Installing Azure Cosmos DB Emulator..." Start-Process msiexec.exe -Wait -ArgumentList '/I CosmosDBEmulator.msi /quiet /qn /norestart' + Write-Host "Installation completed." shell: pwsh - - name: Start Azure Cosmos DB Emulator using PowerShell module + - name: Start Azure Cosmos DB Emulator run: | + Write-Host "Importing Cosmos DB Emulator PowerShell module..." Import-Module "C:\Program Files\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator" - Start-CosmosDbEmulator -NoUI -AllowNetworkAccess - Start-Sleep -Seconds 20 + + Write-Host "Starting Cosmos DB Emulator..." + Start-CosmosDbEmulator -NoUI -AllowNetworkAccess -Timeout 600 + + Write-Host "Waiting for emulator to be ready..." + $maxAttempts = 30 + $attempt = 0 + $ready = $false + + while ($attempt -lt $maxAttempts -and -not $ready) { + $attempt++ + Write-Host "Checking emulator status (attempt $attempt/$maxAttempts)..." + + try { + $status = Get-CosmosDbEmulatorStatus + Write-Host "Emulator status: $status" + + if ($status -eq "Running") { + Write-Host "Emulator is running!" + $ready = $true + } else { + Write-Host "Emulator not ready yet, waiting 10 seconds..." + Start-Sleep -Seconds 10 + } + } catch { + Write-Host "Error checking status: $($_.Exception.Message)" + Write-Host "Waiting 10 seconds before retry..." + Start-Sleep -Seconds 10 + } + } + + if (-not $ready) { + Write-Error "Cosmos DB Emulator failed to start within timeout period" + exit 1 + } + + Write-Host "Cosmos DB Emulator is ready!" + shell: pwsh + + - name: Verify Cosmos DB Emulator Connection + run: | + Write-Host "Testing Cosmos DB Emulator connection..." + try { + $response = Invoke-WebRequest -Uri "https://localhost:8081/_explorer/emulator.js" -SkipCertificateCheck -TimeoutSec 30 + if ($response.StatusCode -eq 200) { + Write-Host "? Cosmos DB Emulator is accessible on https://localhost:8081" + } else { + Write-Warning "Cosmos DB Emulator responded with status code: $($response.StatusCode)" + } + } catch { + Write-Warning "Could not verify emulator web interface: $($_.Exception.Message)" + } + + # Display emulator information + $emulatorInfo = Get-CosmosDbEmulatorStatus + Write-Host "Final emulator status: $emulatorInfo" shell: pwsh From 3004976cd57c768f5ddddc6ab423ebd413d0803a Mon Sep 17 00:00:00 2001 From: Andrii Chebukin Date: Fri, 1 Aug 2025 02:09:54 +0400 Subject: [PATCH 3/5] fixup! copilot: add setup steps --- .github/workflows/copilot-setup-steps.yml | 113 +++++++++++++++------- 1 file changed, 77 insertions(+), 36 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 9d04990..9dabb44 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -45,64 +45,105 @@ jobs: Write-Host "Installation completed." shell: pwsh - - name: Start Azure Cosmos DB Emulator + - name: Start Azure Cosmos DB Emulator using direct executable run: | - Write-Host "Importing Cosmos DB Emulator PowerShell module..." - Import-Module "C:\Program Files\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator" + Write-Host "Starting Cosmos DB Emulator using direct executable approach..." - Write-Host "Starting Cosmos DB Emulator..." - Start-CosmosDbEmulator -NoUI -AllowNetworkAccess -Timeout 600 + # Define emulator path + $emulatorPath = "C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" - Write-Host "Waiting for emulator to be ready..." - $maxAttempts = 30 + # Start emulator process directly with optimized settings + Write-Host "Starting emulator process..." + $processArgs = @( + "/NoUI" + "/NoExplorer" + "/DisableRateLimiting" + "/PartitionCount=25" + "/Consistency=Session" + ) + + $process = Start-Process -FilePath $emulatorPath -ArgumentList $processArgs -PassThru -WindowStyle Hidden + Write-Host "Emulator process started with PID: $($process.Id)" + + # Wait for emulator to become responsive + Write-Host "Waiting for emulator to become ready..." + $maxWaitMinutes = 15 + $checkIntervalSeconds = 15 + $maxAttempts = [math]::Floor(($maxWaitMinutes * 60) / $checkIntervalSeconds) $attempt = 0 - $ready = $false + $emulatorReady = $false - while ($attempt -lt $maxAttempts -and -not $ready) { + while ($attempt -lt $maxAttempts -and -not $emulatorReady) { $attempt++ - Write-Host "Checking emulator status (attempt $attempt/$maxAttempts)..." + $elapsedMinutes = [math]::Round(($attempt * $checkIntervalSeconds) / 60, 1) + Write-Host "Checking emulator readiness (attempt $attempt/$maxAttempts, $elapsedMinutes min elapsed)..." try { - $status = Get-CosmosDbEmulatorStatus - Write-Host "Emulator status: $status" - - if ($status -eq "Running") { - Write-Host "Emulator is running!" - $ready = $true - } else { - Write-Host "Emulator not ready yet, waiting 10 seconds..." - Start-Sleep -Seconds 10 + # Check if the emulator endpoint is responding + $response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/" -UseBasicParsing -TimeoutSec 10 -SkipCertificateCheck + if ($response.StatusCode -eq 200) { + Write-Host "? Emulator is responding on HTTPS endpoint!" + $emulatorReady = $true } } catch { - Write-Host "Error checking status: $($_.Exception.Message)" - Write-Host "Waiting 10 seconds before retry..." - Start-Sleep -Seconds 10 + Write-Host "Emulator not ready yet (HTTPS check failed): $($_.Exception.Message)" + } + + if (-not $emulatorReady) { + # Also try to check if the process is still running + try { + $runningProcess = Get-Process -Id $process.Id -ErrorAction Stop + Write-Host "Emulator process is still running (CPU: $($runningProcess.CPU), Memory: $([math]::Round($runningProcess.WorkingSet64/1MB))MB)" + } catch { + Write-Warning "Emulator process appears to have crashed!" + break + } + + Write-Host "Waiting $checkIntervalSeconds seconds before next check..." + Start-Sleep -Seconds $checkIntervalSeconds } } - if (-not $ready) { - Write-Error "Cosmos DB Emulator failed to start within timeout period" + if (-not $emulatorReady) { + Write-Error "Cosmos DB Emulator failed to become ready within $maxWaitMinutes minutes" + + # Try to get some diagnostic information + try { + Write-Host "Checking for any emulator processes..." + Get-Process -Name "*Cosmos*" -ErrorAction SilentlyContinue | ForEach-Object { + Write-Host "Found process: $($_.ProcessName) (PID: $($_.Id))" + } + } catch { + Write-Host "Could not enumerate emulator processes" + } + exit 1 } - Write-Host "Cosmos DB Emulator is ready!" + Write-Host "? Cosmos DB Emulator is ready and responding!" shell: pwsh - name: Verify Cosmos DB Emulator Connection run: | - Write-Host "Testing Cosmos DB Emulator connection..." + Write-Host "Final verification of Cosmos DB Emulator..." + + # Test HTTPS endpoint try { - $response = Invoke-WebRequest -Uri "https://localhost:8081/_explorer/emulator.js" -SkipCertificateCheck -TimeoutSec 30 - if ($response.StatusCode -eq 200) { - Write-Host "? Cosmos DB Emulator is accessible on https://localhost:8081" - } else { - Write-Warning "Cosmos DB Emulator responded with status code: $($response.StatusCode)" - } + $response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/" -UseBasicParsing -SkipCertificateCheck -TimeoutSec 30 + Write-Host "? HTTPS endpoint accessible (Status: $($response.StatusCode))" + } catch { + Write-Warning "HTTPS endpoint test failed: $($_.Exception.Message)" + } + + # Test the data explorer endpoint + try { + $response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/_explorer/emulator.js" -UseBasicParsing -SkipCertificateCheck -TimeoutSec 30 + Write-Host "? Data Explorer endpoint accessible (Status: $($response.StatusCode))" } catch { - Write-Warning "Could not verify emulator web interface: $($_.Exception.Message)" + Write-Warning "Data Explorer endpoint test failed: $($_.Exception.Message)" } - # Display emulator information - $emulatorInfo = Get-CosmosDbEmulatorStatus - Write-Host "Final emulator status: $emulatorInfo" + # Display emulator info + Write-Host "Emulator should be accessible at: https://127.0.0.1:8081" + Write-Host "Primary Key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" shell: pwsh From 0145ef15d9a94f8c8d619b8861b36f0c4ed79165 Mon Sep 17 00:00:00 2001 From: Andrii Chebukin Date: Fri, 1 Aug 2025 02:38:13 +0400 Subject: [PATCH 4/5] fixup! copilot: add setup steps --- .github/workflows/copilot-setup-steps.yml | 50 +++++++++++++++-------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 9dabb44..b3e33b6 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -48,10 +48,10 @@ jobs: - name: Start Azure Cosmos DB Emulator using direct executable run: | Write-Host "Starting Cosmos DB Emulator using direct executable approach..." - + # Define emulator path $emulatorPath = "C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" - + # Start emulator process directly with optimized settings Write-Host "Starting emulator process..." $processArgs = @( @@ -61,10 +61,10 @@ jobs: "/PartitionCount=25" "/Consistency=Session" ) - + $process = Start-Process -FilePath $emulatorPath -ArgumentList $processArgs -PassThru -WindowStyle Hidden Write-Host "Emulator process started with PID: $($process.Id)" - + # Wait for emulator to become responsive Write-Host "Waiting for emulator to become ready..." $maxWaitMinutes = 15 @@ -72,23 +72,33 @@ jobs: $maxAttempts = [math]::Floor(($maxWaitMinutes * 60) / $checkIntervalSeconds) $attempt = 0 $emulatorReady = $false - + while ($attempt -lt $maxAttempts -and -not $emulatorReady) { $attempt++ $elapsedMinutes = [math]::Round(($attempt * $checkIntervalSeconds) / 60, 1) Write-Host "Checking emulator readiness (attempt $attempt/$maxAttempts, $elapsedMinutes min elapsed)..." - + try { # Check if the emulator endpoint is responding + # A 401 Unauthorized response actually means the service is up and running! $response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/" -UseBasicParsing -TimeoutSec 10 -SkipCertificateCheck if ($response.StatusCode -eq 200) { Write-Host "? Emulator is responding on HTTPS endpoint!" $emulatorReady = $true } } catch { - Write-Host "Emulator not ready yet (HTTPS check failed): $($_.Exception.Message)" + # Check if we got a 401 Unauthorized - this actually means the service is ready! + if ($_.Exception.Response.StatusCode -eq 401) { + Write-Host "? Emulator is responding with 401 Unauthorized - service is ready!" + $emulatorReady = $true + } elseif ($_.Exception.Message -like "*401*" -or $_.Exception.Message -like "*Unauthorized*") { + Write-Host "? Emulator is responding with authentication error - service is ready!" + $emulatorReady = $true + } else { + Write-Host "Emulator not ready yet (HTTPS check failed): $($_.Exception.Message)" + } } - + if (-not $emulatorReady) { # Also try to check if the process is still running try { @@ -98,15 +108,15 @@ jobs: Write-Warning "Emulator process appears to have crashed!" break } - + Write-Host "Waiting $checkIntervalSeconds seconds before next check..." Start-Sleep -Seconds $checkIntervalSeconds } } - + if (-not $emulatorReady) { Write-Error "Cosmos DB Emulator failed to become ready within $maxWaitMinutes minutes" - + # Try to get some diagnostic information try { Write-Host "Checking for any emulator processes..." @@ -116,25 +126,29 @@ jobs: } catch { Write-Host "Could not enumerate emulator processes" } - + exit 1 } - + Write-Host "? Cosmos DB Emulator is ready and responding!" shell: pwsh - name: Verify Cosmos DB Emulator Connection run: | Write-Host "Final verification of Cosmos DB Emulator..." - - # Test HTTPS endpoint + + # Test HTTPS endpoint - 401 is expected and means the service is working try { $response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/" -UseBasicParsing -SkipCertificateCheck -TimeoutSec 30 Write-Host "? HTTPS endpoint accessible (Status: $($response.StatusCode))" } catch { - Write-Warning "HTTPS endpoint test failed: $($_.Exception.Message)" + if ($_.Exception.Response.StatusCode -eq 401 -or $_.Exception.Message -like "*401*" -or $_.Exception.Message -like "*Unauthorized*") { + Write-Host "? HTTPS endpoint accessible (Status: 401 Unauthorized - this is expected and correct)" + } else { + Write-Warning "HTTPS endpoint test failed: $($_.Exception.Message)" + } } - + # Test the data explorer endpoint try { $response = Invoke-WebRequest -Uri "https://127.0.0.1:8081/_explorer/emulator.js" -UseBasicParsing -SkipCertificateCheck -TimeoutSec 30 @@ -142,7 +156,7 @@ jobs: } catch { Write-Warning "Data Explorer endpoint test failed: $($_.Exception.Message)" } - + # Display emulator info Write-Host "Emulator should be accessible at: https://127.0.0.1:8081" Write-Host "Primary Key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" From 159f8ce48fa5c623f5a820b108b292c20143a2f3 Mon Sep 17 00:00:00 2001 From: Andrii Chebukin Date: Fri, 8 Aug 2025 15:25:53 +0400 Subject: [PATCH 5/5] fixup! copilot: add setup steps --- .github/workflows/copilot-setup-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index b3e33b6..86f6024 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -29,7 +29,7 @@ jobs: uses: actions/checkout@v4 - name: Setup necessary dotnet SDKs - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: global-json-file: global.json dotnet-version: |