name: database-tests

on:
  workflow_call:
    inputs:
      node-version:
        required: true
        type: string

jobs:
  oracle:
    # For some reason nyc is stuck at the end of the test execution even if all tests pass
    # Probably that's why the job failed on CircleCI
    if: ${{inputs.node-version != '16.x'}}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false

    steps:
      - uses: actions/setup-node@v4
        with:
          node-version: ${{inputs.node-version}}
      - uses: actions/checkout@v4
      - run: docker compose -f .github/workflows/test/oracle.docker-compose up -d
      - run: npm i
      - run: cp .github/workflows/test/oracle.ormconfig.json ormconfig.json
      - run: npx nyc npm run test
      - name: Coveralls Parallel
        uses: coverallsapp/github-action@v2
        with:
          flag-name: oracle-${{ inputs.node-version }}
          parallel: true
