diff --git a/.github/workflows/dotnet-build-and-test.yml b/.github/workflows/dotnet-build-and-test.yml
index a04160af76..692f3e7c45 100644
--- a/.github/workflows/dotnet-build-and-test.yml
+++ b/.github/workflows/dotnet-build-and-test.yml
@@ -35,7 +35,8 @@ jobs:
contents: read
pull-requests: read
outputs:
- dotnetChanges: ${{ steps.filter.outputs.dotnet}}
+ dotnetChanges: ${{ steps.filter.outputs.dotnet }}
+ cosmosDbChanges: ${{ steps.filter.outputs.cosmosdb }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v3
@@ -44,10 +45,15 @@ jobs:
filters: |
dotnet:
- 'dotnet/**'
+ cosmosdb:
+ - 'dotnet/src/Microsoft.Agents.AI.CosmosNoSql/**'
# run only if 'dotnet' files were changed
- name: dotnet tests
if: steps.filter.outputs.dotnet == 'true'
run: echo "Dotnet file"
+ - name: dotnet CosmosDB tests
+ if: steps.filter.outputs.cosmosdb == 'true'
+ run: echo "Dotnet CosmosDB changes"
# run only if not 'dotnet' files were changed
- name: not dotnet tests
if: steps.filter.outputs.dotnet != 'true'
@@ -77,6 +83,16 @@ jobs:
dotnet
python
workflow-samples
+
+ # Start Cosmos DB Emulator for all integration tests and only for unit tests when CosmosDB changes happened)
+ - name: Start Azure Cosmos DB Emulator
+ if: ${{ runner.os == 'Windows' && (needs.paths-filter.outputs.cosmosDbChanges == 'true' || (github.event_name != 'pull_request' && matrix.integration-tests)) }}
+ shell: pwsh
+ run: |
+ Write-Host "Launching Azure Cosmos DB Emulator"
+ Import-Module "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
+ Start-CosmosDbEmulator -NoUI -Key "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
+ echo "COSMOS_EMULATOR_AVAILABLE=true" >> $env:GITHUB_ENV
- name: Setup dotnet
uses: actions/setup-dotnet@v5.0.1
@@ -123,17 +139,7 @@ jobs:
popd
popd
rm -rf "$TEMP_DIR"
-
- # Start Cosmos DB Emulator for Cosmos-based unit tests (only on Windows)
- - name: Start Azure Cosmos DB Emulator
- if: runner.os == 'Windows'
- shell: pwsh
- run: |
- Write-Host "Launching Azure Cosmos DB Emulator"
- Import-Module "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
- Start-CosmosDbEmulator -NoUI -Key "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
- echo "COSMOS_EMULATOR_AVAILABLE=true" >> $env:GITHUB_ENV
-
+
- name: Run Unit Tests
shell: bash
run: |
diff --git a/dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosCheckpointStore.cs b/dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosCheckpointStore.cs
index 62987b1dfc..e0073feaf9 100644
--- a/dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosCheckpointStore.cs
+++ b/dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosCheckpointStore.cs
@@ -217,9 +217,7 @@ protected virtual void Dispose(bool disposing)
}
}
- ///
- /// Represents a checkpoint document stored in Cosmos DB.
- ///
+ /// Represents a checkpoint document stored in Cosmos DB.
internal sealed class CosmosCheckpointDocument
{
[JsonProperty("id")]
diff --git a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatMessageStoreTests.cs b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatMessageStoreTests.cs
index 7ce0611c99..3dbd3ec367 100644
--- a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatMessageStoreTests.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatMessageStoreTests.cs
@@ -10,7 +10,6 @@
using Azure.Identity;
using Microsoft.Azure.Cosmos;
using Microsoft.Extensions.AI;
-using Xunit;
namespace Microsoft.Agents.AI.CosmosNoSql.UnitTests;
@@ -59,6 +58,9 @@ public sealed class CosmosChatMessageStoreTests : IAsyncLifetime, IDisposable
public async Task InitializeAsync()
{
+ // Fail fast if emulator is not available
+ this.SkipIfEmulatorNotAvailable();
+
// Check environment variable to determine if we should preserve containers
// Set COSMOS_PRESERVE_CONTAINERS=true to keep containers and data for inspection
this._preserveContainer = string.Equals(Environment.GetEnvironmentVariable("COSMOS_PRESERVE_CONTAINERS"), "true", StringComparison.OrdinalIgnoreCase);
diff --git a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs
index 8f5749b187..dc75b34758 100644
--- a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs
@@ -7,7 +7,6 @@
using Microsoft.Agents.AI.Workflows;
using Microsoft.Agents.AI.Workflows.Checkpointing;
using Microsoft.Azure.Cosmos;
-using Xunit;
namespace Microsoft.Agents.AI.CosmosNoSql.UnitTests;
@@ -58,6 +57,9 @@ private static JsonSerializerOptions CreateJsonOptions()
public async Task InitializeAsync()
{
+ // Fail fast if emulator is not available
+ this.SkipIfEmulatorNotAvailable();
+
// Check environment variable to determine if we should preserve containers
// Set COSMOS_PRESERVE_CONTAINERS=true to keep containers and data for inspection
this._preserveContainer = string.Equals(Environment.GetEnvironmentVariable("COSMOS_PRESERVE_CONTAINERS"), "true", StringComparison.OrdinalIgnoreCase);