Skip to content

Commit 5f67d6a

Browse files
committed
Use domain-type inference for products, and add safety net to ResolveBundleDirectory
1 parent acd5d79 commit 5f67d6a

2 files changed

Lines changed: 30 additions & 15 deletions

File tree

src/services/Elastic.Changelog/Uploading/ChangelogUploadService.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ private List<string> ReadProductsFromFragment(string filePath)
164164
}
165165
}
166166

167-
private static readonly YamlDotNet.Serialization.IDeserializer BundleDeserializer =
168-
ReleaseNotesSerialization.GetEntryDeserializer();
169-
170167
internal IReadOnlyList<UploadTarget> DiscoverBundleUploadTargets(IDiagnosticsCollector collector, string bundleDir)
171168
{
172169
var rootDir = _fileSystem.DirectoryInfo.New(bundleDir);
@@ -216,14 +213,11 @@ private List<string> ReadProductsFromBundle(string filePath)
216213
try
217214
{
218215
var content = _fileSystem.File.ReadAllText(filePath);
219-
var bundle = BundleDeserializer.Deserialize<BundleDto>(content);
220-
if (bundle?.Products == null)
221-
return [];
216+
var bundle = ReleaseNotesSerialization.DeserializeBundle(content);
222217

223218
return bundle.Products
224-
.Select(p => p?.Product)
219+
.Select(p => p.ProductId)
225220
.Where(p => !string.IsNullOrWhiteSpace(p))
226-
.Select(p => p!)
227221
.Distinct()
228222
.ToList();
229223
}
@@ -255,6 +249,6 @@ private List<string> ReadProductsFromBundle(string filePath)
255249
return "docs/releases";
256250

257251
var config = await _configLoader.LoadChangelogConfiguration(collector, args.Config, ctx);
258-
return config?.Bundle?.OutputDirectory ?? "docs/releases";
252+
return config?.Bundle?.OutputDirectory ?? config?.Bundle?.Directory ?? "docs/releases";
259253
}
260254
}

tests/Elastic.Changelog.Tests/Uploading/ChangelogUploadServiceTests.cs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,16 @@ public async Task Upload_BundleArtifactType_UploadsToS3()
343343
- product: elasticsearch
344344
target: 9.2.0
345345
lifecycle: ga
346+
repo: elasticsearch
347+
owner: elastic
346348
entries:
347-
- title: New feature
348-
type: feature
349+
- file:
350+
name: 1234-feature.yaml
351+
checksum: abc123def456
352+
type: enhancement
353+
title: New feature
354+
prs:
355+
- https://github.com/elastic/elasticsearch/pull/1234
349356
"""));
350357

351358
A.CallTo(() => _s3Client.GetObjectMetadataAsync(A<GetObjectMetadataRequest>._, A<CancellationToken>._))
@@ -383,9 +390,16 @@ public void DiscoverBundleUploadTargets_MapsToCorrectS3Key()
383390
products:
384391
- product: elasticsearch
385392
target: 9.2.0
393+
repo: elasticsearch
394+
owner: elastic
386395
entries:
387-
- title: Feature
388-
type: feature
396+
- file:
397+
name: 5678-bugfix.yaml
398+
checksum: def789abc012
399+
type: bug-fix
400+
title: Fixed crash on startup
401+
prs:
402+
- https://github.com/elastic/elasticsearch/pull/5678
389403
"""));
390404

391405
var targets = _service.DiscoverBundleUploadTargets(_collector, bundleDir);
@@ -405,11 +419,18 @@ public void DiscoverBundleUploadTargets_MultipleProducts_CreatesTargetPerProduct
405419
products:
406420
- product: elasticsearch
407421
target: 9.2.0
422+
repo: elasticsearch
408423
- product: kibana
409424
target: 9.2.0
425+
repo: kibana
410426
entries:
411-
- title: Stack feature
412-
type: feature
427+
- file:
428+
name: 9999-cross-product.yaml
429+
checksum: aaa111bbb222
430+
type: enhancement
431+
title: Cross-product improvement
432+
prs:
433+
- https://github.com/elastic/elasticsearch/pull/9999
413434
"""));
414435

415436
var targets = _service.DiscoverBundleUploadTargets(_collector, bundleDir);

0 commit comments

Comments
 (0)