Skip to content

Commit

Permalink
Merge pull request #4102 from DataDog/tonycthsu/remove-appraisal-update
Browse files Browse the repository at this point in the history
CircleCI cache fix
  • Loading branch information
TonyCTHsu authored Nov 12, 2024
2 parents d84be25 + 48d180e commit 18960b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
34 changes: 10 additions & 24 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ save_bundle_checksum: &save_bundle_checksum
command: |
if [ "$CI_BUNDLE_CACHE_HIT" != 1 ]; then
# Recompute gemfiles/*.lock checksum, as those files might have changed
cat Gemfile Gemfile.lock Appraisals gemfiles/*.gemfile.lock | md5sum > .circleci/bundle_checksum
cat Gemfile Gemfile.lock Appraisals gemfiles/*.gemfile gemfiles/*.gemfile.lock | md5sum > .circleci/bundle_checksum
fi
cp .circleci/bundle_checksum /usr/local/bundle/bundle_checksum
step_bundle_install: &step_bundle_install
Expand All @@ -82,16 +82,12 @@ step_appraisal_install: &step_appraisal_install
name: Install Appraisal gems
command: |
if [ "$CI_BUNDLE_CACHE_HIT" != 1 ]; then
bundle exec appraisal install
bundle exec appraisal generate
bundle exec rake dependency:install
else
bundle exec appraisal generate # Generate the appraisal files to match the lockfiles in the tree
bundle exec appraisal generate
echo "All required gems were found in cache."
fi
step_appraisal_update: &step_appraisal_update
run:
name: Update Appraisal gems
command: | # Remove all generated gemfiles and lockfiles, resolve, and install dependencies again
bundle exec appraisal update
step_compute_bundle_checksum: &step_compute_bundle_checksum
run:
name: Compute bundle checksum
Expand All @@ -100,7 +96,7 @@ step_compute_bundle_checksum: &step_compute_bundle_checksum
# updating the gemset lock files produces extremely large commits.
command: |
bundle lock # Create Gemfile.lock
cat Gemfile Gemfile.lock Appraisals gemfiles/*.gemfile.lock | md5sum > .circleci/bundle_checksum
cat Gemfile Gemfile.lock Appraisals gemfiles/*.gemfile gemfiles/*.gemfile.lock | md5sum > .circleci/bundle_checksum
step_run_all_tests: &step_run_all_tests
run:
name: Run tests
Expand Down Expand Up @@ -181,17 +177,7 @@ orbs:
- bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<<parameters.ruby_version>>-{{ checksum "lib/datadog/version.rb" }}
- *check_exact_bundle_cache_hit
- *step_bundle_install
- when:
condition:
equal: [ << parameters.edge >>, true ]
steps:
- *step_appraisal_update # Run on latest version of all gems we integrate with
- when:
condition:
not:
equal: [ << parameters.edge >>, true ]
steps:
- *step_appraisal_install # Run on a stable set of gems we integrate with
- *step_appraisal_install # Run on a stable set of gems we integrate with
- *save_bundle_checksum
- save_cache:
key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-<<parameters.ruby_version>>-{{ .Environment.CIRCLE_SHA1 }}'
Expand Down Expand Up @@ -299,6 +285,10 @@ orbs:
curl --silent --show-error --location --fail --retry 3 --output /usr/local/bin/dockerize $DOCKERIZE_URL
chmod +x /usr/local/bin/dockerize
dockerize --version
# Test agent uses `jq` to check results
- run:
name: Install jq
command: apt update && apt install jq -y
# Wait for containers to start
- docker-wait:
port: 5432
Expand All @@ -321,10 +311,6 @@ orbs:
host: "testagent"
port: 9126
- *step_run_all_tests
- run:
# Test agent uses `jq` to check results
name: Install jq
command: apt update && apt install jq -y
- *step_get_test_agent_trace_check_results
- store_test_results:
path: /tmp/rspec
Expand Down
10 changes: 2 additions & 8 deletions tasks/dependency.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'open3'

require_relative 'appraisal_conversion'

namespace :dependency do
Expand Down Expand Up @@ -31,9 +29,7 @@ namespace :dependency do
Bundler.with_unbundled_env do
command = +'bundle lock'
command << ' --add-platform x86_64-linux aarch64-linux' unless RUBY_PLATFORM == 'java'
output, = Open3.capture2e({ 'BUNDLE_GEMFILE' => gemfile.to_s }, command)

puts output
sh({ 'BUNDLE_GEMFILE' => gemfile.to_s }, command)
end
end
end
Expand All @@ -47,9 +43,7 @@ namespace :dependency do

gemfiles.each do |gemfile|
Bundler.with_unbundled_env do
output, = Open3.capture2e({ 'BUNDLE_GEMFILE' => gemfile.to_s }, "bundle check || bundle install")

puts output
sh({ 'BUNDLE_GEMFILE' => gemfile.to_s }, 'bundle check || bundle install')
end
end
end
Expand Down

0 comments on commit 18960b5

Please sign in to comment.