Circle Ci fail only on script run not on console

rails
bundler
ruby

#1

Hello

We are testing CircleCi (in parallel with other solution) and we have an issue:

Here is our config.yml

# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
       - image: circleci/ruby:2.4.1
         environment:
           RAILS_ENV: test
       - image: redis:3.2.10
       - image: circleci/postgres:9.4
         environment:
         - POSTGRES_USER=***
         - POSTGRES_DB=***

    working_directory: ~/app

    steps:
      - checkout

      # Load installed gems from cache if possible, bundle install then save cache
      # Multiple caches are used to increase the chance of a cache hit
      - restore_cache:
          keys:
            - gem-cache-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
            - gem-cache-{{ .Branch }}
            - gem-cache

      - run:
          name: install dependencies
          command: |
            sudo apt-get install -y cmake && bundle install --jobs=4 --retry=3 --path vendor/bundle
      - save_cache:
          key: gem-cache-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle
      - save_cache:
          key: gem-cache-{{ .Branch }}
          paths:
            - vendor/bundle
      - save_cache:
          key: gem-cache
          paths:
            - vendor/bundle

      # Database setup
      - run: bundle exec rake db:create
      - run: bundle exec rake db:schema:load
      - run: bundle exec rake db:seed

      # run tests!
      - run:
          name: run tests
          command: |
            mkdir /tmp/test-results
            TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
            bundle exec rspec --format progress \
                            --format RspecJunitFormatter \
                            --out /tmp/test-results/rspec.xml \
                            --format progress \
                            $TEST_FILES

      # collect reports
      - store_test_results:
          path: /tmp/test-results
      - store_artifacts:
          path: /tmp/test-results
          destination: test-results

But we got this:

#!/bin/bash -eo pipefail
pwd
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
rspec --format progress \
      --format RspecJunitFormatter \
      --out /tmp/test-results/rspec.xml \
      --format progress \
      $TEST_FILES
/home/circleci/app
Run options: --seed 46296
/home/circleci/app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-transport-1.0.7/lib/elasticsearch/transport/transport/base.rb:43: warning: constant ::Fixnum is deprecated
/home/circleci/app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-transport-1.0.7/lib/elasticsearch/transport/transport/base.rb:45: warning: constant ::Fixnum is deprecated
/home/circleci/app/spec/services/native_link_metadata_service/foo_test/service_builder_spec.rb:3: warning: toplevel constant FooTest referenced by NativeLinkMetadataService::FooTest
/home/circleci/app/spec/services/native_link_metadata_service/foo_test/service_builder_spec.rb:3:in `<top (required)>': uninitialized constant FooTest::ServiceBuilder (NameError)
	from /home/circleci/app/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'

When we run the ssh we have no issue running bundle exec rspec


#2

It seems it’s related to https://circleci.com/docs/1.0/file-ordering/


#3

The error is related to our project and splitting file using times. Solution is to require file in test or don’t use split by time.


#4

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.