diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a8ca8df..09a42af5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,16 +94,6 @@ jobs: - name: Run tests run: npm test - - name: Run integration tests - env: - AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} - AZURE_OPENAI_ENDPOINT: ${{ vars.AZURE_OPENAI_ENDPOINT }} - AZURE_OPENAI_DEPLOYMENT: ${{ vars.AZURE_OPENAI_DEPLOYMENT }} - AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }} - ENABLE_OBSERVABILITY: ${{ vars.ENABLE_OBSERVABILITY }} - run: | - npm run test:integration - - name: Pack packages run: npm run pack @@ -123,3 +113,60 @@ jobs: # run: npm publish # env: # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + integration-tests: + name: Integration tests + needs: [nodejs-sdk] + # Pull request workflows can be edited by the PR author, so the Azure OpenAI key lives in the + # integration-tests environment, which only allows deployments from main. + if: github.event_name == 'push' + runs-on: ubuntu-latest + environment: integration-tests + permissions: + contents: read + + strategy: + matrix: + node-version: ['18', '20'] + + steps: + - name: Checkout repository + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + fetch-depth: 0 + + - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0 + name: Install pnpm + with: + run_install: false + + - name: Set up Node.js ${{ matrix.node-version }} + uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + cache-dependency-path: '**/pnpm-lock.yaml' + + - name: Setup pnpm + uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0 + with: + version: 10.20.0 + + - name: Install dependencies + run: pnpm i + + - name: Set version with Nerdbank.GitVersioning + run: node setVersion.js + + - name: Build package + run: npm run build + + - name: Run integration tests + env: + AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} + AZURE_OPENAI_ENDPOINT: ${{ vars.AZURE_OPENAI_ENDPOINT }} + AZURE_OPENAI_DEPLOYMENT: ${{ vars.AZURE_OPENAI_DEPLOYMENT }} + AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }} + ENABLE_OBSERVABILITY: ${{ vars.ENABLE_OBSERVABILITY }} + run: | + npm run test:integration