diff --git a/.github/workflows/linux-cosmos-emulator-test.yml b/.github/workflows/linux-cosmos-emulator-test.yml new file mode 100644 index 0000000..415db2c --- /dev/null +++ b/.github/workflows/linux-cosmos-emulator-test.yml @@ -0,0 +1,84 @@ +name: Linux .NET test with Cosmos DB Emulator +on: + workflow_dispatch: + pull_request: + branches: [ "main" ] + paths: + - 'Extensions/Cosmos/**' + - '.github/workflows/linux-cosmos-emulator-test.yml' + +jobs: + cosmos_tests_linux: + name: Run Cosmos .NET unit tests on Linux (${{ matrix.emulator_version.name }}) + runs-on: ubuntu-latest + strategy: + matrix: + emulator_version: [ + { + name: "current", + image: "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest", + allow_failure: false + }, + { + name: "vnext", + image: "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview", + allow_failure: true + } + ] + fail-fast: false + continue-on-error: ${{ matrix.emulator_version.allow_failure }} + services: + cosmos-emulator: + image: ${{ matrix.emulator_version.image }} + ports: + - 8081:8081 + - 10251:10251 + - 10252:10252 + - 10253:10253 + - 10254:10254 + env: + AZURE_COSMOS_EMULATOR_PARTITION_COUNT: 10 + AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE: false + AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE: 127.0.0.1 + options: >- + --health-cmd="curl -f -k https://127.0.0.1:8081/_explorer/emulator.pem || exit 1" + --health-interval=30s + --health-timeout=10s + --health-retries=10 + steps: + - name: Checkout (GitHub) + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --no-restore + + - name: Wait for Cosmos Emulator + run: | + echo "Waiting for Cosmos DB Emulator (${{ matrix.emulator_version.name }}) to be ready..." + timeout 300 bash -c 'until curl -f -k https://127.0.0.1:8081/_explorer/emulator.pem; do sleep 5; done' + echo "Cosmos DB Emulator is ready!" + + - name: Import Cosmos Emulator Certificate + run: | + curl -k https://127.0.0.1:8081/_explorer/emulator.pem > ~/emulatorcert.crt + sudo cp ~/emulatorcert.crt /usr/local/share/ca-certificates/ + sudo update-ca-certificates + + - name: Run Cosmos Extension Tests + run: | + echo "Running Cosmos extension unit tests with emulator connection (${{ matrix.emulator_version.name }})..." + echo "Cosmos_Endpoint: $Cosmos_Endpoint" + echo "Testing connectivity to emulator..." + curl -k -s https://127.0.0.1:8081/_explorer/index.html > /dev/null && echo "Emulator is responding" || echo "Warning: Emulator may not be fully ready" + dotnet test ./Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension.UnitTests/ --no-build --verbosity normal + env: + Cosmos_Endpoint: https://127.0.0.1:8081/ + Cosmos_Key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw== \ No newline at end of file