Install a specific set of gems in a CircleCI configuration file

匿名 (未验证) 提交于 2019-12-03 00:44:02

问题:

I am trying to build a CircleCI configuration file that only installs a specific set of gems via the environment parameter. In this case let's call that environment continuous_integration and this environment matches the test environment. So far I have tried a number of things and this is my current configuration in this spike.

Could anyone point me in the right direction? Is this possible?

machine:   timezone:     America/Los_Angeles   ruby:     version:       2.4.1   services:     - redis   environment:     RAILS_ENV: continous_integration  database:   override:     - bundle exec RAILS_ENV=continous_integration rake db:drop     - bundle exec RAILS_ENV=continous_integration rake db:setup  dependencies:   pre:     - gem install bundler   override:     - bundle install:         timeout: 180         environment:           RAILS_ENV: continous_integration  test:   override:     - bundle exec RAILS_ENV=continous_integration rspec  

回答1:

THIS SOLUTION ONLY WORKS WITH CIRCLE 1.0

From my current research I had to verify the continous_integration environment was setup correctly throughout Rails inside of secrets, the environments folder, gems, etc. As it turns out I have discovered that bundler does not use the ENV set so I am working with the following configuration know to force cache the gems, speed up the build process, and use the continous_integration environment.

References

.rspec

--color --require spec_helper --format documentation 

.circle.yml

machine:   timezone:     America/Los_Angeles   ruby:     version:       2.4.1   services:     - redis  dependencies:   pre:     - gem install bundler     - gem update bundler   override:     - bundle config without development:test     - bundle check --path=vendor/bundle || bundle install --without development test --path=vendor/bundle --jobs=4 --retry=3:         timeout: 180  database:   override:     - RAILS_ENV=continous_integration bundle exec rake db:drop     - RAILS_ENV=continous_integration bundle exec rake db:setup  test:   override:     - RAILS_ENV=continous_integration bundle exec rspec --format RspecJunitFormatter -o $CIRCLE_TEST_REPORTS/rspec.xml   post:     - gem install brakeman     - gem install rubocop     - gem install rubocop-rspec     - RAILS_ENV=continous_integration bundle exec rubocop --format fuubar --require rubocop-rspec --config .rubocop.yml     - RAILS_ENV=continous_integration brakeman -z 

Gemfile

group :development do   gem 'spring'   gem 'spring-watcher-listen', '~> 2.0.0'   gem 'spring-commands-rspec'   gem 'spring-commands-rubocop' end  group :development, :test do   gem 'pry-rails'   gem 'pry-nav'   gem 'pry-clipboard'   gem 'pry-rescue'   gem 'table_print'   gem 'awesome_print'   gem 'guard-rake'   gem 'guard-rspec' end  group :development, :test, :continous_integration do   gem 'brakeman', require: false   gem 'rubocop', require: false   gem 'rubocop-rspec', require: false   gem 'timecop'   gem 'mail_safe'   gem 'dotenv-rails'   gem 'factory_girl_rails'   gem 'faker', '~> 1.6.6' end  group :test, :continous_integration do   gem 'simplecov'   gem 'database_cleaner'   gem 'rspec-rails'   gem 'json_spec'   gem 'json-schema'   gem 'json_matchers'   gem 'shoulda-matchers'   gem 'nyan-cat-formatter'   gem 'rspec_junit_formatter', '~> 0.3.0.pre6'   gem 'webmock'   gem 'vcr' end 

This setup will yield the correct error output in Circle CI too



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!