name: Encryption Tests

on:
  pull_request:
    paths:
      - ".github/workflows/encryption-tests.yml"
      - "package.json"
      - "index.js"
      - "lib/**"
      - "test/encryption/**.js"
      - "scripts/setup-encryption-tests.js"
  push:
    paths:
      - ".github/workflows/encryption-tests.yml"
      - "package.json"
      - "index.js"
      - "lib/**"
      - "test/encryption/**.js"
      - "scripts/setup-encryption-tests.js"
  workflow_dispatch: {}

permissions:
  contents: write
  pull-requests: write
  id-token: write

jobs:
  run-tests:
    permissions:
      # required for all workflows
      security-events: write
      id-token: write
      contents: write
    runs-on: ubuntu-latest
    name: Encryption tests
    env:
      FORCE_COLOR: true
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - name: Setup node
        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
        with:
          node-version: 22
      - name: Install Dependencies
        run: npm install
      - name: Install mongodb-client-encryption
        run: npm install mongodb-client-encryption
      - name: Run setup scripts for mongodb-client-encryption
        run: pushd node_modules/mongodb-client-encryption && npm run install && popd
      - name: Setup Tests
        run: npm run setup-test-encryption
      - name: Run Tests
        run: npm run test-encryption:ci