Travis – Postgresql inside of a nested jo

I cannot get postgresql to run using travis, WITHIN A NESTED JOB

I have read all the posts I can find, and have tried everything. I think the problem is the jobs, as I did get postgresql to connect but only if I set it up in the outer layers.

I'm sorry I am not a travis expert so my terminology is probably all wrong:

Here is the yml file:

This is for this CI build 
https://travis-ci.com/github/hyperstack-org/hyperstack

I cannot get postgresql running... have followed all instructions, have tried all different versions.  I would ultimately like to get postgresql 11.2 running.  Please help 

I believe the problem has to do with the way we have these 'nested jobs'  but that is necessary for our build structure.

Here is my yml file:

language: bash
cache:
  bundler: true
  directories:
    - node_modules # NPM packages
_test_gem: &_test_gem
  # env:
  #   global:
  #   - PGPORT=5433
  stage: test
  services:
    - postgresql
  addons:
    apt:
      sources:
        - sourceline: 'deb http://dl.yarnpkg.com/debian/ stable main'
          key_url: 'http://dl.yarnpkg.com/debian/pubkey.gpg'
        - sourceline: 'deb http://dl.google.com/linux/chrome/deb/ stable main'
          key_url: 'https://dl-ssl.google.com/linux/linux_signing_key.pub'
      packages:
        - chromium-chromedriver
        - google-chrome-stable
        - yarn
        - redis-server
    # mariadb: '10.3' # mariadb works fine...
    postgresql: "9.6"
  before_install:
    - echo installing $COMPONENT
    - sudo rm -f /usr/local/bin/yarn
    - nvm install 10
    - rvm install 2.6.3  # was 2.5.1
    - gem install bundler
    - ln -s /usr/lib/chromium-browser/chromedriver ~/bin/chromedriver
  before_script:
    - echo creating pg database hyper_mesh_test_db
    - psql --version
    # reports pg is there... but following line breaks with:
    #    psql: could not connect to server: No such file or directory
    - psql -c 'CREATE DATABASE hyper_mesh_test_db;' -U postgres
    - psql -c 'CREATE ROLE travis SUPERUSER LOGIN CREATEDB;' -U postgres
    - echo before_script $COMPONENT
    - cd ruby/$COMPONENT
    - bundle install --jobs=3 --retry=3
    - bundle exec rake spec:prepare
    - google-chrome --version
    - which google-chrome
    - yarn install
  script:
    - echo running script $COMPONENT
    - DRIVER=travis bundle exec rake $TASK

_deploy_gem: &_deploy_gem
  stage: release gems
  before_script:
    - cd ruby/$COMPONENT
  script:
    - echo deploying $COMPONENT
  deploy:
    - provider: rubygems
      api_key:...
      on:
        tags: true
jobs:
  include:
    - <<: *_test_gem
      env: COMPONENT=hyper-model       RUBY_VERSION=2.5.1 TASK=part1


Read more here: https://stackoverflow.com/questions/66336742/travis-postgresql-inside-of-a-nested-jo

Content Attribution

This content was originally published by Mitch VanDuyn at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: