Skip to content
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
11 changes: 11 additions & 0 deletions updater/lib/dependabot/job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require "dependabot/experiments"
require "dependabot/source"
require "wildcard_matcher"

Expand Down Expand Up @@ -33,6 +34,8 @@ def initialize(attributes)
@update_subdependencies = attributes.fetch(:update_subdependencies)
@updating_a_pull_request = attributes.fetch(:updating_a_pull_request)
@vendor_dependencies = attributes.fetch(:vendor_dependencies, false)

register_experiments
end

def clone?
Expand Down Expand Up @@ -141,6 +144,14 @@ def commit_message_options

private

def register_experiments
experiments.each do |name, value|
Dependabot::Experiments.register(name, value)
end

Dependabot::Utils.register_always_clone("npm_and_yarn") if Dependabot::Experiments.enabled?(:yarn_berry)
end

def name_match?(name1, name2)
WildcardMatcher.match?(
name_normaliser.call(name1),
Expand Down
6 changes: 0 additions & 6 deletions updater/lib/dependabot/updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ def initialize(service:, job_id:, job:, dependency_files:,
def run
return unless job

job.experiments.each do |name, value|
Dependabot::Experiments.register(name, value)
end

Dependabot::Utils.register_always_clone("npm_and_yarn") if Dependabot::Experiments.enabled?(:yarn_berry)

if job.updating_a_pull_request?
logger_info("Starting PR update job for #{job.source.repo}")
check_and_update_existing_pr_with_error_handling(dependencies)
Expand Down
33 changes: 33 additions & 0 deletions updater/spec/dependabot/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@
it "transforms the keys" do
expect(job.experiments).to eq(simple: false, kebab_case: true)
end

it "registers the experiments with Dependabot::Experiments" do
job
expect(Dependabot::Experiments.enabled?(:kebab_case)).to be_truthy
expect(Dependabot::Experiments.enabled?(:simpe)).to be_falsey
end
end

context "with experimental values" do
Expand All @@ -286,6 +292,33 @@
expect(job.experiments).to eq(timeout_per_operation_seconds: 600)
end
end

describe "yarn_berry experiment" do
let(:experiments) { { "yarn_berry" => true } }
let(:package_manager) { "npm_and_yarn" }
let(:dependency) do
Dependabot::Dependency.new(
name: "ansi-regex",
package_manager: "npm_and_yarn",
version: "6.0.0",
requirements: [
{
file: "package.json",
requirement: "^6.0.0",
groups: ["devDependencies"],
source: {
type: "registry",
url: "https://registry.npmjs.org"
}
}
]
)
end

it "enables cloning when yarn_berry is enabled" do
expect(job.clone?).to be_truthy
end
end
end

describe "#commit_message_options" do
Expand Down