# 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.6.0-node-browsers environment: BUNDLER_VERSION: 2.0.1 # Specify service dependencies here if necessary # CircleCI maintains a library of pre-built images # documented at https://circleci.com/docs/2.0/circleci-images/ # - image: circleci/postgres:9.4 working_directory: ~/repo steps: - checkout # Download and cache dependencies - restore_cache: keys: - v1-dependencies-{{ checksum "Gemfile.lock" }} # fallback to using the latest cache if no exact match is found - v1-dependencies- # install Bundler! # ref:https://discuss.circleci.com/t/using-bundler-2-0-during-ci-fails/27411 - run: name: install bundler command: | sudo gem update --system sudo gem uninstall bundler sudo rm /usr/local/bin/bundle sudo rm /usr/local/bin/bundler sudo gem install bundler # install gem! - run: name: install gem command: | # jobs=4は並列処理をして高速化するための設定(4つのjobで実行するって意味) bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 - save_cache: paths: - ./vendor/bundle key: v1-dependencies-{{ checksum "Gemfile.lock" }} # run rubocop! - run: name: run rubocop command: | bundle exec rubocop # run tests! - run: name: run tests command: | TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)" bundle exec rspec \ --format progress \ --format RspecJunitFormatter \ --out test_results/rspec.xml \ --format progress \ $TEST_FILES # collect reports - store_test_results: path: test_results - store_artifacts: # テスト結果をtest-resultsディレクトリに吐き出す path: test_results destination: test-results - store_artifacts: # カバレッジの結果をcoverage-resultsディレクトリに吐き出す path: coverage destination: coverage-results # deploy RubyGems - deploy: command: | if [ "${CIRCLE_BRANCH}" == "master" ]; then mkdir ~/.gem curl -u dodonki1223:$RUBYGEMS_PASSWORD https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials git config user.name dodonki1223 git config user.email $RUBYGEMS_EMAIL bundle exec rake build bundle exec rake release fi