diff --git a/bin/dry-run.rb b/bin/dry-run.rb index 4a63eeb1c6d..492b425fda4 100755 --- a/bin/dry-run.rb +++ b/bin/dry-run.rb @@ -83,6 +83,7 @@ require "dependabot/file_updaters" require "dependabot/pull_request_creator" require "dependabot/config/file_fetcher" +require "dependabot/simple_instrumentor" require "dependabot/bundler" require "dependabot/cargo" @@ -477,7 +478,7 @@ def log_conflicting_dependencies(conflicting_dependencies) StackProf.start(raw: true) if $options[:profile] $network_trace_count = 0 -ActiveSupport::Notifications.subscribe(/excon/) do |*args| +Dependabot::SimpleInstrumentor.subscribe do |*args| name = args.first $network_trace_count += 1 if name == "excon.request" @@ -488,11 +489,6 @@ def log_conflicting_dependencies(conflicting_dependencies) end end -$package_manager_version_log = [] -Dependabot.subscribe(Dependabot::Notifications::FILE_PARSER_PACKAGE_MANAGER_VERSION_PARSED) do |*args| - $package_manager_version_log << args.last -end - $source = Dependabot::Source.new( provider: $options[:provider], repo: $repo_name, @@ -804,7 +800,8 @@ def security_fix?(dependency) StackProf.results("tmp/stackprof-#{Time.now.strftime('%Y-%m-%d-%H:%M')}.dump") if $options[:profile] puts "🌍 Total requests made: '#{$network_trace_count}'" -puts "🎈 Package manager version log: #{$package_manager_version_log.join('\n')}" if $package_manager_version_log.any? +package_manager = fetcher.package_manager_version +puts "🎈 Package manager version log: #{package_manager}" unless package_manager.nil? # rubocop:enable Metrics/BlockLength diff --git a/bundler/lib/dependabot/bundler/file_fetcher.rb b/bundler/lib/dependabot/bundler/file_fetcher.rb index bf6b43efb90..3ef18aba58c 100644 --- a/bundler/lib/dependabot/bundler/file_fetcher.rb +++ b/bundler/lib/dependabot/bundler/file_fetcher.rb @@ -23,6 +23,15 @@ def self.required_files_message "Repo must contain either a Gemfile, a gemspec, or a gems.rb." end + def package_manager_version + { + ecosystem: "bundler", + package_managers: { + "bundler" => Helpers.detected_bundler_version(lockfile) + } + } + end + private def fetch_files diff --git a/bundler/lib/dependabot/bundler/file_parser.rb b/bundler/lib/dependabot/bundler/file_parser.rb index 407879f941c..859df9bdfdb 100644 --- a/bundler/lib/dependabot/bundler/file_parser.rb +++ b/bundler/lib/dependabot/bundler/file_parser.rb @@ -24,7 +24,6 @@ def parse dependency_set += gemspec_dependencies dependency_set += lockfile_dependencies check_external_code(dependency_set.dependencies) - instrument_package_manager_version dependency_set.dependencies end @@ -44,17 +43,6 @@ def git_source?(dependencies) end end - def instrument_package_manager_version - version = Helpers.detected_bundler_version(lockfile) - Dependabot.instrument( - Notifications::FILE_PARSER_PACKAGE_MANAGER_VERSION_PARSED, - ecosystem: "bundler", - package_managers: { - "bundler" => version - } - ) - end - def gemfile_dependencies dependencies = DependencySet.new diff --git a/bundler/spec/dependabot/bundler/file_parser_spec.rb b/bundler/spec/dependabot/bundler/file_parser_spec.rb index c8d824ec837..ec8a5828aad 100644 --- a/bundler/spec/dependabot/bundler/file_parser_spec.rb +++ b/bundler/spec/dependabot/bundler/file_parser_spec.rb @@ -828,18 +828,5 @@ end end end - - it "instruments the package manager version" do - events = [] - Dependabot.subscribe(Dependabot::Notifications::FILE_PARSER_PACKAGE_MANAGER_VERSION_PARSED) do |*args| - events << ActiveSupport::Notifications::Event.new(*args) - end - - parser.parse - - expect(events.last.payload).to eq( - { ecosystem: "bundler", package_managers: { "bundler" => PackageManagerHelper.bundler_version } } - ) - end end end diff --git a/common/dependabot-common.gemspec b/common/dependabot-common.gemspec index 82b5fe23321..01c8a9ea184 100644 --- a/common/dependabot-common.gemspec +++ b/common/dependabot-common.gemspec @@ -20,7 +20,6 @@ Gem::Specification.new do |spec| spec.required_ruby_version = ">= 3.1.0" spec.required_rubygems_version = ">= 3.3.7" - spec.add_dependency "activesupport", ">= 6.0.0" spec.add_dependency "aws-sdk-codecommit", "~> 1.28" spec.add_dependency "aws-sdk-ecr", "~> 1.5" spec.add_dependency "bundler", ">= 1.16", "< 3.0.0" diff --git a/common/lib/dependabot/file_fetchers/base.rb b/common/lib/dependabot/file_fetchers/base.rb index 32a6ca12413..dce0ca5dd55 100644 --- a/common/lib/dependabot/file_fetchers/base.rb +++ b/common/lib/dependabot/file_fetchers/base.rb @@ -100,6 +100,10 @@ def clone_repo_contents raise Dependabot::RepoNotFound, source end + def package_manager_version + nil + end + private def fetch_file_if_present(filename, fetch_submodules: false) diff --git a/common/lib/dependabot/file_parsers/base.rb b/common/lib/dependabot/file_parsers/base.rb index fa9ce612b9c..7c4c7be95de 100644 --- a/common/lib/dependabot/file_parsers/base.rb +++ b/common/lib/dependabot/file_parsers/base.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "dependabot/notifications" - module Dependabot module FileParsers class Base diff --git a/common/lib/dependabot/notifications.rb b/common/lib/dependabot/notifications.rb deleted file mode 100644 index f398e510a92..00000000000 --- a/common/lib/dependabot/notifications.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require "active_support" -require "active_support/notifications" - -module Dependabot - module Notifications - FILE_PARSER_PACKAGE_MANAGER_VERSION_PARSED = "dependabot.file_parser.package_manager_version_parsed" - end - - def self.instrument(name, payload = {}) - ActiveSupport::Notifications.instrument(name, payload) - end - - def self.subscribe(pattern = nil, callback = nil, &block) - ActiveSupport::Notifications.subscribe(pattern, callback, &block) - end -end diff --git a/common/lib/dependabot/shared_helpers.rb b/common/lib/dependabot/shared_helpers.rb index 2f665f0b6df..780eb12bcd3 100644 --- a/common/lib/dependabot/shared_helpers.rb +++ b/common/lib/dependabot/shared_helpers.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require "active_support/notifications" require "digest" require "English" require "excon" @@ -10,6 +9,7 @@ require "shellwords" require "tmpdir" +require "dependabot/simple_instrumentor" require "dependabot/utils" require "dependabot/errors" require "dependabot" @@ -152,7 +152,7 @@ def self.excon_defaults(options = nil) options ||= {} headers = options.delete(:headers) { - instrumentor: ActiveSupport::Notifications, + instrumentor: Dependabot::SimpleInstrumentor, connect_timeout: 5, write_timeout: 5, read_timeout: 20, diff --git a/common/lib/dependabot/simple_instrumentor.rb b/common/lib/dependabot/simple_instrumentor.rb new file mode 100644 index 00000000000..3d2406fc8ad --- /dev/null +++ b/common/lib/dependabot/simple_instrumentor.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Dependabot + module SimpleInstrumentor + class << self + attr_accessor :events, :subscribers + + def subscribe(&block) + @subscribers ||= [] + @subscribers << block + end + + def instrument(name, params = {}, &block) + @subscribers&.each { |s| s.call(name, params) } + yield if block + end + end + end +end diff --git a/common/spec/dependabot/shared_helpers_spec.rb b/common/spec/dependabot/shared_helpers_spec.rb index d970688c542..bb08fb92003 100644 --- a/common/spec/dependabot/shared_helpers_spec.rb +++ b/common/spec/dependabot/shared_helpers_spec.rb @@ -2,6 +2,7 @@ require "spec_helper" require "dependabot/shared_helpers" +require "dependabot/simple_instrumentor" RSpec.describe Dependabot::SharedHelpers do let(:spec_root) { File.join(File.dirname(__FILE__), "..") } @@ -301,7 +302,7 @@ def existing_tmp_folders it "includes the defaults" do expect(subject).to eq( - instrumentor: ActiveSupport::Notifications, + instrumentor: Dependabot::SimpleInstrumentor, connect_timeout: 5, write_timeout: 5, read_timeout: 20, diff --git a/maven/lib/dependabot/maven/metadata_finder.rb b/maven/lib/dependabot/maven/metadata_finder.rb index 699ade449de..a3fff8dfc16 100644 --- a/maven/lib/dependabot/maven/metadata_finder.rb +++ b/maven/lib/dependabot/maven/metadata_finder.rb @@ -42,7 +42,7 @@ def repo_has_subdir_for_dep?(tmp_source) any? { |f| dependency_artifact_id.end_with?(f.name) } rescue Dependabot::BranchNotFound # If we are attempting to find a branch, we should fail over to the default branch and retry once only - if tmp_source.branch.present? + unless tmp_source.branch.to_s.empty? tmp_source.branch = nil retry end diff --git a/maven/lib/dependabot/maven/update_checker/version_finder.rb b/maven/lib/dependabot/maven/update_checker/version_finder.rb index efd34d0ac70..df75e1814f4 100644 --- a/maven/lib/dependabot/maven/update_checker/version_finder.rb +++ b/maven/lib/dependabot/maven/update_checker/version_finder.rb @@ -58,7 +58,7 @@ def versions repositories.map do |repository_details| url = repository_details.fetch("url") xml = dependency_metadata(repository_details) - next [] if xml.blank? + next [] if xml.nil? break xml.css("versions > version"). select { |node| version_class.correct?(node.content) }. diff --git a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_fetcher.rb b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_fetcher.rb index 0d4bc591dd6..7b1911c8d77 100644 --- a/npm_and_yarn/lib/dependabot/npm_and_yarn/file_fetcher.rb +++ b/npm_and_yarn/lib/dependabot/npm_and_yarn/file_fetcher.rb @@ -50,6 +50,19 @@ def clone_repo_contents end end + def package_manager_version + package_managers = {} + + package_managers["npm"] = Helpers.npm_version_numeric(package_lock.content) if package_lock + package_managers["yarn"] = yarn_version if yarn_version + package_managers["shrinkwrap"] = 1 if shrinkwrap + + { + ecosystem: "npm", + package_managers: package_managers + } + end + private def fetch_files @@ -65,7 +78,6 @@ def fetch_files fetched_files += workspace_package_jsons fetched_files += lerna_packages fetched_files += path_dependencies(fetched_files) - instrument_package_manager_version fetched_files << inferred_npmrc if inferred_npmrc @@ -103,20 +115,6 @@ def inferred_npmrc @inferred_npmrc = nil end - def instrument_package_manager_version - package_managers = {} - - package_managers["npm"] = Helpers.npm_version_numeric(package_lock.content) if package_lock - package_managers["yarn"] = yarn_version if yarn_version - package_managers["shrinkwrap"] = 1 if shrinkwrap - - Dependabot.instrument( - Notifications::FILE_PARSER_PACKAGE_MANAGER_VERSION_PARSED, - ecosystem: "npm", - package_managers: package_managers - ) - end - def yarn_version return @yarn_version if defined?(@yarn_version) diff --git a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher_spec.rb b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher_spec.rb index c346e6cf322..c8b941f7b43 100644 --- a/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher_spec.rb +++ b/npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher_spec.rb @@ -28,7 +28,6 @@ }] end let(:json_header) { { "content-type" => "application/json" } } - let(:events) { [] } before do allow(file_fetcher_instance).to receive(:commit).and_return("sha") @@ -56,10 +55,6 @@ body: fixture("github", "package_lock_content.json"), headers: json_header ) - - Dependabot.subscribe(Dependabot::Notifications::FILE_PARSER_PACKAGE_MANAGER_VERSION_PARSED) do |*args| - events << ActiveSupport::Notifications::Event.new(*args) - end end context "with .yarn data stored in git-lfs" do @@ -286,9 +281,8 @@ to match_array(%w(package.json yarn.lock)) end - it "instruments the yarn lockfile" do - file_fetcher_instance.files - expect(events.last.payload).to eq( + it "parses the yarn lockfile" do + expect(file_fetcher_instance.package_manager_version).to eq( { ecosystem: "npm", package_managers: { "yarn" => 1 } } ) end @@ -345,9 +339,8 @@ to match_array(%w(package.json npm-shrinkwrap.json)) end - it "instruments the shrinkwrap file" do - file_fetcher_instance.files - expect(events.last.payload).to eq( + it "parses the shrinkwrap file" do + expect(file_fetcher_instance.package_manager_version).to eq( { ecosystem: "npm", package_managers: { "shrinkwrap" => 1 } } ) end @@ -379,9 +372,8 @@ to match_array(%w(package.json package-lock.json)) end - it "instruments the npm lockfile" do - file_fetcher_instance.files - expect(events.last.payload).to eq( + it "parses the npm lockfile" do + expect(file_fetcher_instance.package_manager_version).to eq( { ecosystem: "npm", package_managers: { "npm" => 6 } } ) end @@ -417,9 +409,8 @@ to match_array(%w(package.json package-lock.json yarn.lock)) end - it "instruments the npm and yarn lockfiles" do - file_fetcher_instance.files - expect(events.last.payload).to eq( + it "parses the package manager version" do + expect(file_fetcher_instance.package_manager_version).to eq( { ecosystem: "npm", package_managers: { "npm" => 6, "yarn" => 1 } } ) end diff --git a/terraform/lib/dependabot/terraform/file_parser.rb b/terraform/lib/dependabot/terraform/file_parser.rb index bbf2055097e..27fb5a783f4 100644 --- a/terraform/lib/dependabot/terraform/file_parser.rb +++ b/terraform/lib/dependabot/terraform/file_parser.rb @@ -186,10 +186,12 @@ def source_from(details_hash) def provider_source_from(source_address, name) matches = source_address&.match(PROVIDER_SOURCE_ADDRESS) + matches = {} if matches.nil? + [ - matches.try(:[], :hostname) || DEFAULT_REGISTRY, - matches.try(:[], :namespace) || DEFAULT_NAMESPACE, - matches.try(:[], :name) || name + matches[:hostname] || DEFAULT_REGISTRY, + matches[:namespace] || DEFAULT_NAMESPACE, + matches[:name] || name ] end diff --git a/updater/Gemfile b/updater/Gemfile index 829067378a9..b4f14aa60f7 100644 --- a/updater/Gemfile +++ b/updater/Gemfile @@ -20,7 +20,6 @@ gem "dependabot-pub", path: "../pub" gem "dependabot-python", path: "../python" gem "dependabot-terraform", path: "../terraform" -gem "activesupport", "~> 6.1.7" gem "http", "~> 5.1" gem "octokit", "6.0.1" gem "sentry-raven", "~> 3.1" diff --git a/updater/Gemfile.lock b/updater/Gemfile.lock index 47072be8bd9..a967b1b3d0f 100644 --- a/updater/Gemfile.lock +++ b/updater/Gemfile.lock @@ -14,7 +14,6 @@ PATH remote: ../common specs: dependabot-common (0.215.0) - activesupport (>= 6.0.0) aws-sdk-codecommit (~> 1.28) aws-sdk-ecr (~> 1.5) bundler (>= 1.16, < 3.0.0) @@ -118,12 +117,6 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (6.1.7) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) @@ -302,7 +295,6 @@ PLATFORMS ruby DEPENDENCIES - activesupport (~> 6.1.7) debug (~> 1.7.1) dependabot-bundler! dependabot-cargo! diff --git a/updater/lib/dependabot/file_fetcher_job.rb b/updater/lib/dependabot/file_fetcher_job.rb index 90a28c57efc..ac05dc394a3 100644 --- a/updater/lib/dependabot/file_fetcher_job.rb +++ b/updater/lib/dependabot/file_fetcher_job.rb @@ -16,6 +16,13 @@ def perform_job @base_commit_sha = file_fetcher.commit raise "base commit SHA not found" unless @base_commit_sha + version = file_fetcher.package_manager_version + unless version.nil? + api_client.record_package_manager_version( + Dependabot::Environment.job_id, version[:ecosystem], version[:package_managers] + ) + end + dependency_files rescue StandardError => e @base_commit_sha ||= "unknown" diff --git a/updater/lib/dependabot/instrumentation.rb b/updater/lib/dependabot/instrumentation.rb deleted file mode 100644 index e32fc4237b4..00000000000 --- a/updater/lib/dependabot/instrumentation.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -require "dependabot/api_client" -require "dependabot/notifications" -require "active_support/notifications" -require "dependabot/environment" - -Dependabot.subscribe(Dependabot::Notifications::FILE_PARSER_PACKAGE_MANAGER_VERSION_PARSED) do |*args| - event = ActiveSupport::Notifications::Event.new(*args) - ecosystem = event.payload[:ecosystem] - package_managers = event.payload[:package_managers] - - next unless ecosystem && package_managers - - Dependabot::ApiClient.new(Dependabot::Environment.api_url, Dependabot::Environment.token). - record_package_manager_version( - Dependabot::Environment.job_id, ecosystem, package_managers - ) -end diff --git a/updater/lib/dependabot/service.rb b/updater/lib/dependabot/service.rb index b7a609cb7d5..e4e7b550477 100644 --- a/updater/lib/dependabot/service.rb +++ b/updater/lib/dependabot/service.rb @@ -8,6 +8,7 @@ # module Dependabot class Service + extend Forwardable attr_reader :client, :events, :pull_requests, :errors def initialize(client:) @@ -16,7 +17,7 @@ def initialize(client:) @errors = [] end - delegate :get_job, :mark_job_as_processed, :update_dependency_list, :record_package_manager_version, to: :@client + def_delegators :client, :get_job, :mark_job_as_processed, :update_dependency_list, :record_package_manager_version def create_pull_request(job_id, dependencies, updated_dependency_files, base_commit_sha, pr_message) client.create_pull_request(job_id, dependencies, updated_dependency_files, base_commit_sha, pr_message) diff --git a/updater/lib/dependabot/setup.rb b/updater/lib/dependabot/setup.rb index a4227ee1e2a..7a7ff24c97d 100644 --- a/updater/lib/dependabot/setup.rb +++ b/updater/lib/dependabot/setup.rb @@ -67,5 +67,3 @@ def call(severity, _datetime, _progname, msg) require "dependabot/npm_and_yarn" require "dependabot/bundler" require "dependabot/pub" - -require "dependabot/instrumentation" diff --git a/updater/licenses/bundler/activesupport.dep.yml b/updater/licenses/bundler/activesupport.dep.yml deleted file mode 100644 index 47019652a43..00000000000 --- a/updater/licenses/bundler/activesupport.dep.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -name: activesupport -version: 6.1.4.4 -type: bundler -summary: A toolkit of support libraries and Ruby core extensions extracted from the - Rails framework. -homepage: https://rubyonrails.org -license: mit -licenses: -- sources: MIT-LICENSE - text: | - Copyright (c) 2005-2020 David Heinemeier Hansson - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- sources: README.rdoc - text: |- - Active Support is released under the MIT license: - - * https://opensource.org/licenses/MIT -notices: [] diff --git a/updater/spec/bin_run_spec.rb b/updater/spec/bin_run_spec.rb deleted file mode 100644 index ef55b4ec9e7..00000000000 --- a/updater/spec/bin_run_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -require "json" -require "spec_helper" - -RSpec.describe "bin/run" do - describe "fetch_files" do - around do |example| - Dir.mktmpdir do |tempdir| - output_path = File.join(tempdir, "output.json") - job_path = File.join(tempdir, "job.json") - - job_info = JSON.parse(File.read("spec/fixtures/jobs/job_with_credentials.json")) - job_info["credentials"][0]["password"] = test_access_token - - File.write(job_path, JSON.dump(job_info)) - - ENV["DEPENDABOT_JOB_ID"] = "1" - ENV["DEPENDABOT_JOB_TOKEN"] = "token" - ENV["DEPENDABOT_JOB_PATH"] = job_path - ENV["DEPENDABOT_OUTPUT_PATH"] = output_path - ENV["DEPENDABOT_API_URL"] = "http://example.com" - - example.run - ensure - ENV["DEPENDABOT_JOB_ID"] = nil - ENV["DEPENDABOT_JOB_TOKEN"] = nil - ENV["DEPENDABOT_JOB_PATH"] = nil - ENV["DEPENDABOT_OUTPUT_PATH"] = nil - ENV["DEPENDABOT_API_URL"] = nil - end - end - - it "completes the job successfully and persists the files" do - result = `bin/run fetch_files` - expect(result).to include("Starting job processing") - expect(result).to include("Finished job processing") - job_output = JSON.parse(File.read(ENV.fetch("DEPENDABOT_OUTPUT_PATH", nil))) - expect(job_output.fetch("base64_dependency_files").length).to eq(1) - end - end -end diff --git a/updater/spec/dependabot/file_fetcher_job_spec.rb b/updater/spec/dependabot/file_fetcher_job_spec.rb index 1d42487c710..fdb617aacd4 100644 --- a/updater/spec/dependabot/file_fetcher_job_spec.rb +++ b/updater/spec/dependabot/file_fetcher_job_spec.rb @@ -17,8 +17,10 @@ allow(api_client).to receive(:mark_job_as_processed) allow(api_client).to receive(:record_update_job_error) + allow(api_client).to receive(:record_package_manager_version) allow(Dependabot::Environment).to receive(:output_path).and_return(File.join(Dir.mktmpdir, "output.json")) + allow(Dependabot::Environment).to receive(:job_id).and_return(job_id) end describe "#perform_job" do @@ -110,6 +112,9 @@ allow_any_instance_of(Dependabot::Bundler::FileFetcher). to receive(:files). and_raise(exception) + allow_any_instance_of(Dependabot::Bundler::FileFetcher). + to receive(:package_manager_version). + and_return(nil) end it "retries the job when the rate-limit is reset and reports api error" do diff --git a/updater/spec/dependabot/instrumentation_spec.rb b/updater/spec/dependabot/instrumentation_spec.rb deleted file mode 100644 index 984e3af5591..00000000000 --- a/updater/spec/dependabot/instrumentation_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" -require "dependabot/api_client" -require "dependabot/instrumentation" - -RSpec.describe "dependabot instrumentation" do - describe ".subscribe" do - it "relays package manager versions to core" do - allow(Dependabot::Environment).to receive(:job_id).and_return(1) - allow(Dependabot::Environment).to receive(:token).and_return("some_token") - - expect_any_instance_of(Dependabot::ApiClient).to receive(:record_package_manager_version).with( - 1, "bundler", { "bundler" => "1" } - ) - - Dependabot.instrument( - Dependabot::Notifications::FILE_PARSER_PACKAGE_MANAGER_VERSION_PARSED, - { ecosystem: "bundler", package_managers: { "bundler" => "1" } } - ) - end - end -end diff --git a/updater/spec/dependabot/integration_spec.rb b/updater/spec/dependabot/integration_spec.rb index bc3975101fc..d5130300bfb 100644 --- a/updater/spec/dependabot/integration_spec.rb +++ b/updater/spec/dependabot/integration_spec.rb @@ -6,7 +6,6 @@ require "dependabot/file_fetchers" require "dependabot/end_to_end_job" require "dependabot/api_client" -require "dependabot/instrumentation" RSpec.describe Dependabot::EndToEndJob do subject(:end_to_end_job) { Dependabot::EndToEndJob.new } @@ -32,6 +31,7 @@ allow(api_client).to receive(:mark_job_as_processed) allow(api_client).to receive(:update_dependency_list) allow(api_client).to receive(:record_update_job_error) + allow(api_client).to receive(:record_package_manager_version) # Recording the package manager happens via an observer so the instantiated `api_client` does not receive this call allow_any_instance_of(Dependabot::ApiClient).to receive(:record_package_manager_version) @@ -162,12 +162,6 @@ end_to_end_job.run end - it "instruments the package manager version" do - expect_any_instance_of(Dependabot::ApiClient).to receive(:record_package_manager_version) - - end_to_end_job.run - end - context "when there is an exception that blocks PR creation" do before do allow(api_client).to receive(:create_pull_request).and_raise(StandardError, "oh no!")