GitHub ActionsでRails+PostgresSQLのCIを回そうとするところ、
rails db:migrate
のところでエラーがでて困っています。
エラー解決方法などわかることがあれば、教えていただきたいです
エラー詳細
Run bundle exec rails db:migrate rails aborted! ActiveRecord::ConnectionNotEstablished: 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"? /__w/RailsAppName/RailsAppName/bin/rails:5:in `<top (required)>' /__w/RailsAppName/RailsAppName/bin/spring:10:in `require' /__w/RailsAppName/RailsAppName/bin/spring:10:in `block in <top (required)>' /__w/RailsAppName/RailsAppName/bin/spring:7:in `<top (required)>' Caused by: 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"? /__w/RailsAppName/RailsAppName/bin/rails:5:in `<top (required)>' /__w/RailsAppName/RailsAppName/bin/spring:10:in `require' /__w/RailsAppName/RailsAppName/bin/spring:10:in `block in <top (required)>' /__w/RailsAppName/RailsAppName/bin/spring:7:in `<top (required)>'
config.ymlの中身
Rails + Postgres + github actions でCIを構築する - Qiita
上記の記事を参考にconfig.ymlを作成しました。
config.yml
1name: Verify 2# This workflow is triggered on pushes to the repository. 3on: [push] 4 5jobs: 6 build: 7 # Job name is Greeting 8 name: verify 9 # This job runs on Linux 10 runs-on: ubuntu-latest 11 services: 12 postgres: 13 image: postgres:13.3 14 ports: 15 - 5432:5432 16 env: 17 POSTGRES_USER: postgres 18 POSTGRES_PASSWORD: password 19 POSTGRES_DB: test 20 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 21 container: 22 image: ruby:3.0.2 23 env: 24 RAILS_ENV: test 25 POSTGRES_HOST: postgres 26 RAILS_DATABASE_USER: postgres 27 RAILS_DATABASE_PASSWORD: password 28 29 steps: 30 - name: checkout 31 uses: actions/checkout@v2 32 - name: bundler set up 33 run: | 34 gem install bundler 35 bundle install 36 - name: install node 37 uses: actions/setup-node@v1 38 with: 39 node-version: '16' 40 41 - name: Cache gems 42 uses: actions/cache@v1 43 with: 44 path: vendor/bundle 45 key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} 46 restore-keys: | 47 ${{ runner.os }}-gem- 48 49 - name: db migrate 50 run: | 51 bundle exec bin/rails db:migrate 52 53 - name: verify 54 run: | 55 bundle exec bin/rails test
調べたこと
ググってみて、ダイレクトにエラーを解決するものはなかったと思っています。
GitHub Actionsに慣れてなく、GitHub Actionsでどのように解決すればいいのかわかってないです。
あなたの回答
tips
プレビュー