【问题标题】:Rails Postgres Github Actions error: PG::ConnectionBad: fe_sendauth: no password suppliedRails Postgres Github Actions 错误:PG::ConnectionBad:fe_sendauth:未提供密码
【发布时间】:2021-04-04 09:58:48
【问题描述】:

我正在尝试基于this articlethis article 中显示的配置,使用 Postgresql 在 Github Actions 上构建和测试 Rails 应用程序。当我将分支推送到 Github 以启动操作时,运行测试时出现以下错误:

PG::ConnectionBad: fe_sendauth: 未提供密码

我提供了那些文章中显示的数据库的用户名和密码,为什么会失败?

[...]

jobs:
  test:

    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres:13
        ports:
          - 5432:5432
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

    [...]
    - name: Install postgres
      run: sudo apt-get install libpq-dev
    - name: Install dependencies
      run: bundle install
    - name: Setup database
      env:
        RAILS_ENV: test
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: postgres
      run: |
        cp config/database.yml.github-actions config/database.yml
        bundle exec rake db:create
        bundle exec rake db:schema:load
    - name: Run tests
      run: bundle exec rake

【问题讨论】:

    标签: ruby-on-rails postgresql github-actions


    【解决方案1】:

    问题是配置文件中的一个简单遗漏:我为Setup database 步骤设置了env 变量部分,但没有为Run tests 步骤设置。结果,错误是正确的,在该步骤中,没有提供用户名/密码,因此无法连接到数据库服务器。将其添加到测试步骤即可解决问题:

    - name: Run tests
      run: bundle exec rake
      env:
        RAILS_ENV: test
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: postgres
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-04
      • 1970-01-01
      • 1970-01-01
      • 2016-02-03
      • 1970-01-01
      • 2014-06-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多