Skip to content

Commit

Permalink
Merge pull request #7557 from dependabot/brrygrdn/guard-group-eval-wi…
Browse files Browse the repository at this point in the history
…th-experiment

[Grouped Updates] Don't instantiate any groups without the feature flag
  • Loading branch information
brrygrdn committed Jul 14, 2023
2 parents 4e39370 + 0d141f7 commit d5ecf60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions updater/lib/dependabot/dependency_snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ def job_dependencies
# Returns just the group that is specifically requested to be updated by
# the job definition
def job_group
return nil unless Dependabot::Experiments.enabled?(:grouped_updates_prototype)
return nil unless job.dependency_group_to_refresh
return @job_group if defined?(@job_group)

@job_group = @dependency_group_engine.find_group(name: job.dependency_group_to_refresh)
end

def groups
return [] unless Dependabot::Experiments.enabled?(:grouped_updates_prototype)

@dependency_group_engine.dependency_groups
end

Expand All @@ -81,6 +84,9 @@ def initialize(job:, base_commit_sha:, dependency_files:)
@dependency_files = dependency_files

@dependencies = parse_files!

return unless Dependabot::Experiments.enabled?(:grouped_updates_prototype)

@dependency_group_engine = DependencyGroupEngine.from_job_config(job: job)
@dependency_group_engine.assign_to_groups!(dependencies: allowed_dependencies)
end
Expand Down
10 changes: 10 additions & 0 deletions updater/spec/dependabot/dependency_snapshot_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
end

it "correctly instantiates any configured dependency groups" do
Dependabot::Experiments.register("grouped_updates_prototype", true)

snapshot = create_dependency_snapshot

expect(snapshot.groups.length).to eql(1)
Expand All @@ -117,6 +119,14 @@

expect(snapshot.ungrouped_dependencies.length).to eql(1)
expect(snapshot.ungrouped_dependencies.first.name).to eql("dummy-pkg-b")

Dependabot::Experiments.reset!
end

it "ignores any configured dependency groups when the experiment is disabled" do
snapshot = create_dependency_snapshot

expect(snapshot.groups.length).to eql(0)
end
end

Expand Down

0 comments on commit d5ecf60

Please sign in to comment.