繁体   English   中英

Rails Postgres Github 操作错误:PG::ConnectionBad:fe_sendauth:未提供密码

[英]Rails Postgres Github Actions error: PG::ConnectionBad: fe_sendauth: no password supplied

我正在尝试基于本文本文中显示的配置,使用 Postgresql 构建和测试在 Github 操作上工作的 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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM