Skip to content

Commit

Permalink
Fix Gemfile to be compatible with dependabot.
Browse files Browse the repository at this point in the history
My earlier attempts (e.g. #82) did not work. Using the `dry_run` script[^1],
I've discovered that dependabot runs bundler commands in a temporary
directory that only contains _some_ of the source controlled files (e.g.
the `Gemfile`, `*.gemspec` files, etc). To be compatible with dependabot,
our `Gemfile` cannot assume the presence of any files beyond these.

[^1]: https://github.com/dependabot/dependabot-core/blob/v0.291.0/bin/dry-run.rb
  • Loading branch information
myronmarston committed Jan 1, 2025
1 parent 83be56f commit b6ad8fd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@ group :site do
end

# Since this file gets symlinked both at the repo root and into each Gem directory, we have
# to dynamically detect the repo root, by looking for a file that only exists at the root.
repo_root = ::Pathname.new(::Dir.pwd).ascend.find { |dir| ::File.exist?("#{dir}/CODE_OF_CONDUCT.md") }.to_s
# to dynamically detect the repo root, by looking for one of the subdirs at the root.
repo_root = ::Pathname.new(__dir__).ascend.find { |dir| ::Dir.exist?("#{dir}/elasticgraph-support") }.to_s

# `tmp` and `log` are git-ignored but many of our build tasks and scripts expect them to exist.
# We create them here since `Gemfile` evaluation happens before anything else.
::FileUtils.mkdir_p("#{repo_root}/log")
::FileUtils.mkdir_p("#{repo_root}/tmp")

# Identify the gems that live in the ElasticGraph repository.
require "#{repo_root}/script/list_eg_gems"
gems_in_this_repo = ::ElasticGraphGems.list.to_set
gems_in_this_repo = ::Dir.glob("#{repo_root}/*/*.gemspec").map do |gemspec|
::File.basename(::File.dirname(gemspec))
end.to_set

# Here we override the `gem` method to automatically add the ElasticGraph version
# to all ElasticGraph gems. If we don't do this, we can get confusing bundler warnings
Expand Down

0 comments on commit b6ad8fd

Please sign in to comment.