Gitlab-ci.yml rspec在迁移到第页后测试错误



我在gitlab上执行时出错。gitlab-ci.yml

$ bundle exec rspec

in.gitlab-ci.yml

在本地,我有用于开发和测试环境的postgresql。所有rspec测试均通过。

但在gitlab上传项目后,它引发了错误:

An error occurred while loading ./spec/requests/api/packages_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!
PG::ConnectionBad:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"

在我使用sqlite3数据库之前。但比我迁移到pg.

database.yml:

default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: pg_app_development
test:
<<: *default
database: pg_app_test

添加database.yml端口和主机var:

test:
<<: *default
database: pg_app_test
user: postgres
host: <%= ENV.fetch("DATABASE_HOST") { 'localhost' } %>
port: 5432

和数据库变量到.gitlab-ci.yml

variables:
RAILS_ENV: test
POSTGRES_DB: pg_app_test
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
DATABASE_HOST: postgres

最新更新