# Common variables, containers, jobs and steps. job_defaults: &job_defaults working_directory: /app shell: /bin/bash --login ruby_containers: &ruby_containers - &container-1_9 image: datadog/docker-library:ddtrace_rb_1_9_3 environment: - BUNDLE_GEMFILE=/app/Gemfile - &container-2_0 image: datadog/docker-library:ddtrace_rb_2_0_0 environment: - BUNDLE_GEMFILE=/app/Gemfile - &container-2_1 image: datadog/docker-library:ddtrace_rb_2_1_10 environment: - BUNDLE_GEMFILE=/app/Gemfile - &container-2_2 image: datadog/docker-library:ddtrace_rb_2_2_10 environment: - BUNDLE_GEMFILE=/app/Gemfile - &container-2_3 image: datadog/docker-library:ddtrace_rb_2_3_7 environment: - BUNDLE_GEMFILE=/app/Gemfile - &container-2_4 image: datadog/docker-library:ddtrace_rb_2_4_4 environment: - BUNDLE_GEMFILE=/app/Gemfile test_containers: &test_containers - &container_postgres image: postgres:9.6 environment: - POSTGRES_PASSWORD=postgres - POSTGRES_USER=postgres - POSTGRES_DB=postgres - &container_mysql image: mysql:5.6 environment: - MYSQL_ROOT_PASSWORD=root - MYSQL_PASSWORD=mysql - MYSQL_USER=mysql - &container_elasticsearch image: elasticsearch:2.4 - &container_redis image: redis:3.0 - &container_mongo image: mongo:3.5 - &container_memcached image: memcached:1.5-alpine - &container_agent image: datadog/docker-dd-agent environment: - DD_APM_ENABLED=true - DD_BIND_HOST=0.0.0.0 - DD_API_KEY=invalid_key_but_this_is_fine step_init_bundle_checksum: &step_init_bundle_checksum run: name: Initialize bundle cache key command: | touch .circleci/bundle_checksum step_bundle_install: &step_bundle_install run: name: Install gem dependencies command: bundle install step_rubocop: &step_rubocop run: name: Delint with Rubocop command: bundle exec rake rubocop step_appraisal_install: &step_appraisal_install run: name: Install Appraisal gems command: bundle exec appraisal install step_compute_bundle_checksum: &step_compute_bundle_checksum run: name: Compute bundle checksum command: | cat Gemfile.lock gemfiles/*.gemfile.lock > .circleci/bundle_checksum step_run_all_tests: &step_run_all_tests run: name: Run tests command: bundle exec rake ci step_release_docs: &step_release_docs run: name: Upload release docs command: S3_DIR=trace bundle exec rake release:docs filters_all_branches_and_tags: &filters_all_branches_and_tags filters: tags: only: /.*/ filters_only_release_tags: &filters_only_release_tags filters: branches: ignore: /.*/ tags: only: /^v\d+(\.\d+){0,3}(\.(alpha|beta|rc)\d+)?$/ version: 2.0 jobs: checkout-1.9: <<: *job_defaults docker: - *container-1_9 steps: - checkout - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-1.9-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app build-1.9: <<: *job_defaults docker: - *container-1_9 steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-1.9-{{ .Environment.CIRCLE_SHA1 }}' - '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-1.9-{{ .Environment.CIRCLE_SHA1 }}' - *step_init_bundle_checksum - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-1.9-{{ checksum ".circleci/bundle_checksum" }}' - *step_bundle_install - *step_appraisal_install - *step_compute_bundle_checksum - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-1.9-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-1.9-{{ checksum ".circleci/bundle_checksum" }}' paths: - /usr/local/bundle test-1.9: <<: *job_defaults docker: - <<: *container-1_9 environment: - TEST_DATADOG_INTEGRATION: 1 - *container_postgres - *container_mysql - *container_elasticsearch - *container_redis - *container_mongo - *container_memcached - *container_agent steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-1.9-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-1.9-{{ checksum ".circleci/bundle_checksum" }}' - *step_run_all_tests checkout-2.0: <<: *job_defaults docker: - *container-2_0 steps: - checkout - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-2.0-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app build-2.0: <<: *job_defaults docker: - *container-2_0 steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.0-{{ .Environment.CIRCLE_SHA1 }}' - '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-2.0-{{ .Environment.CIRCLE_SHA1 }}' - *step_init_bundle_checksum - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.0-{{ checksum ".circleci/bundle_checksum" }}' - *step_bundle_install - *step_appraisal_install - *step_compute_bundle_checksum - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.0-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.0-{{ checksum ".circleci/bundle_checksum" }}' paths: - /usr/local/bundle test-2.0: <<: *job_defaults docker: - <<: *container-2_0 environment: - TEST_DATADOG_INTEGRATION: 1 - *container_postgres - *container_mysql - *container_elasticsearch - *container_redis - *container_mongo - *container_memcached - *container_agent steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.0-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.0-{{ checksum ".circleci/bundle_checksum" }}' - *step_run_all_tests checkout-2.1: <<: *job_defaults docker: - *container-2_1 steps: - checkout - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-2.1-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app build-2.1: <<: *job_defaults docker: - *container-2_1 steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.1-{{ .Environment.CIRCLE_SHA1 }}' - '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-2.1-{{ .Environment.CIRCLE_SHA1 }}' - *step_init_bundle_checksum - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.1-{{ checksum ".circleci/bundle_checksum" }}' - *step_bundle_install - *step_rubocop - *step_appraisal_install - *step_compute_bundle_checksum - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.1-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.1-{{ checksum ".circleci/bundle_checksum" }}' paths: - /usr/local/bundle test-2.1: <<: *job_defaults docker: - <<: *container-2_1 environment: - TEST_DATADOG_INTEGRATION: 1 - *container_postgres - *container_mysql - *container_elasticsearch - *container_redis - *container_mongo - *container_memcached - *container_agent steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.1-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.1-{{ checksum ".circleci/bundle_checksum" }}' - *step_run_all_tests checkout-2.2: <<: *job_defaults docker: - *container-2_2 steps: - checkout - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-2.2-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app build-2.2: <<: *job_defaults docker: - *container-2_2 steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.2-{{ .Environment.CIRCLE_SHA1 }}' - '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-2.2-{{ .Environment.CIRCLE_SHA1 }}' - *step_init_bundle_checksum - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.2-{{ checksum ".circleci/bundle_checksum" }}' - *step_bundle_install - *step_rubocop - *step_appraisal_install - *step_compute_bundle_checksum - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.2-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.2-{{ checksum ".circleci/bundle_checksum" }}' paths: - /usr/local/bundle test-2.2: <<: *job_defaults docker: - <<: *container-2_2 environment: - TEST_DATADOG_INTEGRATION: 1 - *container_postgres - *container_mysql - *container_elasticsearch - *container_redis - *container_mongo - *container_memcached - *container_agent steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.2-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.2-{{ checksum ".circleci/bundle_checksum" }}' - *step_run_all_tests checkout-2.3: <<: *job_defaults docker: - *container-2_3 steps: - checkout - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-2.3-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app build-2.3: <<: *job_defaults docker: - *container-2_3 steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.3-{{ .Environment.CIRCLE_SHA1 }}' - '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-2.3-{{ .Environment.CIRCLE_SHA1 }}' - *step_init_bundle_checksum - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.3-{{ checksum ".circleci/bundle_checksum" }}' - *step_bundle_install - *step_rubocop - *step_appraisal_install - *step_compute_bundle_checksum - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.3-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.3-{{ checksum ".circleci/bundle_checksum" }}' paths: - /usr/local/bundle test-2.3: <<: *job_defaults docker: - <<: *container-2_3 environment: - TEST_DATADOG_INTEGRATION: 1 - *container_postgres - *container_mysql - *container_elasticsearch - *container_redis - *container_mongo - *container_memcached - *container_agent steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.3-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.3-{{ checksum ".circleci/bundle_checksum" }}' - *step_run_all_tests benchmark-2.3: <<: *job_defaults docker: - <<: *container-2_3 environment: - TEST_DATADOG_INTEGRATION: 1 - *container_postgres - *container_redis - *container_agent steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.3-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.3-{{ checksum ".circleci/bundle_checksum" }}' - run: name: Run Benchmark command: bundle exec appraisal rails5-postgres-sidekiq ruby benchmarks/sidekiq_test.rb 2>&1 1> /dev/null | tee benchmark_results.csv - run: name: Run Benchmark without ddtracer command: rm -f lib/ddtrace.rb && bundle exec appraisal rails5-postgres-sidekiq ruby benchmarks/sidekiq_test.rb 2>&1 1> /dev/null | tee benchmark_results.csv checkout-2.4: <<: *job_defaults docker: - *container-2_4 steps: - checkout - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-2.4-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app build-2.4: <<: *job_defaults docker: - *container-2_4 steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.4-{{ .Environment.CIRCLE_SHA1 }}' - '{{ .Environment.CIRCLE_CACHE_VERSION }}-repo-2.4-{{ .Environment.CIRCLE_SHA1 }}' - *step_init_bundle_checksum - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.4-{{ checksum ".circleci/bundle_checksum" }}' - *step_bundle_install - *step_rubocop - *step_appraisal_install - *step_compute_bundle_checksum - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.4-{{ .Environment.CIRCLE_SHA1 }}' paths: - /app - save_cache: key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.4-{{ checksum ".circleci/bundle_checksum" }}' paths: - /usr/local/bundle test-2.4: <<: *job_defaults docker: - <<: *container-2_4 environment: - TEST_DATADOG_INTEGRATION: 1 - *container_postgres - *container_mysql - *container_elasticsearch - *container_redis - *container_mongo - *container_memcached - *container_agent steps: - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-2.4-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundle-2.4-{{ checksum ".circleci/bundle_checksum" }}' - *step_run_all_tests build-2.5: <<: *job_defaults working_directory: ~/app docker: - &container-2_5 image: circleci/ruby:2.5.1 steps: - checkout - restore_cache: &cache-2_5 key: 'b1-{{ .Environment.CIRCLE_CACHE_VERSION }}-cache-2.5-{{ checksum Appraisals }}-{{ checksum ddtrace.gemspec }}-{{ checksum Gemfile }}' paths: - vendor/bundle - gemfiles/ - Gemfile.lock - run: &bundler_init name: Initializing Bundler vendor path command: bundle --path vendor/bundle - *step_bundle_install - *step_appraisal_install - save_cache: *cache-2_5 - *step_rubocop - persist_to_workspace: <<: *cache-2_5 root: '.' test-2.5: <<: *job_defaults working_directory: ~/app docker: - <<: *container-2_5 environment: - TEST_DATADOG_INTEGRATION: 1 - *container_postgres - *container_mysql - *container_elasticsearch - *container_redis - *container_mongo - *container_memcached - *container_agent steps: - checkout - attach_workspace: at: ~/app - run: *bundler_init - *step_run_all_tests deploy-release: <<: *job_defaults docker: - *container-2_4 steps: - checkout - run: command: | apt-get -y -qq update apt-get -y -qq install awscli - *step_bundle_install - *step_release_docs workflows: version: 2 build-and-test: jobs: - checkout-1.9: <<: *filters_all_branches_and_tags - build-1.9: <<: *filters_all_branches_and_tags requires: - checkout-1.9 - test-1.9: <<: *filters_all_branches_and_tags requires: - build-1.9 - checkout-2.0: <<: *filters_all_branches_and_tags - build-2.0: <<: *filters_all_branches_and_tags requires: - checkout-2.0 - test-2.0: <<: *filters_all_branches_and_tags requires: - build-2.0 - checkout-2.1: <<: *filters_all_branches_and_tags - build-2.1: <<: *filters_all_branches_and_tags requires: - checkout-2.1 - test-2.1: <<: *filters_all_branches_and_tags requires: - build-2.1 - checkout-2.2: <<: *filters_all_branches_and_tags - build-2.2: <<: *filters_all_branches_and_tags requires: - checkout-2.2 - test-2.2: <<: *filters_all_branches_and_tags requires: - build-2.2 - checkout-2.3: <<: *filters_all_branches_and_tags - build-2.3: <<: *filters_all_branches_and_tags requires: - checkout-2.3 - test-2.3: <<: *filters_all_branches_and_tags requires: - build-2.3 - benchmark-2.3: <<: *filters_all_branches_and_tags requires: - build-2.3 - checkout-2.4: <<: *filters_all_branches_and_tags - build-2.4: <<: *filters_all_branches_and_tags requires: - checkout-2.4 - test-2.4: <<: *filters_all_branches_and_tags requires: - build-2.4 - build-2.5: *filters_all_branches_and_tags - test-2.5: <<: *filters_all_branches_and_tags requires: - build-2.5 - deploy-release: <<: *filters_only_release_tags requires: - test-1.9 - test-2.0 - test-2.1 - test-2.2 - test-2.3 - test-2.4 - test-2.5