version: 2.1 orbs: codacy: codacy/base@1.0.0 jobs: build_and_test: parameters: ruby_version: type: string persist_to_workspace: type: boolean default: false docker: - image: circleci/ruby:<< parameters.ruby_version >> working_directory: ~/workdir steps: - attach_workspace: at: ~/ - run: gem install bundler - restore_cache: keys: - ruby-codacy-coverage-{{ checksum "Gemfile.lock" }} - ruby-codacy-coverage- - run: bundle install --path vendor/bundle - save_cache: key: ruby-codacy-coverage-{{ checksum "Gemfile.lock" }} paths: - vendor/bundle - run: bundle exec rspec - when: condition: << parameters.persist_to_workspace >> steps: - persist_to_workspace: root: ~/ paths: - workdir/* publish: docker: - image: circleci/ruby:2 working_directory: ~/workdir steps: - attach_workspace: at: ~/ - run: name: Setup Rubygems command: bash .circleci/setup-rubygems.sh - run: name: Publish to Rubygems command: | export PUBLISH_VERSION=$(cat .version) gem build codacy-coverage.gemspec gem push codacy-coverage-$(cat .version).gem workflows: version: 2 build_and_publish: jobs: - codacy/checkout_and_version - build_and_test: name: build_and_test_2 ruby_version: "2" persist_to_workspace: true requires: - codacy/checkout_and_version - build_and_test: name: build_and_test_2.3 ruby_version: "2.3" requires: - codacy/checkout_and_version - build_and_test: name: build_and_test_2.4 ruby_version: "2.4" requires: - codacy/checkout_and_version - build_and_test: name: build_and_test_2.5 ruby_version: "2.5" requires: - codacy/checkout_and_version - build_and_test: name: build_and_test_2.6 ruby_version: "2.6" requires: - codacy/checkout_and_version - publish: requires: - build_and_test_2 - build_and_test_2.3 - build_and_test_2.4 - build_and_test_2.5 - build_and_test_2.6 filters: branches: only: - master - codacy/tag_version: name: tag_version requires: - publish