Gitlab-ci.ymlrspec迁移到pg后测试报错
Gitlab-ci.yml rspec tests error after migarting to pg
执行时gitlab报错.gitlab-ci.yml
$ bundle exec rspec
在 .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 端口和主机变量:
test:
<<: *default
database: pg_app_test
user: postgres
host: <%= ENV.fetch("DATABASE_HOST") { 'localhost' } %>
port: 5432
和db变量到.gitlab-ci.yml
variables:
RAILS_ENV: test
POSTGRES_DB: pg_app_test
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
DATABASE_HOST: postgres
执行时gitlab报错.gitlab-ci.yml
$ bundle exec rspec
在 .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 端口和主机变量:
test:
<<: *default
database: pg_app_test
user: postgres
host: <%= ENV.fetch("DATABASE_HOST") { 'localhost' } %>
port: 5432
和db变量到.gitlab-ci.yml
variables:
RAILS_ENV: test
POSTGRES_DB: pg_app_test
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
DATABASE_HOST: postgres