Ruby on rails PG::Rails的Github操作上的ConnectionBad

Ruby on rails PG::Rails的Github操作上的ConnectionBad,ruby-on-rails,postgresql,github-actions,Ruby On Rails,Postgresql,Github Actions,我现在遇到了一个问题,不知道如何在Github操作上下文中解决这个问题 侧上下文:我正在关注一个关于为CI设置带有GH操作的Rails Postgres的问题 通常,当我在开发环境中遇到这个问题时,我会删除一个postmaster.pid文件。但在这里,因为我在GH actions的测试环境中,我不知道如何解决它。我已经尝试过如何在devenv中实现它,但不幸的是没有成功 我尝试过的解决方案: rm/usr/local/var/postgres/postmaster.pid 在工作流中更改po

我现在遇到了一个问题,不知道如何在Github操作上下文中解决这个问题

侧上下文:我正在关注一个关于为CI设置带有GH操作的Rails Postgres的问题

通常,当我在开发环境中遇到这个问题时,我会删除一个
postmaster.pid
文件。但在这里,因为我在GH actions的测试环境中,我不知道如何解决它。我已经尝试过如何在devenv中实现它,但不幸的是没有成功

我尝试过的解决方案:

  • rm/usr/local/var/postgres/postmaster.pid

  • 在工作流中更改postgres条目中的
    端口

我的工作流程:

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

它在
运行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"?

谢谢大家的帮助,因为您为6543指定了端口,所以PostgreSQL找不到默认端口5432

要解决此问题,请指定下面的端口

服务:
博士后:
端口:
-5432/tcp
找到了修复程序

我需要在
config/database.yml
中为测试数据库添加
主机
用户名
,和
密码
条目

是的,检查此项后发现同样的问题。