add metrics #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright (c) Microsoft Corporation. | |
| # Licensed under the MIT License. | |
| name: E2E - Node.js LangChain | |
| on: | |
| workflow_call: # Allow orchestrator to call this workflow | |
| workflow_dispatch: # Allow manual triggering | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'nodejs/langchain/**' | |
| - 'scripts/e2e/**' | |
| - '.github/workflows/e2e-nodejs-langchain.yml' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'nodejs/langchain/**' | |
| - 'scripts/e2e/**' | |
| permissions: | |
| contents: read | |
| env: | |
| SAMPLE_PATH: nodejs/langchain/sample-agent | |
| AGENT_PORT: 3979 | |
| SCRIPTS_PATH: scripts/e2e | |
| E2E_TESTS_PATH: tests/e2e | |
| jobs: | |
| nodejs-langchain: | |
| name: Node.js LangChain Agent | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| working-directory: ${{ env.SAMPLE_PATH }} | |
| run: | | |
| if (Test-Path "package-lock.json") { | |
| npm ci | |
| } else { | |
| npm install | |
| } | |
| if (Test-Path "tsconfig.json") { | |
| npm run build | |
| } | |
| shell: pwsh | |
| - name: Log SDK Versions | |
| shell: pwsh | |
| run: | | |
| & "${{ env.SCRIPTS_PATH }}/Get-SDKVersions.ps1" ` | |
| -Runtime "nodejs" ` | |
| -WorkingDirectory "${{ env.SAMPLE_PATH }}" | |
| - name: Acquire Bearer Token (ROPC) | |
| id: token | |
| shell: pwsh | |
| run: | | |
| $token = & "${{ env.SCRIPTS_PATH }}/Acquire-BearerToken.ps1" ` | |
| -ClientId "${{ secrets.MCP_CLIENT_ID }}" ` | |
| -TenantId "${{ secrets.MCP_TENANT_ID }}" ` | |
| -Username "${{ secrets.MCP_TEST_USERNAME }}" ` | |
| -Password "${{ secrets.MCP_TEST_PASSWORD }}" | |
| echo "BEARER_TOKEN=$token" >> $env:GITHUB_OUTPUT | |
| echo "::add-mask::$token" | |
| - name: Copy ToolingManifest.json | |
| shell: pwsh | |
| run: | | |
| & "${{ env.SCRIPTS_PATH }}/Copy-ToolingManifest.ps1" -TargetPath "${{ env.SAMPLE_PATH }}" | |
| - name: Generate .env configuration | |
| shell: pwsh | |
| run: | | |
| $configMappings = @{ | |
| "NODE_ENV" = "development" | |
| "AZURE_OPENAI_API_KEY" = "${{ secrets.NODEJS_OPENAI_AZURE_OPENAI_API_KEY }}" | |
| "AZURE_OPENAI_ENDPOINT" = "${{ secrets.NODEJS_OPENAI_AZURE_OPENAI_ENDPOINT }}" | |
| "AZURE_OPENAI_DEPLOYMENT" = "${{ secrets.NODEJS_OPENAI_AZURE_OPENAI_DEPLOYMENT }}" | |
| "AZURE_OPENAI_API_VERSION" = "2024-12-01-preview" | |
| "connections__service_connection__settings__authType" = "ClientSecret" | |
| "connections__service_connection__settings__clientId" = "${{ secrets.NODEJS_OPENAI_AGENT_ID }}" | |
| "connections__service_connection__settings__clientSecret" = "${{ secrets.NODEJS_OPENAI_CLIENT_SECRET }}" | |
| "connections__service_connection__settings__tenantId" = "${{ secrets.TENANT_ID }}" | |
| "connectionsMap__0__serviceUrl" = "*" | |
| "connectionsMap__0__connection" = "service_connection" | |
| "agentic_scopes" = "ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/.default" | |
| } | |
| & "${{ env.SCRIPTS_PATH }}/Generate-EnvConfig.ps1" ` | |
| -OutputPath "${{ env.SAMPLE_PATH }}/.env" ` | |
| -BearerToken "${{ steps.token.outputs.BEARER_TOKEN }}" ` | |
| -Port ${{ env.AGENT_PORT }} ` | |
| -ConfigMappings $configMappings | |
| - name: Start Agent | |
| id: start-agent | |
| shell: pwsh | |
| run: | | |
| $agentPid = & "${{ env.SCRIPTS_PATH }}/Start-Agent.ps1" ` | |
| -AgentPath "${{ env.SAMPLE_PATH }}" ` | |
| -StartCommand "node dist/index.js" ` | |
| -Port ${{ env.AGENT_PORT }} ` | |
| -BearerToken "${{ steps.token.outputs.BEARER_TOKEN }}" ` | |
| -Environment "Development" ` | |
| -Runtime "nodejs" | |
| echo "AGENT_PID=$agentPid" >> $env:GITHUB_OUTPUT | |
| - name: Verify Agent Running | |
| shell: pwsh | |
| run: | | |
| $agentPid = "${{ steps.start-agent.outputs.AGENT_PID }}" | |
| if ($agentPid) { | |
| try { | |
| $proc = Get-Process -Id $agentPid -ErrorAction Stop | |
| Write-Host "Agent process (PID: $agentPid) is running: $($proc.ProcessName)" -ForegroundColor Green | |
| } catch { | |
| Write-Host "ERROR: Agent process (PID: $agentPid) is NOT running!" -ForegroundColor Red | |
| throw "Agent process has stopped" | |
| } | |
| } | |
| $agentUrl = "http://localhost:${{ env.AGENT_PORT }}" | |
| $healthResponse = Invoke-WebRequest -Uri "$agentUrl/api/health" -Method GET -UseBasicParsing -ErrorAction SilentlyContinue | |
| Write-Host "Health check: $($healthResponse.StatusCode)" -ForegroundColor Green | |
| - name: Restore E2E Test Dependencies | |
| run: dotnet restore "${{ env.E2E_TESTS_PATH }}/Agent365.E2E.Tests.csproj" | |
| - name: Run .NET E2E Tests | |
| shell: pwsh | |
| run: | | |
| dotnet test "${{ env.E2E_TESTS_PATH }}/Agent365.E2E.Tests.csproj" ` | |
| --no-restore ` | |
| --verbosity normal ` | |
| --logger "console;verbosity=detailed" ` | |
| --logger "trx;LogFileName=test-results-nodejs-langchain.trx" ` | |
| --filter "Category=HTTP" | |
| env: | |
| AGENT_URL: http://localhost:${{ env.AGENT_PORT }} | |
| TEST_RESULTS_DIR: ${{ runner.temp }}/TestConversations | |
| - name: Emit Test Conversations | |
| if: always() | |
| shell: pwsh | |
| run: | | |
| & "${{ env.SCRIPTS_PATH }}/Emit-TestConversations.ps1" ` | |
| -TestResultsDir "${{ runner.temp }}/TestConversations" | |
| - name: Capture Agent Logs | |
| if: always() | |
| shell: pwsh | |
| run: | | |
| & "${{ env.SCRIPTS_PATH }}/Capture-AgentLogs.ps1" ` | |
| -AgentPath "${{ env.SAMPLE_PATH }}" | |
| - name: Stop Agent Process | |
| if: always() | |
| shell: pwsh | |
| run: | | |
| $agentPid = "${{ steps.start-agent.outputs.AGENT_PID }}" | |
| if ($agentPid) { | |
| & "${{ env.SCRIPTS_PATH }}/Stop-AgentProcess.ps1" -AgentPID $agentPid | |
| } | |
| - name: Upload Test Results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-nodejs-langchain | |
| path: | | |
| ${{ env.E2E_TESTS_PATH }}/TestResults/**/*.trx | |
| ${{ env.E2E_TESTS_PATH }}/TestResults/**/*-logs.txt | |
| retention-days: 7 |