Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 217e3fb

Browse files
Merge pull request #599 from NuGet/dev
RI - Dev to master
2 parents 44fdc21 + 418a50f commit 217e3fb

27 files changed

Lines changed: 502 additions & 306 deletions

build.ps1

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,17 @@ Invoke-BuildStep 'Creating artifacts' {
129129
# We need a few projects to be published for sharing the common bits with other repos.
130130
# We need symbols published for those, too. All other packages are deployment ones and
131131
# don't need to be shared, hence no need for symbols for them
132-
$ProjectsWithSymbols =
132+
$CsprojProjects =
133133
"src/NuGet.Jobs.Common/NuGet.Jobs.Common.csproj",
134134
"src/Validation.Common.Job/Validation.Common.Job.csproj",
135135
"src/Validation.ScanAndSign.Core/Validation.ScanAndSign.Core.csproj",
136136
"src/Validation.Symbols.Core/Validation.Symbols.Core.csproj"
137137

138-
$Projects = `
138+
$CsprojProjects | ForEach-Object {
139+
New-ProjectPackage (Join-Path $PSScriptRoot $_) -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch -Symbols
140+
}
141+
142+
$NuspecProjects = `
139143
"src/Stats.CollectAzureCdnLogs/Stats.CollectAzureCdnLogs.csproj", `
140144
"src/Stats.AggregateCdnDownloadsInGallery/Stats.AggregateCdnDownloadsInGallery.csproj", `
141145
"src/Stats.ImportAzureCdnStatistics/Stats.ImportAzureCdnStatistics.csproj", `
@@ -161,12 +165,10 @@ Invoke-BuildStep 'Creating artifacts' {
161165
"src/Monitoring.RebootSearchInstance/Monitoring.RebootSearchInstance.csproj", `
162166
"src/StatusAggregator/StatusAggregator.csproj", `
163167
"src/Validation.Symbols.Core/Validation.Symbols.Core.csproj", `
164-
"src/Validation.Symbols/Validation.Symbols.csproj" `
165-
+ $ProjectsWithSymbols
168+
"src/Validation.Symbols/Validation.Symbols.csproj"
166169

167-
Foreach ($Project in $Projects) {
168-
$Symbols = $ProjectsWithSymbols -contains $Project;
169-
New-Package (Join-Path $PSScriptRoot "$Project") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch -MSBuildVersion "$msBuildVersion" -Symbols:$Symbols
170+
Foreach ($Project in $NuspecProjects) {
171+
New-Package (Join-Path $PSScriptRoot "$Project") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch -MSBuildVersion "$msBuildVersion"
170172
}
171173
} `
172174
-ev +BuildErrors

src/NuGet.Jobs.Common/NuGet.Jobs.Common.csproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
<DefineConstants>TRACE</DefineConstants>
1616
<TargetFrameworkProfile />
1717
</PropertyGroup>
18+
<PropertyGroup>
19+
<Authors>.NET Foundation</Authors>
20+
<IncludeSymbols Condition="'$(IncludeSymbols)' == ''">true</IncludeSymbols>
21+
</PropertyGroup>
1822
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1923
<DebugSymbols>true</DebugSymbols>
2024
<DebugType>full</DebugType>
@@ -95,14 +99,16 @@
9599
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions">
96100
<Version>1.1.2</Version>
97101
</PackageReference>
98-
<PackageReference Include="NuGet.Services.Configuration">
99-
<Version>2.27.0</Version>
102+
<PackageReference Include="NuGet.Build.Tasks.Pack">
103+
<Version>4.8.0</Version>
104+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
105+
<PrivateAssets>all</PrivateAssets>
100106
</PackageReference>
101-
<PackageReference Include="NuGet.Services.KeyVault">
107+
<PackageReference Include="NuGet.Services.Configuration">
102108
<Version>2.29.0</Version>
103109
</PackageReference>
104110
<PackageReference Include="NuGet.Services.Logging">
105-
<Version>2.27.0</Version>
111+
<Version>2.29.0</Version>
106112
</PackageReference>
107113
<PackageReference Include="NuGet.Services.Sql">
108114
<Version>2.29.0</Version>

src/NuGet.Services.Validation.Orchestrator/Configuration/CoreMessageServiceConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
using System;
55
using System.Net.Mail;
66
using Microsoft.Extensions.Options;
7-
using NuGetGallery.Services;
7+
using NuGetGallery.Infrastructure.Mail;
88

99
namespace NuGet.Services.Validation.Orchestrator
1010
{
11-
public class CoreMessageServiceConfiguration : ICoreMessageServiceConfiguration
11+
public class CoreMessageServiceConfiguration : IMessageServiceConfiguration
1212
{
1313
public CoreMessageServiceConfiguration(IOptionsSnapshot<EmailConfiguration> emailConfigurationAccessor)
1414
{

src/NuGet.Services.Validation.Orchestrator/IValidationPackageFileService.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,13 @@ Task CopyValidationSetPackageToPackageFileAsync(
123123
/// <exception cref="Microsoft.WindowsAzure.Storage.StorageException">Thrown if the blob has changed between
124124
/// successive read and write operations.</exception>
125125
Task<PackageStreamMetadata> UpdatePackageBlobMetadataAsync(PackageValidationSet validationSet);
126+
127+
/// <summary>
128+
/// Reads the ETag for the package in the public container.
129+
/// </summary>
130+
/// <param name="validationSet">A validationSet that will identify the package that will have its blob metadata updated.</param>
131+
/// <returns>A task that represents the asynchronous operation.
132+
/// The result is the etag of the package blob or null if the package does not exists.</returns>
133+
Task<string> GetPublicPackageBlobETagOrNullAsync(PackageValidationSet validationSet);
126134
}
127135
}

src/NuGet.Services.Validation.Orchestrator/Job.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
using NuGet.Services.Validation.PackageSigning.ValidateCertificate;
4141
using NuGet.Services.Validation.Vcs;
4242
using NuGetGallery.Diagnostics;
43-
using NuGetGallery.Services;
43+
using NuGetGallery.Infrastructure.Mail;
4444

4545
namespace NuGet.Services.Validation.Orchestrator
4646
{
@@ -280,8 +280,8 @@ private void ConfigureJobServices(IServiceCollection services, IConfigurationRoo
280280
? (IMailSender)new DiskMailSender()
281281
: (IMailSender)new MailSender(mailSenderConfiguration);
282282
});
283-
services.AddTransient<ICoreMessageServiceConfiguration, CoreMessageServiceConfiguration>();
284-
services.AddTransient<ICoreMessageService, CoreMessageService>();
283+
services.AddTransient<IMessageServiceConfiguration, CoreMessageServiceConfiguration>();
284+
services.AddTransient<IMessageService, CoreMarkdownMessageService>();
285285
services.AddTransient<IMessageService<Package>, PackageMessageService>();
286286
services.AddTransient<ICommonTelemetryService, CommonTelemetryService>();
287287
services.AddTransient<ITelemetryService, TelemetryService>();
@@ -581,7 +581,7 @@ private static void ConfigureFileServices(IServiceCollection services, IConfigur
581581
break;
582582
case ValidatingType.SymbolPackage:
583583
services.AddTransient<IFileMetadataService, SymbolPackageFileMetadataService>();
584-
services.AddTransient<IValidationFileService, ValidationSymbolFileService>();
584+
services.AddTransient<IValidationFileService, ValidationFileService>();
585585
break;
586586
default:
587587
throw new NotImplementedException($"Unknown type: {validatingType}");
@@ -595,7 +595,7 @@ private static void ConfigureOrchestratorSymbolTypes(IServiceCollection services
595595
services.AddTransient<ICoreSymbolPackageService, CoreSymbolPackageService>();
596596
services.AddTransient<ICriteriaEvaluator<SymbolPackage>, SymbolCriteriaEvaluator>();
597597
services.AddTransient<IValidationOutcomeProcessor<SymbolPackage>, ValidationOutcomeProcessor<SymbolPackage>>();
598-
services.AddTransient<IStatusProcessor<SymbolPackage>, EntityStatusProcessor<SymbolPackage>>();
598+
services.AddTransient<IStatusProcessor<SymbolPackage>, SymbolsStatusProcessor>();
599599
services.AddTransient<IValidationSetProvider<SymbolPackage>, ValidationSetProvider<SymbolPackage>>();
600600
services.AddTransient<IMessageService<SymbolPackage>, SymbolsPackageMessageService>();
601601
services.AddTransient<IBrokeredMessageSerializer<SymbolsValidatorMessage>, SymbolsValidatorMessageSerializer>();

src/NuGet.Services.Validation.Orchestrator/NuGet.Services.Validation.Orchestrator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<Compile Include="Error.cs" />
5454
<Compile Include="Services\MessageServiceConfiguration.cs" />
5555
<Compile Include="Services\SymbolsMessageService.cs" />
56+
<Compile Include="SymbolsStatusProcessor.cs" />
5657
<Compile Include="Symbols\ISymbolsIngesterMessageEnqueuer.cs" />
5758
<Compile Include="Symbols\SymbolScanOnlyConfiguration.cs" />
5859
<Compile Include="Symbols\SymbolCriteriaEvaluator.cs" />
@@ -107,7 +108,6 @@
107108
<Compile Include="ValidatingEntitites\PackageValidatingEntity.cs" />
108109
<Compile Include="ValidationFailureBehavior.cs" />
109110
<Compile Include="SymbolValidationMessageHandler.cs" />
110-
<Compile Include="ValidationSymbolFileService.cs" />
111111
<Compile Include="ValidationPackageFileService.cs" />
112112
<Compile Include="ValidationSetProcessorResult.cs" />
113113
<Compile Include="Vcs\IPackageCriteria.cs" />

src/NuGet.Services.Validation.Orchestrator/PackageStatusProcessor.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace NuGet.Services.Validation.Orchestrator
1313
{
1414
public class EntityStatusProcessor<T> : IStatusProcessor<T> where T : class, IEntity
1515
{
16-
private readonly IEntityService<T> _galleryPackageService;
17-
private readonly IValidationFileService _packageFileService;
18-
private readonly IValidatorProvider _validatorProvider;
19-
private readonly ITelemetryService _telemetryService;
20-
private readonly ILogger<EntityStatusProcessor<T>> _logger;
16+
protected readonly IEntityService<T> _galleryPackageService;
17+
protected readonly IValidationFileService _packageFileService;
18+
protected readonly IValidatorProvider _validatorProvider;
19+
protected readonly ITelemetryService _telemetryService;
20+
protected readonly ILogger<EntityStatusProcessor<T>> _logger;
2121

2222
public EntityStatusProcessor(
2323
IEntityService<T> galleryPackageService,
@@ -76,7 +76,7 @@ public Task SetStatusAsync(
7676
}
7777
}
7878

79-
private async Task MakePackageFailedValidationAsync(IValidatingEntity<T> validatingEntity, PackageValidationSet validationSet)
79+
protected virtual async Task MakePackageFailedValidationAsync(IValidatingEntity<T> validatingEntity, PackageValidationSet validationSet)
8080
{
8181
var fromStatus = validatingEntity.Status;
8282

@@ -88,7 +88,7 @@ private async Task MakePackageFailedValidationAsync(IValidatingEntity<T> validat
8888
}
8989
}
9090

91-
private async Task MakePackageAvailableAsync(IValidatingEntity<T> validatingEntity, PackageValidationSet validationSet)
91+
protected virtual async Task MakePackageAvailableAsync(IValidatingEntity<T> validatingEntity, PackageValidationSet validationSet)
9292
{
9393
// 1) Operate on blob storage.
9494
var copied = await UpdatePublicPackageAsync(validationSet);

src/NuGet.Services.Validation.Orchestrator/Services/MessageServiceConfiguration.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5+
using System.Net.Mail;
56
using Microsoft.Extensions.Options;
7+
using NuGetGallery.Infrastructure.Mail;
68

79
namespace NuGet.Services.Validation.Orchestrator
810
{
9-
public class MessageServiceConfiguration
11+
public class MessageServiceConfiguration : IMessageServiceConfiguration
1012
{
1113
public EmailConfiguration EmailConfiguration { get; }
1214

@@ -17,6 +19,7 @@ public MessageServiceConfiguration(IOptionsSnapshot<EmailConfiguration> emailCon
1719
throw new ArgumentNullException(nameof(emailConfigurationAccessor));
1820
}
1921
EmailConfiguration = emailConfigurationAccessor.Value ?? throw new ArgumentException("Value cannot be null", nameof(emailConfigurationAccessor));
22+
2023
if (string.IsNullOrWhiteSpace(EmailConfiguration.PackageUrlTemplate))
2124
{
2225
throw new ArgumentException($"{nameof(emailConfigurationAccessor.Value)}.{nameof(EmailConfiguration.PackageUrlTemplate)} cannot be empty", nameof(emailConfigurationAccessor));
@@ -33,9 +36,19 @@ public MessageServiceConfiguration(IOptionsSnapshot<EmailConfiguration> emailCon
3336
{
3437
throw new ArgumentException($"{nameof(emailConfigurationAccessor.Value)}.{nameof(EmailConfiguration.EmailSettingsUrl)} must be an absolute Url", nameof(emailConfigurationAccessor));
3538
}
39+
40+
GalleryOwner = new MailAddress(EmailConfiguration.GalleryOwner);
41+
GalleryNoReplyAddress = new MailAddress(EmailConfiguration.GalleryNoReplyAddress);
3642
}
3743

3844
public string GalleryPackageUrl(string packageId, string packageNormalizedVersion) => string.Format(EmailConfiguration.PackageUrlTemplate, packageId, packageNormalizedVersion);
3945
public string PackageSupportUrl(string packageId, string packageNormalizedVersion) => string.Format(EmailConfiguration.PackageSupportTemplate, packageId, packageNormalizedVersion);
46+
47+
public MailAddress GalleryOwner { get; set; }
48+
49+
/// <summary>
50+
/// Gets the gallery e-mail from name and email address
51+
/// </summary>
52+
public MailAddress GalleryNoReplyAddress { get; set; }
4053
}
4154
}

src/NuGet.Services.Validation.Orchestrator/Services/PackageMessageService.cs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@
66
using Microsoft.Extensions.Logging;
77
using Microsoft.Extensions.Options;
88
using NuGetGallery;
9-
using NuGetGallery.Services;
9+
using NuGetGallery.Infrastructure.Mail;
10+
using NuGetGallery.Infrastructure.Mail.Messages;
1011

1112
namespace NuGet.Services.Validation.Orchestrator
1213
{
1314
public class PackageMessageService : IMessageService<Package>
1415
{
15-
private readonly ICoreMessageService _coreMessageService;
16+
private readonly IMessageService _messageService;
1617
private readonly ILogger<PackageMessageService> _logger;
1718
private readonly MessageServiceConfiguration _serviceConfiguration;
1819

1920
public PackageMessageService(
20-
ICoreMessageService coreMessageService,
21+
IMessageService messageService,
2122
IOptionsSnapshot<EmailConfiguration> emailConfigurationAccessor,
2223
ILogger<PackageMessageService> logger)
2324
{
2425
_serviceConfiguration = new MessageServiceConfiguration(emailConfigurationAccessor);
25-
_coreMessageService = coreMessageService ?? throw new ArgumentNullException(nameof(coreMessageService));
26+
_messageService = messageService ?? throw new ArgumentNullException(nameof(messageService));
2627
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
2728
}
2829

@@ -32,8 +33,15 @@ public async Task SendPublishedMessageAsync(Package package)
3233

3334
var galleryPackageUrl = _serviceConfiguration.GalleryPackageUrl(package.PackageRegistration.Id, package.NormalizedVersion);
3435
var packageSupportUrl = _serviceConfiguration.PackageSupportUrl(package.PackageRegistration.Id, package.NormalizedVersion);
35-
36-
await _coreMessageService.SendPackageAddedNoticeAsync(package, galleryPackageUrl, packageSupportUrl, _serviceConfiguration.EmailConfiguration.EmailSettingsUrl);
36+
var packageAddedMessage = new PackageAddedMessage(
37+
_serviceConfiguration,
38+
package,
39+
galleryPackageUrl,
40+
packageSupportUrl,
41+
_serviceConfiguration.EmailConfiguration.EmailSettingsUrl,
42+
Array.Empty<string>());
43+
44+
await _messageService.SendMessageAsync(packageAddedMessage);
3745
}
3846

3947
public async Task SendValidationFailedMessageAsync(Package package, PackageValidationSet validationSet)
@@ -44,14 +52,28 @@ public async Task SendValidationFailedMessageAsync(Package package, PackageValid
4452
var galleryPackageUrl = _serviceConfiguration.GalleryPackageUrl(package.PackageRegistration.Id, package.NormalizedVersion);
4553
var packageSupportUrl = _serviceConfiguration.PackageSupportUrl(package.PackageRegistration.Id, package.NormalizedVersion);
4654

47-
await _coreMessageService.SendPackageValidationFailedNoticeAsync(package, validationSet, galleryPackageUrl, packageSupportUrl, _serviceConfiguration.EmailConfiguration.AnnouncementsUrl, _serviceConfiguration.EmailConfiguration.TwitterUrl);
55+
var packageValidationFailedMessage = new PackageValidationFailedMessage(
56+
_serviceConfiguration,
57+
package,
58+
validationSet,
59+
galleryPackageUrl,
60+
packageSupportUrl,
61+
_serviceConfiguration.EmailConfiguration.AnnouncementsUrl,
62+
_serviceConfiguration.EmailConfiguration.TwitterUrl);
63+
64+
await _messageService.SendMessageAsync(packageValidationFailedMessage);
4865
}
4966

5067
public async Task SendValidationTakingTooLongMessageAsync(Package package)
5168
{
5269
package = package ?? throw new ArgumentNullException(nameof(package));
5370

54-
await _coreMessageService.SendValidationTakingTooLongNoticeAsync(package, _serviceConfiguration.GalleryPackageUrl(package.PackageRegistration.Id, package.NormalizedVersion));
71+
var packageValidationTakingTooLongMessage = new PackageValidationTakingTooLongMessage(
72+
_serviceConfiguration,
73+
package,
74+
_serviceConfiguration.GalleryPackageUrl(package.PackageRegistration.Id, package.NormalizedVersion));
75+
76+
await _messageService.SendMessageAsync(packageValidationTakingTooLongMessage);
5577
}
5678
}
5779
}

0 commit comments

Comments
 (0)