From 8f979692e5b83e276bf06b359566f2523fec2326 Mon Sep 17 00:00:00 2001 From: Titus Fortner Date: Mon, 13 Jul 2026 09:43:18 -0500 Subject: [PATCH] [build] Reconcile Gemfile.lock in rb:pin with bundle lock, not bundle update --- rake_tasks/ruby.rake | 4 +++- rb/BUILD.bazel | 19 +++++++++++++++++-- rb/support/BUILD.bazel | 4 ++-- rb/support/{bundle_update.rb => bundle.rb} | 4 +++- 4 files changed, 25 insertions(+), 6 deletions(-) rename rb/support/{bundle_update.rb => bundle.rb} (87%) diff --git a/rake_tasks/ruby.rake b/rake_tasks/ruby.rake index 6e4aa7d698a53..fee7b20595983 100644 --- a/rake_tasks/ruby.rake +++ b/rake_tasks/ruby.rake @@ -187,8 +187,10 @@ task :lint do |_task, arguments| ) end -desc 'Sync gem checksums from Gemfile.lock to MODULE.bazel (use force to re-download all)' +desc 'Reconcile Gemfile.lock and sync gem checksums to MODULE.bazel (use force to re-download all)' task :pin, [:force] do |_task, arguments| + Bazel.execute('run', [], '//rb:bundle-lock') + gemfile_lock = 'rb/Gemfile.lock' module_bazel = 'MODULE.bazel' force = arguments[:force] == 'force' diff --git a/rb/BUILD.bazel b/rb/BUILD.bazel index abd2dba9eda84..9e50ebcac62a6 100644 --- a/rb/BUILD.bazel +++ b/rb/BUILD.bazel @@ -177,16 +177,31 @@ rb_binary( ], ) +rb_binary( + name = "bundle-lock", + args = [ + "rb/support/bundle.rb", + "lock", + ], + data = [ + "Gemfile", + ], + deps = [ + "//rb/support:bundle", + ], +) + rb_binary( name = "bundle-update", args = [ - "rb/support/bundle_update.rb", + "rb/support/bundle.rb", + "update", ], data = [ "Gemfile", ], deps = [ - "//rb/support:bundle_update", + "//rb/support:bundle", ], ) diff --git a/rb/support/BUILD.bazel b/rb/support/BUILD.bazel index bbfc91213af24..0760303bd534c 100644 --- a/rb/support/BUILD.bazel +++ b/rb/support/BUILD.bazel @@ -8,8 +8,8 @@ rb_library( ) rb_library( - name = "bundle_update", - srcs = ["bundle_update.rb"], + name = "bundle", + srcs = ["bundle.rb"], ) rb_library( diff --git a/rb/support/bundle_update.rb b/rb/support/bundle.rb similarity index 87% rename from rb/support/bundle_update.rb rename to rb/support/bundle.rb index a47bfeee29ee3..24aa3129e4d61 100644 --- a/rb/support/bundle_update.rb +++ b/rb/support/bundle.rb @@ -35,5 +35,7 @@ FileUtils.mkdir_p(ENV["BUNDLE_PATH"]) +# The bundle subcommand (e.g. "lock" or "update") and any flags are supplied by +# the caller so a single script backs both //rb:bundle-lock and //rb:bundle-update. ruby = RbConfig.ruby -exec ruby, "-S", "bundle", "update", *ARGV +exec ruby, "-S", "bundle", *ARGV