|
40 | 40 | token: ${{ secrets.CODECOV_TOKEN }} |
41 | 41 | files: ./**/coverage.cobertura.xml |
42 | 42 | fail_ci_if_error: false |
43 | | - |
44 | | - cosmos-emulator: |
45 | | - name: Cosmos Emulator Tests |
46 | | - runs-on: windows-latest |
47 | | - env: |
48 | | - DOTNET_VERSION: '9.0.x' |
49 | | - SOLUTION_FILE: GraphRag.slnx |
50 | | - COSMOS_EMULATOR_CONNECTION_STRING: AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw== |
51 | | - GRAPHRAG_SKIP_TESTCONTAINERS: '1' |
52 | | - |
53 | | - steps: |
54 | | - - name: Checkout |
55 | | - uses: actions/checkout@v5 |
56 | | - |
57 | | - - name: Setup .NET |
58 | | - uses: actions/setup-dotnet@v4 |
59 | | - with: |
60 | | - dotnet-version: ${{ env.DOTNET_VERSION }} |
61 | | - |
62 | | - - name: Install Cosmos DB Emulator |
63 | | - shell: pwsh |
64 | | - run: choco install azure-cosmosdb-emulator --yes --no-progress |
65 | | - |
66 | | - - name: Start Cosmos DB Emulator |
67 | | - shell: pwsh |
68 | | - run: | |
69 | | - $emulatorPath = "${env:ProgramFiles}\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" |
70 | | - if (-not (Test-Path $emulatorPath)) { |
71 | | - throw "Cosmos DB Emulator executable not found at $emulatorPath" |
72 | | - } |
73 | | -
|
74 | | - Start-Process -FilePath $emulatorPath -ArgumentList "/EnablePreview","/NoUI","/DisableTelemetry","/Start" -Wait:$false |
75 | | -
|
76 | | - $certPath = Join-Path $env:TEMP "cosmos-emulator.pem" |
77 | | - $maxAttempts = 60 |
78 | | - for ($attempt = 0; $attempt -lt $maxAttempts; $attempt++) { |
79 | | - try { |
80 | | - Invoke-WebRequest -Uri https://localhost:8081/_explorer/emulator.pem -OutFile $certPath -SkipCertificateCheck |
81 | | - break |
82 | | - } catch { |
83 | | - Start-Sleep -Seconds 2 |
84 | | - } |
85 | | - } |
86 | | -
|
87 | | - if ($attempt -eq $maxAttempts) { |
88 | | - throw "Cosmos DB Emulator did not start within expected time." |
89 | | - } |
90 | | -
|
91 | | - "COSMOS_EMULATOR_CERT_PATH=$certPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
92 | | -
|
93 | | - - name: Import Cosmos Emulator Certificate |
94 | | - shell: pwsh |
95 | | - run: | |
96 | | - $certPemPath = $env:COSMOS_EMULATOR_CERT_PATH |
97 | | - if (-not (Test-Path $certPemPath)) { |
98 | | - throw "Emulator certificate not found at $certPemPath" |
99 | | - } |
100 | | -
|
101 | | - $pemContent = Get-Content $certPemPath -Raw |
102 | | - $certificate = [System.Security.Cryptography.X509Certificates.X509Certificate2]::CreateFromPem($pemContent) |
103 | | - $certBytes = $certificate.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert) |
104 | | - $certFile = Join-Path $env:TEMP "cosmos-emulator.cer" |
105 | | - [System.IO.File]::WriteAllBytes($certFile, $certBytes) |
106 | | -
|
107 | | - Import-Certificate -FilePath $certFile -CertStoreLocation Cert:\LocalMachine\Root | Out-Null |
108 | | -
|
109 | | - - name: Restore dependencies |
110 | | - shell: pwsh |
111 | | - run: dotnet restore $env:SOLUTION_FILE |
112 | | - |
113 | | - - name: Build |
114 | | - shell: pwsh |
115 | | - run: dotnet build $env:SOLUTION_FILE --configuration Release --no-restore |
116 | | - |
117 | | - - name: Test Cosmos scenarios |
118 | | - shell: pwsh |
119 | | - run: dotnet test $env:SOLUTION_FILE --configuration Release --no-build --verbosity normal --filter "Category=Cosmos" |
0 commit comments