Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Grouped Updates] Don't instantiate any groups without the feature flag #7557

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading