name: tests

on:
  pull_request:
    types: [opened, synchronize]
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    strategy:
      matrix:
        node-version: ["10", "12", "14"]

    name: Testing on Node.js ${{ matrix.node }}
    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
      - uses: harmon758/postgresql-action@v1
        with:
          postgresql version: "12"
          postgresql user: "user"
          postgresql password: "password"

      - run: npm ci
      - run: npm test
        env:
          CI: true
          NODE_ENV: test
          PG_CONNECTION_STRING: "postgresql://user:password@localhost"
