public ActionResult Post(BuildRequestModel request) { var requestStart = DateTime.UtcNow; if (request == null) { return(BadRequest(new { error = "No build request was detected." })); } if (String.IsNullOrEmpty(request.GitUrl)) { return(BadRequest(new { error = "No Repo URL was received." })); } // See if we can clone the URL provided var localPath = GitCloner.CloneGitRepoToLocalPath(request.GitUrl, request.Branch); // Do some validation on the cloned directory path var validator = new MarkdownValidator(localPath); validator.EnsureDocSet(); validator.ClearExistingIssues(); var result = validator.CheckForBrokenLinks(); Console.WriteLine($"CheckForBrokenLinks returned {result}"); Console.WriteLine($"Detected {validator.Issues.IssuesInCurrentScope} issues in the documentation."); var outputResults = from e in validator.Issues.Issues where e.Code != ApiDoctor.Validation.Error.ValidationErrorCode.Unknown select new { e.Code, e.Message, e.Source }; try { // Delete the localPath since we're all done with that data Console.WriteLine($"Deleting local files in {localPath}."); System.IO.Directory.Delete(localPath, true); } catch (Exception ex) { Console.WriteLine($"Unable to clean up local files: {ex.Message}"); } var requestCompleted = DateTime.UtcNow; var duration = requestCompleted.Subtract(requestStart); return(Ok(new { contentIssues = outputResults, duration = duration, branch = request.Branch, repo = request.GitUrl })); }
public void CloneFileTest() { //To make code coverate 100% var cn = new GitCloner(); cn.SetGitCmd("echo"); var wf = new WorkflowGeneric(); wf.GetContext().SourceDir = "."; wf.GetContext().WipDir = "."; wf.GetContext().VcsMode = "git"; wf.SetCloner(cn); wf.CloneFiles(); }
public void YamlTransformTest() { Environment.SetEnvironmentVariable("IASC_GSUTIL_PATH", "echo"); var cn = new GitCloner(); cn.SetGitCmd("echo"); var wf = new WorkflowGeneric(); wf.GetContext().SourceDir = "."; wf.GetContext().WipDir = "."; var result = wf.Load(yaml1); UtilsHelm.SetCmd("echo"); wf.SetCopier(CreateGenericCopier()); wf.SetCloner(cn); wf.Transform(); UtilsHelm.ResetHelmCmd(); }
public void YamlLoadFileTest() { var path = "dummy.yaml"; File.WriteAllText(path, yaml1); var cn = new GitCloner(); cn.SetGitCmd("echo"); var wf = new WorkflowGeneric(); wf.GetContext().SourceDir = "."; wf.GetContext().WipDir = "."; wf.SetCloner(cn); wf.SetCopier(CreateGenericCopier()); var result = wf.LoadFile(path); UtilsHelm.SetCmd("echo"); wf.Transform(); UtilsHelm.ResetHelmCmd(); }