Skip to content

Commit 7af435d

Browse files
committed
Switch to using a string representation
1 parent b1c0c46 commit 7af435d

3 files changed

Lines changed: 19 additions & 23 deletions

File tree

updater/lib/github_api/dependency_submission.rb

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,17 @@ def payload
108108
url: SNAPSHOT_DETECTOR_URL
109109
},
110110
manifests: manifests,
111+
# TODO: Move use of metadata to a Dependabot-specific object
112+
#
113+
# We are using the existing job metadata as a bag-of-values for error handling
114+
# and job tracking that is specific to Dependabot-created submissions.
115+
#
116+
# In future, we should extend the public API schema with a validated object to
117+
# harden this contract.
111118
metadata: {
112119
status: status.serialize,
113120
reason: reason,
114-
scanned_manifest_paths: scanned_manifest_paths
121+
scanned_manifest_path: scanned_manifest_path
115122
}.compact
116123
}
117124
end
@@ -181,23 +188,15 @@ def manifests
181188
}
182189
end
183190

184-
# Returns the manifest paths this snapshot scanned.
191+
# Returns a synopsis of the scan performed in the format `ecosystem::manifest_path`, e.g.
192+
# - `golang::/`
193+
# - `rubygems::rails_app/`
185194
#
186-
# This allows the snapshot service to check the snapshot against those requested
187-
# even if the `manifests` property is empty.
188-
#
189-
# Note: We currently submit each manifest path separately, but we use an array
190-
# to align with the `manifests` property and allow flexibility in future.
191195
sig do
192-
returns(T::Array[T::Hash[Symbol, String]])
196+
returns(String)
193197
end
194-
def scanned_manifest_paths
195-
[
196-
{
197-
ecosystem: GithubApi::EcosystemMapper.ecosystem_for(package_manager),
198-
manifest_path: File.dirname(manifest_file.path)
199-
}
200-
]
198+
def scanned_manifest_path
199+
"#{GithubApi::EcosystemMapper.ecosystem_for(package_manager)}::#{File.dirname(manifest_file.path)}"
201200
end
202201
end
203202
end

updater/spec/dependabot/update_graph_processor_spec.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@
388388
# It should contain the expected metadata
389389
expect(payload[:metadata][:status]).to eql(GithubApi::DependencySubmission::SnapshotStatus::FAILED.serialize)
390390
expect(payload[:metadata][:reason]).to eql("dependency_file_not_evaluatable")
391-
expect(payload[:metadata][:scanned_manifest_paths]).to eql([{ ecosystem: "rubygems", manifest_path: "/" }])
391+
expect(payload[:metadata][:scanned_manifest_path]).to eql("rubygems::/")
392392
end
393393

394394
it "correctly snapshots the second directory" do
@@ -419,10 +419,7 @@
419419
# We should have metadata indicating a successful snapshot
420420
expect(payload[:metadata][:status]).to eql(GithubApi::DependencySubmission::SnapshotStatus::SUCCESS.serialize)
421421
expect(payload[:metadata][:reason]).to be_nil
422-
expect(payload[:metadata][:scanned_manifest_paths]).to eql(
423-
[{ ecosystem: "rubygems",
424-
manifest_path: "/subproject" }]
425-
)
422+
expect(payload[:metadata][:scanned_manifest_path]).to eql("rubygems::/subproject")
426423
end
427424
end
428425
end
@@ -562,7 +559,7 @@
562559
# It should contain the expected metadata
563560
expect(payload[:metadata][:status]).to eq(GithubApi::DependencySubmission::SnapshotStatus::SKIPPED.serialize)
564561
expect(payload[:metadata][:reason]).to eq(GithubApi::DependencySubmission::EMPTY_REASON_NO_MANIFESTS)
565-
expect(payload[:metadata][:scanned_manifest_paths]).to eql([{ ecosystem: "rubygems", manifest_path: "/" }])
562+
expect(payload[:metadata][:scanned_manifest_path]).to eql("rubygems::/")
566563
end
567564

568565
update_graph_processor.run
@@ -671,7 +668,7 @@ def fetch_subdependencies(_dependency)
671668
# We should have metadata indicating a successful snapshot
672669
expect(payload[:metadata][:status]).to eql(GithubApi::DependencySubmission::SnapshotStatus::DEGRADED.serialize)
673670
expect(payload[:metadata][:reason]).to eql(GithubApi::DependencySubmission::DEGRADED_REASON_SUBDEPENDENCY_ERR)
674-
expect(payload[:metadata][:scanned_manifest_paths]).to eql([{ ecosystem: "rubygems", manifest_path: "/" }])
671+
expect(payload[:metadata][:scanned_manifest_path]).to eql("rubygems::/")
675672
end
676673

677674
expect(service).to receive(:record_update_job_warning) do |args|

updater/spec/github_api/dependency_submission_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
# Check dependabot-specific metadata keys
116116
expect(payload[:metadata][:status]).to eql("ok")
117117
expect(payload[:metadata][:reason]).to be_nil
118-
expect(payload[:metadata][:scanned_manifest_paths]).to eql([{ ecosystem: "rubygems", manifest_path: "/" }])
118+
expect(payload[:metadata][:scanned_manifest_path]).to eql("rubygems::/")
119119
end
120120

121121
it "affixes to use the updater sha if available" do

0 commit comments

Comments
 (0)