[英]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.