public Result <Unit, string> Run( ConfigurationSettings settings, GitData gitData, CoverageMetadata metadata) { var outputFile = ResolveOutputFile(settings); // Main Processing var files = BuildCoverageFiles(settings); if (!files.Successful) { return(files.Error); } var data = new CoverallData { RepoToken = settings.RepoToken, ServiceJobId = metadata.ServiceJobId, ServiceName = metadata.ServiceName, ServiceNumber = metadata.ServiceNumber, PullRequestId = metadata.PullRequestId, SourceFiles = files.Value.ToArray(), Parallel = metadata.Parallel, Git = gitData }; var fileData = JsonConvert.SerializeObject(data); if (!string.IsNullOrWhiteSpace(outputFile)) { WriteFileData(_fileSystem, fileData, outputFile); } if (!settings.DryRun) { var uploadResult = UploadCoverage(fileData); if (!uploadResult.Successful) { if (settings.TreatUploadErrorsAsWarnings) { _console.WriteLine(uploadResult.Error); } else { return(uploadResult.Error); } } } return(Unit.Default); }
public Result <Unit, string> Run( ConfigurationSettings settings, Either <GitData, CommitSha>?gitData, CoverageMetadata metadata) { _ = settings ?? throw new ArgumentNullException(nameof(settings)); _ = metadata ?? throw new ArgumentNullException(nameof(metadata)); var outputFile = ResolveOutpuFile(settings); // Main Processing var files = BuildCoverageFiles(settings); if (!files.Successful) { return(files.Error); } var data = new CoverallData( repoToken: settings.RepoToken, serviceName: metadata.ServiceName, sourceFiles: files.Value.ToArray()) { ServiceJobId = metadata.ServiceJobId, ServiceNumber = metadata.ServiceBuildNumber, PullRequestId = metadata.PullRequestId, Parallel = metadata.Parallel, }; if (gitData.HasValue) { gitData.Value.Match( git => { data.Git = git; }, sha => { data.CommitSha = sha.Value; }); } var fileData = JsonConvert.SerializeObject(data); if (outputFile.IsNotNullOrWhitespace()) { WriteFileData(_fileSystem, fileData, outputFile); } if (!settings.DryRun) { var uploadResult = UploadCoverage(fileData); if (!uploadResult.Successful) { if (settings.TreatUploadErrorsAsWarnings) { _console.WriteLine(uploadResult.Error); } else { return(uploadResult.Error); } } } return(Unit.Default); }