name: Rust

on: [push, pull_request]

jobs:
  build:
    name: Run tests on Ubuntu
    runs-on: ubuntu-latest

    # Database services used for testing
    services:
      # Microsoft SQL Server
      sqlserver:
        image: mcr.microsoft.com/mssql/server:2019-latest
        ports:
        - 1433:1433
        env:
          ACCEPT_EULA: Y
          SA_PASSWORD: My@Test@Password1

      postgres:
        image: postgres:13
        ports:
          - "5432:5432"
        env:
          POSTGRES_DB: test
          POSTGRES_USER: test
          POSTGRES_PASSWORD: test

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install PostgreSQL Driver
        run: |
          sudo apt-get install -y unixodbc-dev odbc-postgresql devscripts
          # Fix PostgreSQL driver paths
          sed --in-place 's/psqlodbca.so/\/usr\/lib\/x86_64-linux-gnu\/odbc\/psqlodbca.so/' /etc/odbcinst.ini
          sed --in-place 's/psqlodbcw.so/\/usr\/lib\/x86_64-linux-gnu\/odbc\/psqlodbcw.so/' /etc/odbcinst.ini
        shell: sudo bash {0}

      - name: Test
        run: |
          # Parquet tooling is used to verify output of this tool in tests
          cargo install parquet --features cli
          # Run test suite
          cargo test
