Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There was a bug reported where deploying a Ruby application after modifying the Gemfile.lock would result in an error because we were skipping running `bundle install`. Debugging this lead me to find that we were returning the incorrect value from our shared cache logic (accidentally returning the currnt/now value rather than the old value). The idea behind `cached_layer_write_metadata` is to either return the old cached data or return a message stating why it couldn't be returned. It was accidentally returning the new/current value instead. I added a unit test to assert this behavior. While developing I used an integration test to debug the issue (given below). This commit fixes the integration test given below: ## Gemfile.lock cache invalidation integration reproduction ``` $ cargo test test_gemfile_lock_invalidates_cache -- --exact ``` ``` #[test] fn test_gemfile_lock_invalidates_cache() { let app_dir = tempfile::tempdir().unwrap(); fs_err::write( app_dir.path().join("Gemfile"), r#" source "https://rubygems.org" gem "rake" "#, ) .unwrap(); fs_err::write( app_dir.path().join("Gemfile.lock"), r" GEM remote: https://rubygems.org/ specs: rake (13.2.0) PLATFORMS ruby DEPENDENCIES rake ", ) .unwrap(); let mut config = amd_arm_builder_config("heroku/builder:24", &app_dir.path().to_string_lossy()); TestRunner::default().build( config.clone() .buildpacks([ BuildpackReference::CurrentCrate, ]), |context| { let stdout = context.pack_stdout.clone(); println!("{}", stdout); assert_contains!(stdout, "# Heroku Ruby Buildpack"); assert_contains!( stdout, r#"`BUNDLE_BIN="/layers/heroku_ruby/gems/bin" BUNDLE_CLEAN="1" BUNDLE_DEPLOYMENT="1" BUNDLE_GEMFILE="/workspace/Gemfile" BUNDLE_PATH="/layers/heroku_ruby/gems" BUNDLE_WITHOUT="development:test" bundle install`"# ); assert_contains!(stdout, "Installing rake"); fs_err::write( app_dir.path().join("Gemfile.lock"), r" GEM remote: https://rubygems.org/ specs: rake (13.2.1) PLATFORMS ruby DEPENDENCIES rake ", ) .unwrap(); context.rebuild( config.buildpacks([BuildpackReference::CurrentCrate]), |rebuild_context| { println!("{}", rebuild_context.pack_stdout); assert_contains!( rebuild_context.pack_stdout, r#"`BUNDLE_BIN="/layers/heroku_ruby/gems/bin" BUNDLE_CLEAN="1" BUNDLE_DEPLOYMENT="1" BUNDLE_GEMFILE="/workspace/Gemfile" BUNDLE_PATH="/layers/heroku_ruby/gems" BUNDLE_WITHOUT="development:test" bundle install`"# ); assert_contains!(rebuild_context.pack_stdout, "Installing rake"); }, ); }); } ```
- Loading branch information