private async Task <CommitResult> WaitForIngestionAsync(IMcrStatusClient statusClient) { CommitResult commitResult = null; DateTime startTime = DateTime.Now; bool isComplete = false; while (!isComplete) { commitResult = await statusClient.GetCommitResultAsync(Options.CommitDigest); foreach (CommitStatus commitStatus in commitResult.Value) { _loggerService.WriteMessage( $"Readme status results for commit digest '{Options.CommitDigest}' with request ID '{commitStatus.OnboardingRequestId}': {commitStatus.OverallStatus}"); switch (commitStatus.OverallStatus) { case StageStatus.Processing: case StageStatus.NotStarted: await Task.Delay(Options.RequeryDelay); break; case StageStatus.Failed: _loggerService.WriteError(await GetFailureResultsAsync(statusClient, commitStatus)); break; case StageStatus.Succeeded: isComplete = true; break; case StageStatus.NotApplicable: default: throw new NotSupportedException( $"Unexpected status for commit digest '{Options.CommitDigest}' with request ID '{commitStatus.OnboardingRequestId}: {commitStatus.OverallStatus}"); } } if (commitResult.Value.All(status => status.OverallStatus == StageStatus.Failed)) { _loggerService.WriteError("Doc ingestion failed."); _environmentService.Exit(1); } if (DateTime.Now - startTime >= Options.WaitTimeout) { throw new TimeoutException($"Timed out after '{Options.WaitTimeout}' waiting for the docs to be ingested."); } } return(commitResult); }
private void LogResults(ImageSizeValidationResults results) { _loggerService.WriteHeading("VALIDATION RESULTS"); LogResults(results.ImagesWithNoSizeChange, "Images with no size change:"); LogResults(results.ImagesWithAllowedSizeChange, "Images with allowed size change:"); LogResults(results.ImagesWithDisallowedSizeChange, "Images exceeding size variance:"); LogResults(results.ImagesWithMissingBaseline, "Images missing from baseline:"); LogResults(results.ImagesWithExtraneousBaseline, "Extra baseline images not defined in manifest:"); if (results.ImagesWithDisallowedSizeChange.Any() || results.ImagesWithMissingBaseline.Any() || results.ImagesWithExtraneousBaseline.Any()) { _loggerService.WriteError("Image size validation failed"); _loggerService.WriteMessage("The baseline file can be updated by running the updateImageSizeBaseline command."); _environmentService.Exit(1); } }
protected void ValidateArtifacts() { if (_outOfSyncArtifacts.Any() || _invalidTemplates.Any()) { if (_outOfSyncArtifacts.Any()) { string artifacts = string.Join(Environment.NewLine, _outOfSyncArtifacts); Logger.WriteError($"Out of sync with templates:{Environment.NewLine}{artifacts}"); } if (_invalidTemplates.Any()) { string templateList = string.Join(Environment.NewLine, _invalidTemplates); Logger.WriteError($"Invalid Templates:{Environment.NewLine}{templateList}"); } _environmentService.Exit(1); } }
public override async Task ExecuteAsync() { Logger.WriteHeading("GENERATING DOCKERFILES"); List <string> outOfSyncDockerfiles = new List <string>(); List <string> invalidTemplates = new List <string>(); IEnumerable <PlatformInfo> platforms = Manifest.GetFilteredPlatforms() .Where(platform => platform.DockerfileTemplate != null); foreach (PlatformInfo platform in platforms) { Logger.WriteSubheading($"Generating '{platform.DockerfilePath}' from '{platform.DockerfileTemplate}'"); string template = await File.ReadAllTextAsync(platform.DockerfileTemplate); if (Options.IsVerbose) { Logger.WriteMessage($"Template:{Environment.NewLine}{template}"); } await GenerateDockerfileAsync(template, platform, outOfSyncDockerfiles, invalidTemplates); } if (outOfSyncDockerfiles.Any() || invalidTemplates.Any()) { if (outOfSyncDockerfiles.Any()) { string dockerfileList = string.Join(Environment.NewLine, outOfSyncDockerfiles); Logger.WriteError($"Dockerfiles out of sync with templates:{Environment.NewLine}{dockerfileList}"); } if (invalidTemplates.Any()) { string templateList = string.Join(Environment.NewLine, invalidTemplates); Logger.WriteError($"Invalid Templates:{Environment.NewLine}{templateList}"); } _environmentService.Exit(1); } }