Can't get Postgresql working on Focal

I am trying to upgrade our CI build from Xenial to Focal

I can’t get Postgresql to go.

I have followed different instructions (which seem. bit contradictory)

The latest is this setup:

dist: focal

env:
  global:
    - PGPORT=5433  # NOTE ADDING THIS MAKES NO DIFFERENCE


addons:
  postgresql: "11"
  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
      - postgresql-11
      - postgresql-client-11

which was recommended elsewhere in a post here.

That fails like this:

Installing APT Packages

177PostgreSQL package is detected. Stopping postgresql service. See https://github.com/travis-ci/travis-ci/issues/5737 for more information.

178$ sudo systemctl stop postgresql

1790.39s$ sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install chromium-chromedriver google-chrome-stable yarn redis-server postgresql-11 postgresql-client-11

180Reading package lists...

181Building dependency tree...

182Reading state information...

183E: Unable to locate package postgresql-11

184E: Unable to locate package postgresql-client-11

apt-get.diagnostics

185apt-get install failed

284The command "sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install chromium-chromedriver google-chrome-stable yarn redis-server postgresql-11 postgresql-client-11" failed and exited with 100 during .

285

286Your build has been stopped.

Before that I tried a configuration like this:

env:
  global:
    - PGPORT=5433  # NOTE ADDING THIS MAKES NO DIFFERENCE
services:
  - postgresql

which was what the documentation appears to recommend but that errors with:

3.20s$ travis_setup_postgresql
Starting PostgreSQL v12
Assertion failed on job for postgresql@12-main.service.
sudo systemctl start postgresql@12-main
...
$ psql -c 'create database hyper_mesh_test_db;' -U postgres
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
The command "psql -c 'create database hyper_mesh_test_db;' -U postgres" failed and exited with 2 during .
Your build has been stopped.

Thanks in advance

I found the solution here: