Почему сбой CircleCI?

#ruby-on-rails #postgresql #circleci

#ruby-on-rails #postgresql #circleci

Вопрос:

Сборка выполняется, но затем появляется ошибкавведите описание изображения здесь

Полная информация об ошибке:

 Error reading historical timing data: file does not exist
Requested weighting by historical based timing, but they are not present. Falling back to weighting by name.
/home/circleci/project/vendor/bundle/ruby/2.7.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/stack.rb:35: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/circleci/project/vendor/bundle/ruby/2.7.0/gems/actionpack-5.1.7/lib/action_dispatch/middleware/static.rb:109: warning: The called method `initialize' is defined here
/home/circleci/project/vendor/bundle/ruby/2.7.0/gems/activerecord-5.1.7/lib/active_record/type.rb:25: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/circleci/project/vendor/bundle/ruby/2.7.0/gems/activerecord-5.1.7/lib/active_record/type/adapter_specific_registry.rb:7: warning: The called method `add_modifier' is defined here
                                                                                

An error occurred while loading ./spec/models/author_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/models/author_spec.rb:3:in `require'
# ./spec/models/author_spec.rb:3:in `<top (required)>'

An error occurred while loading ./spec/models/author_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/models/author_spec.rb:3:in `require'
# ./spec/models/author_spec.rb:3:in `<top (required)>'
                                                                                

An error occurred while loading ./spec/requests/authors_create_request_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/requests/authors_create_request_spec.rb:3:in `<top (required)>'

An error occurred while loading ./spec/requests/authors_create_request_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/requests/authors_create_request_spec.rb:3:in `<top (required)>'
                                                                                

An error occurred while loading ./spec/requests/authors_delete_request_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/requests/authors_delete_request_spec.rb:3:in `<top (required)>'

An error occurred while loading ./spec/requests/authors_delete_request_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/requests/authors_delete_request_spec.rb:3:in `<top (required)>'
                                                                                

An error occurred while loading ./spec/requests/authors_index_request_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/requests/authors_index_request_spec.rb:3:in `<top (required)>'

An error occurred while loading ./spec/requests/authors_index_request_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/requests/authors_index_request_spec.rb:3:in `<top (required)>'
                                                                                

An error occurred while loading ./spec/requests/authors_show_request_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/requests/authors_show_request_spec.rb:3:in `<top (required)>'

An error occurred while loading ./spec/requests/authors_show_request_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/requests/authors_show_request_spec.rb:3:in `<top (required)>'
                                                                                

An error occurred while loading ./spec/requests/authors_update_request_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/requests/authors_update_request_spec.rb:3:in `<top (required)>'

An error occurred while loading ./spec/requests/authors_update_request_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!

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"?
# ./spec/rails_helper.rb:32:in `<top (required)>'
# ./spec/requests/authors_update_request_spec.rb:3:in `<top (required)>'
                                                                                
No examples found.
No examples found.
                                                                                
 0/0 |========================= 100 ==========================>| Time: 00:00:00 


Top 0 slowest examples (0 seconds, 0.0% of total time):

Finished in 0.00042 seconds (files took 3.02 seconds to load)
0 examples, 0 failures, 6 errors occurred outside of examples

Finished in 0.00042 seconds (files took 3.02 seconds to load)
0 examples, 0 failures, 6 errors occurred outside of examples


Exited with code exit status 1
  

Конфигурации CircleCI являются:
версия: 2.1
шары:
ruby: circleci/ruby@1.0

задания: сборка: docker: — образ: circleci / ruby: 2.7.1 среда: BUNDLER_VERSION: 2.1.4 исполнитель: ruby/default шаги: — проверка проверки ruby/install-deps: docker: — образ: circleci/ ruby: 2.7.1 среда: BUNDLER_VERSION: 2.1.4 шаги: — проверка ruby/install-deps — ruby/rspec-test

рабочие процессы: версия: 2 build_and_test: задания: — сборка — тест: требуется: — сборка

Ответ №1:

Я предполагаю, что вы пропустили настройку базы данных на .circleci/config.yml .

Пожалуйста, обратитесь https://circleci.com/docs/2.0/language-ruby /.

Ниже приведен пример конфигурации.

 version: 2.1 # Use 2.1 to enable using orbs and other features.

# Declare the orbs that we'll use in our config.
# read more about orbs: https://circleci.com/docs/2.0/using-orbs/
orbs:
  ruby: circleci/ruby@1.0 
  node: circleci/node@2

jobs:
  build: # our first job, named "build"
    docker:
      - image: cimg/ruby:2.7-node # use a tailored CircleCI docker image.
    steps:
      - checkout # pull down our git code.
      - ruby/install-deps # use the ruby orb to install dependencies
      # use the node orb to install our packages
      # specifying that we use `yarn` and to cache dependencies with `yarn.lock`
      # learn more: https://circleci.com/docs/2.0/caching/
      - node/install-packages: 
          pkg-manager: yarn
          cache-key: "yarn.lock"
          
  test:  # our next job, called "test"
    # we run "parallel job containers" to enable speeding up our tests;
    # this splits our tests across multiple containers.
    parallelism: 3 
    # here we set TWO docker images.
    docker:
      - image: cimg/ruby:2.7-node # this is our primary docker image, where step commands run.
      - image: circleci/postgres:9.5-alpine 
        environment: # add POSTGRES environment variables.
          POSTGRES_USER: circleci-demo-ruby
          POSTGRES_DB: rails_blog_test
          POSTGRES_PASSWORD: ""
    # environment variables specific to Ruby/Rails, applied to the primary container.
    environment:
      BUNDLE_JOBS: "3"
      BUNDLE_RETRY: "3"
      PGHOST: 127.0.0.1
      PGUSER: circleci-demo-ruby
      PGPASSWORD: ""
      RAILS_ENV: test
    # A series of steps to run, some are similar to those in "build".
    steps:
      - checkout 
      - ruby/install-deps 
      - node/install-packages:
          pkg-manager: yarn
          cache-key: "yarn.lock"
      # Here we make sure that the secondary container boots 
      # up before we run operations on the database.
      - run:
          name: Wait for DB
          command: dockerize -wait tcp://localhost:5432 -timeout 1m
      - run:
          name: Database setup
          command: bundle exec rails db:schema:load --trace
      # Run rspec in parallel
      - ruby/rspec-test

# We use workflows to orchestrate the jobs that we declared above.
workflows:
  version: 2
  build_and_test:     # The name of our workflow is "build_and_test"
    jobs:             # The list of jobs we run as part of this workflow.
      - build         # Run build first.
      - test:         # Then run test,
          requires:   # Test requires that build passes for it to run.
            - build   # Finally, run the build job.
  

Комментарии:

1. да, я действительно пропустил эту конфигурацию. Но после добавления ошибка по-прежнему остается прежней.

2. файл fonfig: drive.google.com/file/d/1KsG3GtUIeuIkKV0HfJk7otDb4W656JZN /…

3. О, вы не произвели никакой настройки, связанной с базой данных. Я обновил свой ответ.