[英]Rails Postgres Github Actions error: PG::ConnectionBad: fe_sendauth: no password supplied
[英]PG::ConnectionBad on Github Actions for Rails
我現在遇到了問題,不知道如何在 Github Actions 上下文中解決這個問題。
側面背景:我正在學習關於使用 GH 操作為 CI 設置 Rails-Postgres 的教程。
通常當我在開發環境中遇到這個問題時,我會刪除一個postmaster.pid
文件。 但在這里,因為我在 GH 動作的測試環境中,我不確定如何解決它。 我已經嘗試過如何在 dev env 中執行此操作,但不幸的是它不起作用。
我嘗試過的解決方案:
rm /usr/local/var/postgres/postmaster.pid
更改工作流中 postgres 條目中的ports
我的 GH 行動工作流程:
name: Test
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12.1
ports:
- 6543:6543
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Ruby version specified in `.ruby-version`
uses: eregon/use-ruby-action@master
- name: Install required apt packages
run: |
sudo apt-get -y install libpq-dev
- name: Setup cache key and directory for gems cache
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-use-ruby-${{ hashFiles('**/Gemfile.lock') }}
- name: Read Node.js version to install from `.nvmrc`
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: nvm
- name: Install required Node.js version
uses: actions/setup-node@v1
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
- name: Get Yarn cache directory path
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Setup cache key and directory for node_modules cache
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Bundle install
run: |
gem install bundler -v2.1.4
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Yarn install
run: yarn --frozen-lockfile
- name: Run RSpec // ERRORS HERE
run: |
RUBYOPT='-W:no-deprecated -W:no-experimental' bundle exec rails db:prepare
RUBYOPT='-W:no-deprecated -W:no-experimental' bundle exec rspec
它中斷了Run RSpec
任務。
錯誤信息:
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"?
謝謝大家的幫助😁
找到了解決辦法!
我需要在config/database.yml
為測試數據庫添加host
、 username
和password
條目
因為你指定的端口是 6543,所以 PostgreSQL 找不到它的默認端口 5432。
要解決此問題,請在下面指定端口
services:
postgres:
ports:
- 5432/tcp
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.