From a908596d0c85ec8f5eeada5c7169c5da7c81a01b Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Mon, 21 Nov 2022 17:26:04 +0100 Subject: [PATCH] Introduce binary version in CI cache key Because CIRCLE_CACHE_VERSION is globally defined in CircleCI, bumping it means starting from a blank universe for all subsequent job runs. If a new PR that breaks binary compatibility ran + saved to cache first then it would produce a matchable key from which other branches would try to build, and fail for older jobs. This also serves as a signal to developers that if they pull new images past a change to this file they should clear their bundle cache volumes and run bundle install and appraisal install again. --- .circleci/config.yml | 20 ++++++++++---------- .circleci/images/primary/binary_version | 1 + lib/ddtrace/version.rb | 2 -- 3 files changed, 11 insertions(+), 12 deletions(-) create mode 100644 .circleci/images/primary/binary_version diff --git a/.circleci/config.yml b/.circleci/config.yml index 5aeb6586ea3..fb292da8104 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -204,9 +204,9 @@ orbs: - *step_compute_bundle_checksum - restore_cache: keys: - - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} - - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}- - - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-<>-{{ checksum "lib/ddtrace/version.rb" }} + - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} + - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}- + - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<>-{{ checksum "lib/ddtrace/version.rb" }} - *check_exact_bundle_cache_hit - *step_bundle_install - when: @@ -226,7 +226,7 @@ orbs: paths: - /app - save_cache: - key: bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} + key: bundle-{{ .Environment.CIRCLE_CACHE_VERSION }-{{ checksum ".circleci/images/primary/binary_version" }}}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} paths: - /usr/local/bundle build_and_test_integration: @@ -278,7 +278,7 @@ orbs: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-<>-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} + - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} - run: name: Set coverage report directory command: | @@ -323,7 +323,7 @@ orbs: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-<>-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} + - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ 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 @@ -338,7 +338,7 @@ orbs: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-<>-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} + - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} - *step_rubocop sorbet_type_checker: <<: *test_job_default @@ -348,7 +348,7 @@ orbs: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-<>-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} + - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} - *step_sorbet_type_checker coverage: <<: *test_job_default @@ -358,7 +358,7 @@ orbs: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-<>-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} + - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} - attach_workspace: at: /tmp/workspace - run: @@ -381,7 +381,7 @@ orbs: - '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-<>-{{ .Environment.CIRCLE_SHA1 }}' - restore_cache: keys: - - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} + - bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<>-{{ checksum "lib/ddtrace/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }} - attach_workspace: at: /tmp/workspace - run: diff --git a/.circleci/images/primary/binary_version b/.circleci/images/primary/binary_version new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/.circleci/images/primary/binary_version @@ -0,0 +1 @@ +1 diff --git a/lib/ddtrace/version.rb b/lib/ddtrace/version.rb index 97edc93a7d7..b34c0065232 100644 --- a/lib/ddtrace/version.rb +++ b/lib/ddtrace/version.rb @@ -23,7 +23,5 @@ module VERSION # an eye on the Ruby 3.2 test releases to see if anything changes. (Otherwise, once Ruby 3.2.0 stable is out, we # should probably bump this to 3.4, and so on...) MAXIMUM_RUBY_VERSION = '3.3'.freeze - - CACHE_BUST = '1' end end