name: tests-windows
on:
  workflow_call:
    inputs:
      node-version:
        required: true
        type: number

jobs:
  better-sqlite3:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ inputs.node-version }}
          cache: "npm"
      - uses: actions/download-artifact@v4
        with:
          name: build
          path: build/

      - run: npm ci
      - run: cp .github/workflows/test/better-sqlite3.ormconfig.json ormconfig.json
      - run: npx nyc npm run test:ci

      - name: Coveralls Parallel
        uses: coverallsapp/github-action@v2
        with:
          flag-name: better-sqlite3-node:${{ inputs.node-version }}-windows
          parallel: true

  sqlite:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ inputs.node-version }}
          cache: "npm"
      - uses: actions/download-artifact@v4
        with:
          name: build
          path: build/

      - run: npm ci
      - run: cp .github/workflows/test/sqlite.ormconfig.json ormconfig.json
      - run: npx nyc npm run test:ci

      - name: Coveralls Parallel
        uses: coverallsapp/github-action@v2
        with:
          flag-name: sqlite-node:${{ inputs.node-version }}-windows
          parallel: true

  sqljs:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ inputs.node-version }}
          cache: "npm"
      - uses: actions/download-artifact@v4
        with:
          name: build
          path: build/

      - run: npm ci
      - run: cp .github/workflows/test/sqljs.ormconfig.json ormconfig.json
      - run: npx nyc npm run test:ci

      - name: Coveralls Parallel
        uses: coverallsapp/github-action@v2
        with:
          flag-name: sqljs-node:${{ inputs.node-version }}-windows
          parallel: true
