# CircleCI config for automated test builds triggered from Github.
version: 2
jobs:
  build:
    docker:
      - image: postgres:latest
    steps:
      - checkout
      - run:
          name: Install
          command: apt update && apt install -y python g++ libpq-dev postgresql build-essential make autoconf dh-autoreconf autoconf-archive automake
      - run:
          name: Prepare postgres
          command: |
              mkdir /tmp/db &&
              chown postgres /tmp/db &&
              su postgres -c '/usr/lib/postgresql/*/bin/initdb --pgdata /tmp/db --auth trust --nosync'
      - run:
          name: Run postgres
          command: (su postgres -c '/usr/lib/postgresql/*/bin/postgres -D /tmp/db -k /tmp' &) && sleep 5
      - run:
          name: Create postgres user
          command: su postgres -c "createuser -w -d -h /tmp root"
      - run:
          name: Set up database
          command: createdb -h /tmp root
      - run:
          name: Configure
          command: CXXFLAGS=-O0 CONFIG_ARGS=--disable-documentation ./autogen.sh
      - run:
          name: Make
          command: make
      - run:
          name: Test
          command: PGDATA=db/data make check

# CircleCI config for automated test builds triggered from Github.
version: 2
jobs:
  build:
    docker:
      - image: postgres:latest
    environment:
      - PGHOST: "/tmp"
    steps:
      - checkout
      - run:
          name: Install
          command: apt update && apt install -y python g++ libpq-dev postgresql build-essential make autoconf dh-autoreconf autoconf-archive automake
      - run:
          name: Prepare postgres
          command: |
              mkdir /tmp/db &&
              chown postgres /tmp/db &&
              su postgres -c '/usr/lib/postgresql/*/bin/initdb --pgdata /tmp/db --auth trust --nosync'
      - run:
          name: Run postgres
          command: (su postgres -c '/usr/lib/postgresql/*/bin/postgres -D /tmp/db -k /tmp' &) && sleep 5
      - run:
          name: Create postgres user
          command: su postgres -c "createuser -w -d root"
      - run:
          name: Set up database
          command: createdb root
      - run:
          name: Configure
          command: CXXFLAGS=-O0 CONFIG_ARGS=--disable-documentation ./autogen.sh
      - run:
          name: Make
          command: make
      - run:
          name: Test
          command: PGDATA=db/data make check

Use PGHOST instead of -h option.
CircleCI: Use PGHOST instead of -h option.
