ON_ERROR_STOP
psql returns 0 to the shell if it finished normally, 1 if a fatal error of its own occurs (e.g. out of memory, file not found), 2 if the connection to the server went bad and the session was not interactive, and 3 if an error occurred in a script and the variable ON_ERROR_STOP was set.
see : https://www.postgresql.org/docs/10/static/app-psql.html#exit-status
This means the default behaviour of psql is to return 0 even if the SQL script has failed. This is not what most users would expect from a CI script, so I would suggest changing your example to had "ON_ERROR_STOP=1" like this :
- psql ... -v "ON_ERROR_STOP=1" -c "SELECT 'OK' AS status;"