diff --git a/.github/workflows/push-to-dockerhub.yml b/.github/workflows/push-to-dockerhub.yml index d614c7d..1ca8186 100644 --- a/.github/workflows/push-to-dockerhub.yml +++ b/.github/workflows/push-to-dockerhub.yml @@ -26,7 +26,7 @@ jobs: id: metadata-portal uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - images: apsiminitiative/postats-portal2 + images: apsiminitiative/postats2-portal flavor: latest=true tags: | type=ref,event=branch @@ -38,7 +38,7 @@ jobs: context: . file: ./dockerfile push: true - target: postats-portal2 + target: postats2-portal tags: ${{ steps.metadata-portal.outputs.tags }} labels: ${{ steps.metadata-portal.outputs.labels }} @@ -46,7 +46,7 @@ jobs: id: metadata-collector uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - images: apsiminitiative/postats-collector2 + images: apsiminitiative/postats2-collector flavor: latest=true tags: | type=ref,event=branch @@ -58,6 +58,6 @@ jobs: context: . file: ./dockerfile push: true - target: postats-collector2 + target: postats2-collector tags: ${{ steps.metadata-collector.outputs.tags }} labels: ${{ steps.metadata-collector.outputs.labels }} diff --git a/APSIM.POStats.Collector/APSIM.POStats.Collector.csproj b/APSIM.POStats.Collector/APSIM.POStats.Collector.csproj index 0c949ef..5627d2f 100644 --- a/APSIM.POStats.Collector/APSIM.POStats.Collector.csproj +++ b/APSIM.POStats.Collector/APSIM.POStats.Collector.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/APSIM.POStats.Collector/Program.cs b/APSIM.POStats.Collector/Program.cs index 016cdf7..731c04d 100644 --- a/APSIM.POStats.Collector/Program.cs +++ b/APSIM.POStats.Collector/Program.cs @@ -27,7 +27,8 @@ static int Main(string[] args) Console.WriteLine(" 3. (int) Commit Id"); Console.WriteLine(" 4. (string) UserID"); Console.WriteLine(" 5. (datetime) Date"); - Console.WriteLine(" 6. (string) Directories (space separated)"); + Console.WriteLine(" 6. (string) Azure pool"); + Console.WriteLine(" 7. (string) Directories (space separated)"); Console.WriteLine(@" Example: APSIM.POStats.Collector Upload 1111 abcdef12345 2016.12.01-06:33 hol353 c:\Apsimx\Tests c:\Apsimx\UnderReview"); return 1; } @@ -52,18 +53,24 @@ static int Main(string[] args) //get the run date DateTime runDate = DateTime.ParseExact(args[4], "yyyy.M.d-HH:mm", CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal); - //get the directories - List searchDirectories = new List(); - for (int i = 5; i < args.Length; i++) + //get the pool name + string pool = args[5]; + + //get the file paths + List filePaths = new List(); + for (int i = 6; i < args.Length; i++) { - if (Directory.Exists(args[i])) - searchDirectories.Add(args[i]); + if (File.Exists(args[i])) + { + filePaths.Add(args[i]); + } else - throw new Exception($"Directory \"{args[i]}\" does not exist."); + throw new Exception($"File \"{args[i]}\" does not exist."); } + //get the Pull Request details - PullRequest pullRequest = Shared.Collector.RetrieveData(pullId, commitId, author, runDate, searchDirectories); + PullRequestDetails pullRequest = Shared.Collector.RetrieveData(pullId, commitId, author, runDate, pool, filePaths); string url = Environment.GetEnvironmentVariable("POSTATS_UPLOAD_URL"); Console.WriteLine($"{url}"); @@ -75,7 +82,7 @@ static int Main(string[] args) if (command == "open") { // Tell endpoint we're about to upload data. - Task response = WebUtilities.GetAsync($"{url}/open?pullrequestnumber={pullRequest.Number}&commitnumber={pullRequest.LastCommit}&author={pullRequest.Author}"); + Task response = WebUtilities.GetAsync($"{url}/open?pullrequestnumber={pullRequest.PullRequest}&commitnumber={pullRequest.Commit}&author={pullRequest.Author}"); response.Wait(); } else if (command == "upload") @@ -87,7 +94,7 @@ static int Main(string[] args) } else if (command == "close") { - Task response = WebUtilities.GetAsync($"{url}/close?pullrequestnumber={pullRequest.Number}&commitid={pullRequest.LastCommit}"); + Task response = WebUtilities.GetAsync($"{url}/close?pullrequestnumber={pullRequest.PullRequest}&commitid={pullRequest.Commit}"); response.Wait(); } //this is provided for Jenkins so it can continue to run with the original uploading code @@ -96,7 +103,7 @@ static int Main(string[] args) //get the Pull Request details PullRequestJenkins pullRequestJenkins = new PullRequestJenkins(); pullRequestJenkins.Id = pullRequest.Id; - pullRequestJenkins.Number = pullRequest.Number; + pullRequestJenkins.Number = pullRequest.PullRequest; pullRequestJenkins.Author = pullRequest.Author; pullRequestJenkins.DateRun = pullRequest.DateRun; pullRequestJenkins.DateStatsAccepted = pullRequest.DateStatsAccepted; @@ -125,26 +132,28 @@ static int Main(string[] args) /// /// /// - private static void UploadStats(PullRequest pullRequest, string url) + private static void UploadStats(PullRequestDetails pullRequest, string url) { List files = new(); files.AddRange(pullRequest.Files); - foreach (var file in files) - { - // Upload data for one file only. - pullRequest.Files.Clear(); - pullRequest.Files.Add(file); - try + //In the case we have no files produced, just send it back empty. + if (files.Count == 0) + { + Task response = WebUtilities.PostAsync($"{url}/adddata", pullRequest, null); + response.Wait(); + } + else + { + foreach (var file in files) { + // Upload data for one file only. + pullRequest.Files = new List(); + pullRequest.Files.Add(file); + Task response = WebUtilities.PostAsync($"{url}/adddata", pullRequest, null); response.Wait(); } - catch (Exception exception) - { - Console.WriteLine($"Error when collecting file {file.Name}"); - Console.WriteLine(exception.Message); - } } } diff --git a/APSIM.POStats.Portal/APSIM.POStats.Portal.csproj b/APSIM.POStats.Portal/APSIM.POStats.Portal.csproj index 833bfca..c1729bf 100644 --- a/APSIM.POStats.Portal/APSIM.POStats.Portal.csproj +++ b/APSIM.POStats.Portal/APSIM.POStats.Portal.csproj @@ -10,17 +10,18 @@ - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + diff --git a/APSIM.POStats.Portal/Controllers/Api.cs b/APSIM.POStats.Portal/Controllers/Api.cs index eae86f2..a6a5d5c 100644 --- a/APSIM.POStats.Portal/Controllers/Api.cs +++ b/APSIM.POStats.Portal/Controllers/Api.cs @@ -5,6 +5,7 @@ using APSIM.POStats.Shared.GitHub; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; +using APSIM.POStats.Portal.Models; namespace APSIM.POStats.Portal.Controllers { @@ -15,16 +16,40 @@ public class Api : ControllerBase /// The database context. private readonly StatsDbContext statsDb; - /// Event handler for timeout timer. - private static void OnTimeout(Object source, ElapsedEventArgs e) + /// Lock for adding to the db + private static object _lock = new(); + + /// Final timeout in minutes. Controls how long to wait before finally closing a pull request. + private const double FINAL_TIMEOUT = 30.0; + + /// Event handler for finish timer. + private static void OnCheckIfFinished(Object source, ElapsedEventArgs e) { string url = Environment.GetEnvironmentVariable("POSTATS_UPLOAD_URL"); if (string.IsNullOrEmpty(url)) throw new Exception($"Cannot find environment variable POSTATS_UPLOAD_URL"); - TimeoutTimer timer = source as TimeoutTimer; - Task response = WebUtilities.GetAsync($"{url}api/close?pullRequestNumber={timer.PullRequestNumber}&commitId={timer.CommitId}"); + Console.WriteLine($"Tick"); + PullRequestTimer timer = source as PullRequestTimer; + + Task response = WebUtilities.GetAsync($"{url}api/count?pullrequestnumber={timer.PullRequest}&commitid={timer.Commit}"); response.Wait(); + + string result = response.Result.ToString(); + if (!string.IsNullOrEmpty(result)) + { + int count = int.Parse(result); + + double minutes = (DateTime.Now - timer.StartTime).TotalMinutes; + + Console.WriteLine($"{timer.PullRequest} ({timer.Commit}): count={count} and minutes={Math.Round(minutes, 1)}"); + if (minutes >= FINAL_TIMEOUT) + { + timer.Stop(); + response = WebUtilities.GetAsync($"{url}api/close?pullRequestNumber={timer.PullRequest}&commitId={timer.Commit}"); + response.Wait(); + } + } } /// Constructor. @@ -36,10 +61,13 @@ public Api(StatsDbContext stats) /// Invoked by collector to open a pull request. /// The number of the pull request to open. + /// The commit id of the pull request. + /// The number of expected validation tasks to be run. /// The author of the pull request. + /// The name of the Azure Batch pool to be used for this pull request. /// [HttpGet("open")] - public IActionResult Open(int pullrequestnumber, string commitid, int count, string author) + public IActionResult Open(int pullrequestnumber, string commitid, int count, string author, string pool) { Console.WriteLine($"\"{author}\" opening PR \"{pullrequestnumber}\" with commit \"{commitid}\" and count \"{count}\""); if (pullrequestnumber == 0) @@ -48,17 +76,20 @@ public IActionResult Open(int pullrequestnumber, string commitid, int count, str return BadRequest("You must supply a commitid"); if (string.IsNullOrEmpty(author)) return BadRequest("You must supply an author"); + if (string.IsNullOrEmpty(pool)) + return BadRequest("You must supply a pool name"); try { - GitHub.SetStatus(pullrequestnumber, commitid, VariableComparison.Status.Running); + GitHub.SetStatus(pullrequestnumber, commitid, VariableComparison.Status.Running, $"Running {count} Validation Tasks"); - statsDb.OpenPullRequest(pullrequestnumber, commitid, author, count); + statsDb.OpenPullRequest(pullrequestnumber, commitid, author, count, pool); - // Create a timer to close the PR after 30 minutes - TimeoutTimer timeoutTimer = new TimeoutTimer {Interval=1800000, PullRequestNumber=pullrequestnumber, CommitId=commitid}; - timeoutTimer.Elapsed += OnTimeout; - timeoutTimer.AutoReset = false; - timeoutTimer.Start(); + // Create a timer to check how many files have been returned + PullRequestTimer finishTimer = new PullRequestTimer { Interval = 10000, PullRequest = pullrequestnumber, Commit = commitid }; + finishTimer.Elapsed += OnCheckIfFinished; + finishTimer.AutoReset = true; + finishTimer.StartTime = DateTime.Now; + finishTimer.Start(); } catch (Exception ex) { @@ -72,7 +103,7 @@ public IActionResult Open(int pullrequestnumber, string commitid, int count, str /// The number of the pull request to close. /// [HttpGet("close")] - public IActionResult Close(int pullrequestnumber, string commitid) + public async Task Close(int pullrequestnumber, string commitid) { Console.WriteLine($"api/close called"); @@ -93,6 +124,9 @@ public IActionResult Close(int pullrequestnumber, string commitid) VariableComparison.Status status = PullRequestFunctions.GetStatus(pullRequest); GitHub.SetStatus(pullrequestnumber, commitid, status); + if (string.IsNullOrEmpty(pullRequest.Pool)) + throw new Exception("No pool associated with this pull request. Pool is required to close the Azure Batch pool."); + await AzureBatchManager.CloseBatchPoolAsync(pullRequest.Pool); } catch (Exception ex) { @@ -101,34 +135,38 @@ public IActionResult Close(int pullrequestnumber, string commitid) } else { - PullRequest pr = statsDb.GetPullRequest(pullrequestnumber); + PullRequestDetails pr = statsDb.GetPullRequest(pullrequestnumber); if (pr == null) return BadRequest($"A PR with {pullrequestnumber} does not exist in the database"); else - return BadRequest($"A PR with {pullrequestnumber} does exist, but has commit number {pr.LastCommit}, and you submitted a commit of {commitid}"); + return BadRequest($"A PR with {pullrequestnumber} does exist, but has commit number {pr.Commit}, and you submitted a commit of {commitid}"); } return Ok(); } - /// Invoked by collector to upload a pull request. - /// + /// Returns the number of files remaining for a pull request + /// The number of the pull request. + /// The commit id of the pull request. /// - [HttpPost("adddata")] - [RequestSizeLimit(100_000_000)] - public IActionResult Post([FromBody]PullRequest pullrequest) + [HttpGet("count")] + public IActionResult Count(int pullrequestnumber, string commitid) { - Console.WriteLine($"api/adddata called"); + Console.WriteLine($"api/count"); + + if (pullrequestnumber == 0) + return BadRequest("You must supply a pull request number"); - if (pullrequest == null) - return BadRequest("You must supply a pull request"); + if (commitid.Length == 0) + return BadRequest("You must supply a commit number"); - if (statsDb.PullRequestWithCommitExists(pullrequest.Number, pullrequest.LastCommit)) + if (statsDb.PullRequestWithCommitExists(pullrequestnumber, commitid)) { - Console.WriteLine($"Adding Data to PR \"{pullrequest.Number}\""); try { - statsDb.AddDataToPullRequest(pullrequest); + var count = statsDb.GetNumberOfCompletesInPullRequest(pullrequestnumber, commitid); + Console.WriteLine($"{count}"); + return Ok(count); } catch (Exception ex) { @@ -137,13 +175,48 @@ public IActionResult Post([FromBody]PullRequest pullrequest) } else { - PullRequest pr = statsDb.GetPullRequest(pullrequest.Number); + PullRequestDetails pr = statsDb.GetPullRequest(pullrequestnumber); if (pr == null) - return BadRequest($"A PR with {pullrequest.Number} does not exist in the database"); + return BadRequest($"A PR with {pullrequestnumber} does not exist in the database"); else - return BadRequest($"A PR with {pullrequest.Number} does exist, but has commit number {pr.LastCommit}, and you submitted a commit of {pullrequest.LastCommit}"); + return BadRequest($"A PR with {pullrequestnumber} does exist, but has commit number {pr.Commit}, and you submitted a commit of {commitid}"); } + } + + /// Invoked by collector to upload a pull request. + /// + /// + [HttpPost("adddata")] + [RequestSizeLimit(100_000_000)] + public IActionResult PostAsync([FromBody]PullRequestDetails pullrequest) + { + Console.WriteLine($"api/adddata called"); + if (pullrequest == null) + return BadRequest("You must supply a pull request"); + + lock (_lock) + { + if (statsDb.PullRequestWithCommitExists(pullrequest.PullRequest, pullrequest.Commit)) + { + try + { + PullRequestDetails pr = statsDb.AddDataToPullRequest(pullrequest); + } + catch (Exception ex) + { + return BadRequest(ex.ToString()); + } + } + else + { + PullRequestDetails pr = statsDb.GetPullRequest(pullrequest.PullRequest); + if (pr == null) + return BadRequest($"A PR with {pullrequest.PullRequest} does not exist in the database"); + else + return BadRequest($"A PR with {pullrequest.PullRequest} does exist, but has commit number {pr.Commit}, and you submitted a commit of {pullrequest.Commit}"); + } + } return Ok(); } } diff --git a/APSIM.POStats.Portal/Models/Azure.cs b/APSIM.POStats.Portal/Models/Azure.cs new file mode 100644 index 0000000..001dfa7 --- /dev/null +++ b/APSIM.POStats.Portal/Models/Azure.cs @@ -0,0 +1,73 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Azure.Batch; +using Microsoft.Azure.Batch.Auth; +using Microsoft.Azure.Batch.Common; +namespace APSIM.POStats.Portal.Models +{ + /// + /// Class for managing Azure Batch resources. + /// + public static class AzureBatchManager + { + + /// + /// Closes (deletes) a specified Azure Batch pool. + /// + /// The name of the Azure resource group. + /// The name of the Azure Batch account. + /// The name of the Azure Batch pool to delete. + public static async Task CloseBatchPoolAsync(string poolName) + { + try + { + using BatchClient _batchClient = GetBatchClient(); + + if (_batchClient == null) + throw new InvalidOperationException("Unable to get a Azure batch client while closing a pool."); + + CloudPool pool = _batchClient.PoolOperations.ListPools().Where(p => p.Id == poolName).FirstOrDefault(); + if (pool == null) + throw new InvalidOperationException($"Unable to find pool {poolName} while closing a pool."); + await _batchClient.PoolOperations.DeletePoolAsync(pool.Id); + Console.WriteLine($"Successfully deleted pool {poolName}."); + } + catch (BatchException be) + { + Console.WriteLine($"Azure Batch pool with pool id {poolName} failed: " + be.ToString()); + throw; + } + catch (Exception e) + { + Console.WriteLine($"Azure Batch pool with pool id {poolName} failed: " + e.ToString()); + throw; + } + } + + /// + /// Get a BatchClient object to interact with Azure Batch service. + /// + /// A BatchClient object for interacting with Azure Batch service. + private static BatchClient GetBatchClient() + { + // Ensure the necessary environment variables exist. + string accountUrl = Environment.GetEnvironmentVariable("AZURE_BATCH_ACCOUNT_URL"); + if (string.IsNullOrEmpty(accountUrl)) + throw new Exception("Cannot find variable AZURE_BATCH_ACCOUNT_URL"); + + string accountName = Environment.GetEnvironmentVariable("AZURE_BATCH_ACCOUNT_NAME"); + if (string.IsNullOrEmpty(accountName)) + throw new Exception("Cannot find variable AZURE_BATCH_ACCOUNT_NAME"); + + string primaryAccessKey = Environment.GetEnvironmentVariable("AZURE_BATCH_ACCOUNT_KEY"); + if (string.IsNullOrEmpty(primaryAccessKey)) + throw new Exception("Cannot find variable AZURE_BATCH_ACCOUNT_KEY"); + + return BatchClient.Open(new BatchSharedKeyCredentials( + accountUrl, + accountName, + primaryAccessKey)); + } + } +} \ No newline at end of file diff --git a/APSIM.POStats.Portal/Pages/Accept.cshtml.cs b/APSIM.POStats.Portal/Pages/Accept.cshtml.cs index 0feb817..3814846 100644 --- a/APSIM.POStats.Portal/Pages/Accept.cshtml.cs +++ b/APSIM.POStats.Portal/Pages/Accept.cshtml.cs @@ -15,7 +15,7 @@ public class AcceptModel : PageModel private readonly StatsDbContext statsDb; /// The pull request to accept stats on. - private PullRequest pullRequest; + private PullRequestDetails pullRequest; /// Constructor public AcceptModel(StatsDbContext stats) @@ -27,7 +27,7 @@ public AcceptModel(StatsDbContext stats) public int PullRequestId => pullRequest.Id; /// The pull request . - public int PullRequestNumber => pullRequest.Number; + public int PullRequestNumber => pullRequest.PullRequest; /// Invoked when page is first loaded. /// The id of the pull request to work with. @@ -42,7 +42,7 @@ public void OnGet(int id) public void OnPost() { var pullRequestNumber = Convert.ToInt32(Request.Form["PullRequestNumber"]); - pullRequest = statsDb.PullRequests.FirstOrDefault(pr => pr.Number == pullRequestNumber); + pullRequest = statsDb.PullRequests.FirstOrDefault(pr => pr.PullRequest == pullRequestNumber); if (pullRequest == null) throw new Exception($"Cannot find pull request {PullRequestNumber}"); @@ -58,7 +58,7 @@ public void OnPost() statsDb.SaveChanges(); // Send pass/fail to gitHub - GitHub.SetStatus(pullRequest.Number, pullRequest.LastCommit, VariableComparison.Status.Same); + GitHub.SetStatus(pullRequest.PullRequest, pullRequest.Commit, VariableComparison.Status.Same); Response.Redirect($"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}{HttpContext.Request.PathBase.Value}/{pullRequestNumber}"); } } diff --git a/APSIM.POStats.Portal/Pages/Chart.cshtml b/APSIM.POStats.Portal/Pages/Chart.cshtml index 31cd530..dfa247a 100644 --- a/APSIM.POStats.Portal/Pages/Chart.cshtml +++ b/APSIM.POStats.Portal/Pages/Chart.cshtml @@ -1,75 +1,75 @@ -@page -@model ChartModel -@{ - ViewData["Title"] = "Chart"; -} -@using APSIM.POStats.Shared; -@{ -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"N"@Html.Raw(IndexModel.EmitNumber(@Model.Variable.CurrentN, isAccepted: false))@Html.Raw(IndexModel.EmitNumber(@Model.Variable.AcceptedN, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(@Model.Variable.NStatus))  
"RMSE" @Html.Raw(IndexModel.EmitNumber(@Model.Variable.CurrentRMSE, 0, 6, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@Model.Variable.AcceptedRMSE, 0, 6, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(@Model.Variable.RMSEStatus))  
"NSE" @Html.Raw(IndexModel.EmitNumber(@Model.Variable.CurrentNSE, 3, 0, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@Model.Variable.AcceptedNSE, 3, 0, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(@Model.Variable.NSEStatus))@VariableFunctions.NSERating(@Model.Variable.CurrentNSE)  
"RSR" @Html.Raw(IndexModel.EmitNumber(@Model.Variable.CurrentRSR, 3, 0, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@Model.Variable.AcceptedRSR, 3, 0, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(@Model.Variable.RSRStatus))@VariableFunctions.RSRRating(@Model.Variable.CurrentNSE)
-
-
-
- - - +@page +@model ChartModel +@{ + ViewData["Title"] = "Chart"; +} +@using APSIM.POStats.Shared; +@{ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
"N"@Html.Raw(IndexModel.EmitNumber(@Model.Variable.CurrentN, isAccepted: false))@Html.Raw(IndexModel.EmitNumber(@Model.Variable.AcceptedN, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(@Model.Variable.NStatus))  
"RMSE" @Html.Raw(IndexModel.EmitNumber(@Model.Variable.CurrentRMSE, 0, 6, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@Model.Variable.AcceptedRMSE, 0, 6, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(@Model.Variable.RMSEStatus))  
"NSE" @Html.Raw(IndexModel.EmitNumber(@Model.Variable.CurrentNSE, 3, 0, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@Model.Variable.AcceptedNSE, 3, 0, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(@Model.Variable.NSEStatus))@VariableFunctions.NSERating(@Model.Variable.CurrentNSE)  
"RSR" @Html.Raw(IndexModel.EmitNumber(@Model.Variable.CurrentRSR, 3, 0, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@Model.Variable.AcceptedRSR, 3, 0, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(@Model.Variable.RSRStatus))@VariableFunctions.RSRRating(@Model.Variable.CurrentNSE)
+
+
+
+ + + } \ No newline at end of file diff --git a/APSIM.POStats.Portal/Pages/Chart.cshtml.cs b/APSIM.POStats.Portal/Pages/Chart.cshtml.cs index cdcdff7..d999df1 100644 --- a/APSIM.POStats.Portal/Pages/Chart.cshtml.cs +++ b/APSIM.POStats.Portal/Pages/Chart.cshtml.cs @@ -54,8 +54,8 @@ public ActionResult OnGetChartData(int id) DataTable gdt = new DataTable(); gdt.AddColumn(new Column(ColumnType.Number, "Observed", "Observed")); // X - gdt.AddColumn(new Column(ColumnType.Number, "Accepted", "Accepted")); // Accepted - gdt.AddColumn(new Column(ColumnType.Number, "Predicted", "Current")); // Y + gdt.AddColumn(new Column(ColumnType.Number, "Accepted", "Old")); // Y - old + gdt.AddColumn(new Column(ColumnType.Number, "Predicted", "New")); // Y - new // Add in accepted values. VariableFunctions.GetData(accepted, out double[] acceptedPredicted, out double[] acceptedObserved, out string[] acceptedLabels); @@ -69,8 +69,8 @@ public ActionResult OnGetChartData(int id) { var r = gdt.NewRow(); r.AddCell(new Cell(acceptedObserved[i], acceptedObserved[i].ToString("f3"))); // observed - r.AddCell(new Cell(acceptedPredicted[i], $"{acceptedPredicted[i]:f3} ({acceptedLabels[i]})")); // accepted - r.AddCell(new Cell(null, null)); // current + r.AddCell(new Cell(acceptedPredicted[i], $"{acceptedPredicted[i]:f3} ({acceptedLabels[i]})")); // old + r.AddCell(new Cell(null, null)); // new gdt.AddRow(r); } } @@ -84,8 +84,8 @@ public ActionResult OnGetChartData(int id) { var r = gdt.NewRow(); r.AddCell(new Cell(observed[i], observed[i].ToString("f3"))); // observed - r.AddCell(new Cell(null, null)); // accepted - r.AddCell(new Cell(predicted[i], $"{predicted[i]:f3} ({labels[i]})")); // current + r.AddCell(new Cell(null, null)); // old + r.AddCell(new Cell(predicted[i], $"{predicted[i]:f3} ({labels[i]})")); // new gdt.AddRow(r); } diff --git a/APSIM.POStats.Portal/Pages/Heatmap.cshtml.cs b/APSIM.POStats.Portal/Pages/Heatmap.cshtml.cs index 66f70b7..0edd7d6 100644 --- a/APSIM.POStats.Portal/Pages/Heatmap.cshtml.cs +++ b/APSIM.POStats.Portal/Pages/Heatmap.cshtml.cs @@ -21,7 +21,7 @@ public HeatmapModel(StatsDbContext stats) } /// The pull request being analysed. - public PullRequest PullRequest { get; private set; } + public PullRequestDetails PullRequest { get; private set; } public string BaseUrl { get { return $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}"; } } diff --git a/APSIM.POStats.Portal/Pages/Index.cshtml b/APSIM.POStats.Portal/Pages/Index.cshtml index 03108be..37e0a05 100644 --- a/APSIM.POStats.Portal/Pages/Index.cshtml +++ b/APSIM.POStats.Portal/Pages/Index.cshtml @@ -25,11 +25,12 @@   - Performance Rating - RSR - NSE - - + *** Very Good 0.00 ≤ RSR ≤ 0.50 @@ -60,12 +61,12 @@
- - + +
- +
@@ -77,85 +78,132 @@
- + +
+
+ +


+ @if (Model.OnlyShowChangedStats) { - - + + } + else + { + + } +
+
+
+
+ + @if (Model.ShowLogs) + { + } else { - - + }


+
+ + + +
- @{ - var files = PullRequestFunctions.GetFileComparisons(Model.PullRequest); + @{ + List files = PullRequestFunctions.GetFileComparisons(Model.PullRequest); if (Model.OnlyShowChangedStats) PullRequestFunctions.RemoveSame(files); } @foreach (var file in files) { - - - - - @foreach (var table in file.Tables) + @if (IndexModel.FilterVariables(files, Model.Filter, file.Name, "", "")) { + - - - - - - - - - - + - - @foreach (var variable in table.VariableComparisons) + @foreach (var table in file.Tables) { - - - - - + @if (IndexModel.FilterVariables(files, Model.Filter, file.Name, table.Name, "")) + { + + + + + + + + + + + + - - - - + @foreach (var variable in table.VariableComparisons) + { + @if (IndexModel.FilterVariables(files, Model.Filter, file.Name, table.Name, variable.Name)) + { + + + + + - - - - + + + + - - - - + + + + - - - - + + + + + + + + + + } + } + } } } }
- @Html.Raw(IndexModel.EmitFileName(file)) -
     @Html.Raw(IndexModel.EmitTableName(@table))  n  RMSE  NSE  RSR + @Html.Raw(IndexModel.EmitFileName(file)) +
          @Html.Raw(IndexModel.EmitVariableName(@variable))  
     @Html.Raw(IndexModel.EmitTableName(@table))  n  RMSE  NSE  RSR
 @Html.Raw(IndexModel.EmitNumber(@variable.CurrentN, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@variable.AcceptedN, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(variable.NStatus))  
          @Html.Raw(IndexModel.EmitVariableName(@variable))   @Html.Raw(IndexModel.EmitNumber(variable.CurrentRMSE, 0, 6, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(variable.AcceptedRMSE, 0, 6, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(variable.RMSEStatus))   @Html.Raw(IndexModel.EmitNumber(@variable.CurrentN, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@variable.AcceptedN, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(variable.NStatus))   @Html.Raw(IndexModel.EmitNumber(@variable.CurrentNSE, 3, 0, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@variable.AcceptedNSE, 3, 0, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(variable.NSEStatus))@VariableFunctions.NSERating(variable.CurrentNSE)   @Html.Raw(IndexModel.EmitNumber(variable.CurrentRMSE, 0, 6, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(variable.AcceptedRMSE, 0, 6, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(variable.RMSEStatus))   @Html.Raw(IndexModel.EmitNumber(@variable.CurrentRSR, 3, 0, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@variable.AcceptedRSR, 3, 0, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(variable.RSRStatus))@VariableFunctions.RSRRating(variable.CurrentRSR)
 @Html.Raw(IndexModel.EmitNumber(@variable.CurrentNSE, 3, 0, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@variable.AcceptedNSE, 3, 0, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(variable.NSEStatus))@VariableFunctions.NSERating(variable.CurrentNSE)   @Html.Raw(IndexModel.EmitNumber(@variable.CurrentRSR, 3, 0, isAccepted: false)) @Html.Raw(IndexModel.EmitNumber(@variable.AcceptedRSR, 3, 0, isAccepted: true))@Html.Raw(IndexModel.EmitTickCross(variable.RSRStatus))@VariableFunctions.RSRRating(variable.CurrentRSR)
+
+ Logs: + @if (Model.ShowLogs) + { + @foreach (string log in Model.PullRequest.Outputs) + { + @foreach (string line in log.Split("\n")) + { + @Html.Encode(line)
+ } + } + } + else + { + @Html.Raw("Hidden") + } +
diff --git a/APSIM.POStats.Portal/Pages/Index.cshtml.cs b/APSIM.POStats.Portal/Pages/Index.cshtml.cs index 0dd2a65..34adfbd 100644 --- a/APSIM.POStats.Portal/Pages/Index.cshtml.cs +++ b/APSIM.POStats.Portal/Pages/Index.cshtml.cs @@ -4,6 +4,7 @@ using APSIM.Shared.Utilities; using Microsoft.AspNetCore.Mvc.RazorPages; using System; +using System.Collections.Generic; using System.Linq; namespace APSIM.POStats.Portal.Pages @@ -26,17 +27,22 @@ public IndexModel(StatsDbContext stats) /// Only show changed stats? public bool OnlyShowChangedStats { get; set; } = true; + /// Show standard output logs + public bool ShowLogs { get; set; } = false; + /// The pull request being analysed. - public PullRequest PullRequest { get; private set; } + public PullRequestDetails PullRequest { get; private set; } /// The Url for the web site. public string BaseUrl { get { return $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}"; } } + public string Filter { get; set; } = ""; + /// Invoked when page is first loaded. /// The pull request to work with. public void OnGet(int pullRequestNumber) { - PullRequest = statsDb.PullRequests.FirstOrDefault(pr => pr.Number == pullRequestNumber); + PullRequest = statsDb.PullRequests.FirstOrDefault(pr => pr.PullRequest == pullRequestNumber); if (PullRequest == null) throw new Exception($"Cannot find pull request #{pullRequestNumber} in stats database"); @@ -46,12 +52,19 @@ public void OnGet(int pullRequestNumber) public void OnPost() { int pullRequestNumber = Convert.ToInt32(Request.Form["PullRequestNumber"]); - PullRequest = statsDb.PullRequests.FirstOrDefault(pr => pr.Number == pullRequestNumber); + PullRequest = statsDb.PullRequests.FirstOrDefault(pr => pr.PullRequest == pullRequestNumber); if (PullRequest == null) throw new Exception($"Cannot find pull request #{pullRequestNumber} in stats database"); - var statsLabel = Request.Form["StatsLabel"].ToString(); - OnlyShowChangedStats = statsLabel == "Showing all stats."; + this.OnlyShowChangedStats = Request.Form["stats-value"].ToString().ToLower() == "true"; + this.ShowLogs = Request.Form["logs-value"].ToString().ToLower() == "true"; + this.Filter = Request.Form["filter-value"].ToString(); + + if (!String.IsNullOrEmpty(Request.Form["stats-button"].ToString())) + this.OnlyShowChangedStats = !this.OnlyShowChangedStats; + + if (!String.IsNullOrEmpty(Request.Form["logs-button"].ToString())) + this.ShowLogs = !this.ShowLogs; } /// Emit html to display tick/cross. @@ -149,5 +162,35 @@ public static string EmitFileName(ApsimFileComparison file) else return file.Name; } + + public static bool FilterVariables(List files, string filter, string fileName, string tableName = "", string variableName = "") + { + if (String.IsNullOrEmpty(filter)) + return true; + + foreach (ApsimFileComparison file in files) + { + if (file.Name == fileName) + { + foreach (TableComparison table in file.Tables) + { + if (String.IsNullOrEmpty(tableName) || tableName == table.Name) + { + foreach (VariableComparison variable in table.VariableComparisons) + { + if (String.IsNullOrEmpty(variableName) || variableName == variable.Name) + { + if (variable.Name.ToLower().Contains(filter.ToLower())) + { + return true; + } + } + } + } + } + } + } + return false; + } } } \ No newline at end of file diff --git a/APSIM.POStats.Portal/Pages/Shared/_Layout.cshtml b/APSIM.POStats.Portal/Pages/Shared/_Layout.cshtml index bdf43e7..c2b1b0c 100644 --- a/APSIM.POStats.Portal/Pages/Shared/_Layout.cshtml +++ b/APSIM.POStats.Portal/Pages/Shared/_Layout.cshtml @@ -1,50 +1,50 @@ - - - - - - @ViewData["Title"] - APSIM.POStats.Portal - - - - -
- -
-
-
- @RenderBody() -
-
- - - - - - @RenderSection("Scripts", required: false) - - + + + + + + @ViewData["Title"] - APSIM.POStats.Portal + + + + +
+ +
+
+
+ @RenderBody() +
+
+ + + + + + @RenderSection("Scripts", required: false) + + diff --git a/APSIM.POStats.Portal/Pages/UpdateAccepted.cshtml.cs b/APSIM.POStats.Portal/Pages/UpdateAccepted.cshtml.cs index 8a2d5e0..19ba886 100644 --- a/APSIM.POStats.Portal/Pages/UpdateAccepted.cshtml.cs +++ b/APSIM.POStats.Portal/Pages/UpdateAccepted.cshtml.cs @@ -15,7 +15,7 @@ public class UpdateAcceptedModel : PageModel private readonly StatsDbContext statsDb; /// The pull request to accept stats on. - private PullRequest pullRequest; + private PullRequestDetails pullRequest; /// Constructor public UpdateAcceptedModel(StatsDbContext stats) @@ -27,7 +27,7 @@ public UpdateAcceptedModel(StatsDbContext stats) public int PullRequestId => pullRequest.Id; /// The pull request . - public int PullRequestNumber => pullRequest.Number; + public int PullRequestNumber => pullRequest.PullRequest; /// Invoked when page is first loaded. /// The id of the pull request to work with. @@ -42,7 +42,7 @@ public void OnGet(int id) public void OnPost() { var pullRequestNumber = Convert.ToInt32(Request.Form["PullRequestNumber"]); - pullRequest = statsDb.PullRequests.FirstOrDefault(pr => pr.Number == pullRequestNumber); + pullRequest = statsDb.PullRequests.FirstOrDefault(pr => pr.PullRequest == pullRequestNumber); if (pullRequest == null) throw new Exception($"Cannot find pull request {PullRequestNumber}"); @@ -64,7 +64,7 @@ public void OnPost() // Send pass/fail to gitHub VariableComparison.Status status = PullRequestFunctions.GetStatus(pullRequest); - GitHub.SetStatus(pullRequest.Number, pullRequest.LastCommit, status); + GitHub.SetStatus(pullRequest.PullRequest, pullRequest.Commit, status); Response.Redirect($"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}{HttpContext.Request.PathBase.Value}/{pullRequestNumber}"); } } diff --git a/APSIM.POStats.Portal/Startup.cs b/APSIM.POStats.Portal/Startup.cs index 4823da5..e11ce85 100644 --- a/APSIM.POStats.Portal/Startup.cs +++ b/APSIM.POStats.Portal/Startup.cs @@ -3,9 +3,11 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Sqlite.Infrastructure.Internal; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; + namespace APSIM.POStats.Portal { public class Startup @@ -34,11 +36,27 @@ public void ConfigureServices(IServiceCollection services) throw new Exception("Cannot find environment variable PORTAL_DB"); if (connectionString.Contains(".db")) + { + Console.WriteLine("Using SQLite database"); services.AddDbContext(options => options.UseLazyLoadingProxies().UseSqlite(connectionString)); + } else { + Console.WriteLine("Using MySQL database"); var serverVersion = new MySqlServerVersion(new Version(10, 0, 0)); - services.AddDbContext(options => options.UseLazyLoadingProxies().UseMySql(connectionString, serverVersion)); + services.AddDbContext(options => options.UseLazyLoadingProxies().UseMySql( + connectionString, + serverVersion, + mySqlOptionsAction: sqlOptions => + { + sqlOptions.CommandTimeout(60); + sqlOptions.EnableRetryOnFailure( + maxRetryCount: 20, + maxRetryDelay: TimeSpan.FromSeconds(30), + errorNumbersToAdd: null + ); + }) + ); } } diff --git a/APSIM.POStats.Shared/APSIM.POStats.Shared.csproj b/APSIM.POStats.Shared/APSIM.POStats.Shared.csproj index 540b7b2..8b9cec2 100644 --- a/APSIM.POStats.Shared/APSIM.POStats.Shared.csproj +++ b/APSIM.POStats.Shared/APSIM.POStats.Shared.csproj @@ -9,11 +9,11 @@
- + - - - + + + diff --git a/APSIM.POStats.Shared/Collector.cs b/APSIM.POStats.Shared/Collector.cs index a26baa2..e26712a 100644 --- a/APSIM.POStats.Shared/Collector.cs +++ b/APSIM.POStats.Shared/Collector.cs @@ -30,47 +30,72 @@ public class Collector /// /// /// A collection of file paths to search. - public static PullRequest RetrieveData(int pullId, string commitId, string author, DateTime runDate, IEnumerable filePaths) + public static PullRequestDetails RetrieveData(int pullId, string commitId, string author, DateTime runDate, string pool, IEnumerable filePaths) { - var pullRequest = new PullRequest() + var pullRequest = new PullRequestDetails() { - Number = pullId, - LastCommit = commitId, + PullRequest = pullId, + Commit = commitId, Author = author, DateRun = runDate, - Files = new List() + Files = new List(), + Pool = pool }; string errorMessages = string.Empty; + pullRequest.Outputs = new List(); + pullRequest.Status = new List(); foreach (var filePath in filePaths) { - string currentPath = filePath.Trim(); - DirectoryInfo info = new DirectoryInfo(@currentPath); - foreach (FileInfo fileInfo in info.GetFiles("*.apsimx", SearchOption.AllDirectories)) + try { - try + var stopwatch = Stopwatch.StartNew(); + var apsimFile = new ApsimFile() { - var stopwatch = Stopwatch.StartNew(); - var apsimFile = new ApsimFile() - { - Name = Path.GetFileNameWithoutExtension(fileInfo.FullName), - PullRequest = pullRequest, - PullRequestId = pullRequest.Id, - Tables = GetTablesFromFile(fileInfo.FullName) - }; - if (apsimFile.Tables.Count > 0) - pullRequest.Files.Add(apsimFile); - Console.WriteLine($"Read PO data from {fileInfo.FullName} in {stopwatch.Elapsed.Seconds} second(s)."); - } - catch (Exception ex) + Name = Path.GetFileNameWithoutExtension(filePath), + PullRequest = pullRequest, + PullRequestId = pullRequest.Id, + Tables = GetTablesFromFile(filePath) + }; + if (apsimFile.Tables.Count > 0) + pullRequest.Files.Add(apsimFile); + Console.WriteLine($"Read PO data from {filePath} in {stopwatch.Elapsed.Seconds} second(s)."); + } + catch (Exception ex) + { + errorMessages += ex.ToString() + "\n"; + } + + } + + FileInfo[] files = new DirectoryInfo("./").GetFiles("*stdout.txt", SearchOption.AllDirectories); + string log = ""; + foreach (FileInfo fileInfo in files) + { + Console.WriteLine(fileInfo.FullName); + using (StreamReader sr = fileInfo.OpenText()) + { + string text = ""; + while ((text = sr.ReadLine()) != null) { - errorMessages += ex.ToString(); + log += text + "\n"; } } } + if (errorMessages.Length > 0) - throw new Exception(errorMessages); + { + log += errorMessages; + pullRequest.Files.Clear(); + pullRequest.Status.Add(false); + } + else + { + pullRequest.Status.Add(true); + } + pullRequest.Outputs.Add(log); + return pullRequest; } diff --git a/APSIM.POStats.Shared/GitHub/GitHub.cs b/APSIM.POStats.Shared/GitHub/GitHub.cs index 3207086..18bb73a 100644 --- a/APSIM.POStats.Shared/GitHub/GitHub.cs +++ b/APSIM.POStats.Shared/GitHub/GitHub.cs @@ -37,8 +37,6 @@ public static GitHubPullRequestDetails GetPullRequest(int pullRequestID) string state = dictionary["state"].ToString(); string statusURL = dictionary["statuses_url"].ToString(); - Console.WriteLine($"Github Status Update: {number} {author} {dateTime} {state} {statusURL}"); - //return the result as a GitHubPullRequestDetails because we don't need all the data the base class has return new GitHubPullRequestDetails(number, author, dateTime, state, statusURL); } @@ -48,7 +46,7 @@ public static GitHubPullRequestDetails GetPullRequest(int pullRequestID) /// /// The pull request number. /// Set the status to pass? - public static void SetStatus(int pullRequestNumber, string commitId, VariableComparison.Status status) + public static void SetStatus(int pullRequestNumber, string commitId, VariableComparison.Status status, string message = "") { //check we have our login token string token = Environment.GetEnvironmentVariable("GITHUB_TOKEN"); @@ -65,7 +63,7 @@ public static void SetStatus(int pullRequestNumber, string commitId, VariableCom //check the status of POStats for this PR string state = "failure"; - string stateFormatted = status.ToString(); + if (status == VariableComparison.Status.Same) state = "success"; @@ -73,10 +71,19 @@ public static void SetStatus(int pullRequestNumber, string commitId, VariableCom if (status == VariableComparison.Status.Running) state = "pending"; + string stateFormatted = "In Development: " + status.ToString(); + if (!String.IsNullOrEmpty(message)) + stateFormatted = message; + //build our check link that refers back to POStats from github string serverURL = Environment.GetEnvironmentVariable("POSTATS_UPLOAD_URL"); string urlStr = $"{serverURL}{pullRequestNumber}"; + Console.WriteLine($"Github Status Update: {state} {urlStr} {stateFormatted} {"APSIM.POStats2"}"); + + //Always success for now + state = "success"; + //Status POST body details GitHubStatusDetails body = new GitHubStatusDetails(state, urlStr, stateFormatted, "APSIM.POStats2"); diff --git a/APSIM.POStats.Shared/Models/ApsimFile.cs b/APSIM.POStats.Shared/Models/ApsimFile.cs index 23ceb70..298273c 100644 --- a/APSIM.POStats.Shared/Models/ApsimFile.cs +++ b/APSIM.POStats.Shared/Models/ApsimFile.cs @@ -1,17 +1,17 @@ -using System.Collections.Generic; -using System.Text.Json.Serialization; - -namespace APSIM.POStats.Shared.Models -{ - public class ApsimFile - { - public int Id { get; set; } - public string Name { get; set; } - public virtual List Tables { get; set; } - - [JsonIgnore] - public int PullRequestId { get; set; } - [JsonIgnore] - public virtual PullRequest PullRequest { get; set; } - } +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace APSIM.POStats.Shared.Models +{ + public class ApsimFile + { + public int Id { get; set; } + public string Name { get; set; } + public virtual List
Tables { get; set; } + + [JsonIgnore] + public int PullRequestId { get; set; } + [JsonIgnore] + public virtual PullRequestDetails PullRequest { get; set; } + } } \ No newline at end of file diff --git a/APSIM.POStats.Shared/Models/PullRequest.cs b/APSIM.POStats.Shared/Models/PullRequest.cs deleted file mode 100644 index 68ab4b7..0000000 --- a/APSIM.POStats.Shared/Models/PullRequest.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace APSIM.POStats.Shared.Models -{ - public class PullRequest - { - public int Id { get; set; } - public int Number { get; set; } - public string LastCommit { get; set; } - public string Author { get; set; } - public DateTime DateRun { get; set; } - public DateTime? DateStatsAccepted { get; set; } - public virtual List Files { get; set; } - public int Count { get; set; } - public virtual List Output { get; set; } - public int? AcceptedPullRequestId { get; set; } - public virtual PullRequest AcceptedPullRequest { get; set; } - } -} \ No newline at end of file diff --git a/APSIM.POStats.Shared/Models/PullRequestDetails.cs b/APSIM.POStats.Shared/Models/PullRequestDetails.cs new file mode 100644 index 0000000..1566f59 --- /dev/null +++ b/APSIM.POStats.Shared/Models/PullRequestDetails.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +namespace APSIM.POStats.Shared.Models +{ + public class PullRequestDetails + { + public int Id { get; set; } + public int PullRequest { get; set; } + public string Commit { get; set; } + public string Author { get; set; } + public DateTime DateRun { get; set; } + + /// Number of nodes that should return + public int CountTotal { get; set; } + + public DateTime? DateStatsAccepted { get; set; } + public int? AcceptedPullRequestId { get; set; } + + public virtual PullRequestDetails AcceptedPullRequest { get; set; } + + public virtual List Files { get; set; } + + /// Statuses of the nodes that ran the tests. True = success, false = failure. + public virtual List Status { get; set; } + + /// Log outputs from validation that are returned + public virtual List Outputs { get; set; } + + /// The name of the Azure Batch pool that was used to run tests for this pull request. + public string Pool { get; set; } + } +} \ No newline at end of file diff --git a/APSIM.POStats.Shared/PullRequestFunctions.cs b/APSIM.POStats.Shared/PullRequestFunctions.cs index 22fd4ec..5028dd1 100644 --- a/APSIM.POStats.Shared/PullRequestFunctions.cs +++ b/APSIM.POStats.Shared/PullRequestFunctions.cs @@ -12,7 +12,7 @@ public class PullRequestFunctions /// /// /// - public static VariableComparison.Status GetStatus(PullRequest pullRequest) + public static VariableComparison.Status GetStatus(PullRequestDetails pullRequest) { bool allBetterOrSame = true; bool allSame = true; @@ -31,7 +31,7 @@ public static VariableComparison.Status GetStatus(PullRequest pullRequest) } } if (allSame) - return VariableComparison.Status.Same; + return VariableComparison.Status.Same; else if (allBetterOrSame) return VariableComparison.Status.Better; else @@ -40,14 +40,34 @@ public static VariableComparison.Status GetStatus(PullRequest pullRequest) /// Get a list of all files for a pull request. /// The pull request. - public static List GetFileComparisons(PullRequest pullRequest) + public static List GetFileComparisons(PullRequestDetails pullRequest) { var files = new List(); - foreach (var currentFile in pullRequest.Files) + foreach (ApsimFile currentFile in pullRequest.Files) { - var acceptedFile = pullRequest.AcceptedPullRequest?.Files.Find(f => f.Name == currentFile.Name); - files.Add(new ApsimFileComparison(currentFile, acceptedFile)); + if (!currentFile.Name.Contains("Wheat-")) + { + ApsimFile acceptedFile = pullRequest.AcceptedPullRequest?.Files.Find(f => f.Name == currentFile.Name); + files.Add(new ApsimFileComparison(currentFile, acceptedFile)); + } + } + + //Merge Wheat back together + ApsimFile wheatFile = new ApsimFile(); + wheatFile.Name = "Wheat"; + wheatFile.Tables = new List
(); + foreach (ApsimFile currentFile in pullRequest.Files) + { + if (currentFile.Name.Contains("Wheat-")) + { + wheatFile.Id = currentFile.Id; + wheatFile.PullRequestId = currentFile.PullRequestId; + wheatFile.PullRequest = currentFile.PullRequest; + wheatFile.Tables.AddRange(currentFile.Tables); + } } + ApsimFile acceptedWheat = pullRequest.AcceptedPullRequest?.Files.Find(f => f.Name == wheatFile.Name); + files.Add(new ApsimFileComparison(wheatFile, acceptedWheat)); // Add in files that are in the accepted PR but not in the current PR. if (pullRequest.AcceptedPullRequest != null) @@ -81,7 +101,7 @@ public static void RemoveSame(List files) /// Update the stats in the specified pull request. /// - public static void UpdateStats(PullRequest pullRequest) + public static void UpdateStats(PullRequestDetails pullRequest) { foreach (var file in pullRequest.Files) foreach (var table in file.Tables) diff --git a/APSIM.POStats.Shared/TimeoutTimer.cs b/APSIM.POStats.Shared/PullRequestTimer.cs similarity index 51% rename from APSIM.POStats.Shared/TimeoutTimer.cs rename to APSIM.POStats.Shared/PullRequestTimer.cs index 05b1fdd..413f864 100644 --- a/APSIM.POStats.Shared/TimeoutTimer.cs +++ b/APSIM.POStats.Shared/PullRequestTimer.cs @@ -1,11 +1,16 @@ +using System; + namespace APSIM.POStats.Shared { - public class TimeoutTimer : System.Timers.Timer + public class PullRequestTimer : System.Timers.Timer { /// Pull Request Number to be closed when the timeout is reached - public int PullRequestNumber; + public int PullRequest; /// Commit id to be checked when the timeout is reached - public string CommitId; + public string Commit; + + /// Start Time + public DateTime StartTime; } } \ No newline at end of file diff --git a/APSIM.POStats.Shared/StatsDbContext.cs b/APSIM.POStats.Shared/StatsDbContext.cs index fe3e9e2..4c0abd9 100644 --- a/APSIM.POStats.Shared/StatsDbContext.cs +++ b/APSIM.POStats.Shared/StatsDbContext.cs @@ -1,7 +1,9 @@ using APSIM.POStats.Shared.Models; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.EntityFrameworkCore; using System; using System.Linq; +using System.Threading; namespace APSIM.POStats.Shared { @@ -10,7 +12,7 @@ namespace APSIM.POStats.Shared /// public class StatsDbContext : DbContext { - public DbSet PullRequests { get; set; } + public DbSet PullRequests { get; set; } public DbSet ApsimFiles { get; set; } public DbSet
Tables { get; set; } public DbSet Variables { get; set; } @@ -32,25 +34,36 @@ public StatsDbContext(DbContextOptions options) /// /// The pull request number. /// The author of the pull request - public void OpenPullRequest(int pullRequestNumber, string commitNumber, string author, int count) + public void OpenPullRequest(int pullRequestNumber, string commitNumber, string author, int count, string pool) { // Try and locate the pull request. If it doesn't exist, create a new pull request instance. // If it does exist, delete the old data. var pr = GetPullRequest(pullRequestNumber); if (pr == null) { - pr = new PullRequest() { Number = pullRequestNumber }; + pr = new PullRequestDetails() { PullRequest = pullRequestNumber }; PullRequests.Add(pr); } - pr.LastCommit = commitNumber; + pr.Commit = commitNumber; pr.Author = author; - pr.Count = count; - - pr.Files ??= new(); - pr.Files.Clear(); pr.DateRun = DateTime.Now; + pr.CountTotal = count; + pr.DateStatsAccepted = null; + pr.AcceptedPullRequestId = null; pr.AcceptedPullRequest = null; + + pr.Files ??= new(); + pr.Files.Clear(); + + pr.Outputs ??= new(); + pr.Outputs.Clear(); + + pr.Status ??= new(); + pr.Status.Clear(); + + pr.Pool = pool; + SaveChanges(); } @@ -61,22 +74,74 @@ public void OpenPullRequest(int pullRequestNumber, string commitNumber, string a /// Use case: A collector calls this method to add data to a pull request. /// /// The pull request to copy the data from.. - public void AddDataToPullRequest(PullRequest fromPullRequest) + /// Reference to stored PullRequest + public PullRequestDetails AddDataToPullRequest(PullRequestDetails fromPullRequest, int retryCount = 0) { + var pr = new PullRequestDetails(); + // Find the pull request. Should always exist if OpenPullRequest has been called. - var pr = PullRequests.FirstOrDefault(pr => pr.Number == fromPullRequest.Number) - ?? throw new Exception($"Cannot find POStats pull request number: {fromPullRequest.Number}"); - - foreach(ApsimFile file in fromPullRequest.Files) - Console.WriteLine($"File \"{file.Name}\" added to PR {fromPullRequest.Number}"); + pr = PullRequests.FirstOrDefault(pr => pr.PullRequest == fromPullRequest.PullRequest && pr.Commit == fromPullRequest.Commit); + if (pr == null) + throw new Exception($"Cannot find POStats pull request number: {fromPullRequest.PullRequest}"); + + foreach (ApsimFile file in fromPullRequest.Files) + Console.WriteLine($"File \"{file.Name}\" added to PR {fromPullRequest.PullRequest}"); if (fromPullRequest.Files != null) pr.Files.AddRange(fromPullRequest.Files); - if (fromPullRequest.Output != null) - pr.Output.AddRange(fromPullRequest.Output); + if (fromPullRequest.Outputs != null) + pr.Outputs.AddRange(fromPullRequest.Outputs); + + if (fromPullRequest.Status != null) + pr.Status.AddRange(fromPullRequest.Status); SaveChanges(); + + return pr; + } + + /// + /// Add file data to a pull request. + /// + /// + /// Use case: A collector calls this method to add data to a pull request. + /// + /// The pull request to copy the data from.. + /// Reference to stored PullRequest + public int GetNumberOfCompletesInPullRequest(int pullrequestnumber, string commitid) + { + var pr = new PullRequestDetails(); + + // Find the pull request. Should always exist if OpenPullRequest has been called. + pr = PullRequests.FirstOrDefault(pr => pr.PullRequest == pullrequestnumber && pr.Commit == commitid); + if (pr == null) + throw new Exception($"Cannot find POStats pull request number: {pullrequestnumber}"); + + return pr.Status.Count; + } + + public bool SaveChangesMultipleTries(int retries = 0) + { + try + { + SaveChanges(); + return true; + } + catch (Exception ex) + { + if (retries < 5) + { + var wait = new Random().Next(1000, 5000); + Console.WriteLine("Unable to add data to pull request, retrying in " + wait + "ms"); + Thread.Sleep(wait); + return SaveChangesMultipleTries(retries + 1); + } + else + { + throw new Exception(ex.Message); + } + } } /// @@ -86,10 +151,10 @@ public void AddDataToPullRequest(PullRequest fromPullRequest) /// Use case: A collector calls this method to indicate that it has finished sending data to the pr. /// /// The pull request number. - public PullRequest ClosePullRequest(int pullRequestNumber) + public PullRequestDetails ClosePullRequest(int pullRequestNumber) { // Find the pull request. Should always exist if OpenPullRequest has been called. - var pr = PullRequests.FirstOrDefault(pr => pr.Number == pullRequestNumber) + var pr = PullRequests.FirstOrDefault(pr => pr.PullRequest == pullRequestNumber) ?? throw new Exception($"Cannot find POStats pull request number: {pullRequestNumber}"); // Assign the current accepted pull request. @@ -105,7 +170,7 @@ public PullRequest ClosePullRequest(int pullRequestNumber) } /// Get the most recent accepted pull request. - public PullRequest GetMostRecentAcceptedPullRequest() + public PullRequestDetails GetMostRecentAcceptedPullRequest() { return PullRequests.Where(pr => pr.DateStatsAccepted != null) .OrderBy(pr => pr.DateStatsAccepted) @@ -120,10 +185,10 @@ public PullRequest GetMostRecentAcceptedPullRequest() public bool PullRequestWithCommitExists(int pullRequestNumber, string commitNumber) { // Try and locate the pull request - PullRequest pr = GetPullRequest(pullRequestNumber); + PullRequestDetails pr = GetPullRequest(pullRequestNumber); if (pr == null) return false; - else if (pr.LastCommit == commitNumber) + else if (pr.Commit == commitNumber) return true; else return false; @@ -134,10 +199,10 @@ public bool PullRequestWithCommitExists(int pullRequestNumber, string commitNumb /// /// The pull request number. /// The commit number. - public PullRequest GetPullRequest(int pullRequestNumber) + public PullRequestDetails GetPullRequest(int pullRequestNumber) { // Try and locate the pull request - return PullRequests.FirstOrDefault(pr => pr.Number == pullRequestNumber); + return PullRequests.FirstOrDefault(pr => pr.PullRequest == pullRequestNumber); } /// @@ -147,7 +212,7 @@ public PullRequest GetPullRequest(int pullRequestNumber) /// protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity().ToTable("PullRequest"); + modelBuilder.Entity().ToTable("PullRequest"); modelBuilder.Entity().ToTable("ApsimFile"); modelBuilder.Entity
().ToTable("Table"); modelBuilder.Entity().ToTable("Variable"); diff --git a/APSIM.POStats.Tests/APSIM.POStats.Tests.csproj b/APSIM.POStats.Tests/APSIM.POStats.Tests.csproj index 7c395b9..54314ec 100644 --- a/APSIM.POStats.Tests/APSIM.POStats.Tests.csproj +++ b/APSIM.POStats.Tests/APSIM.POStats.Tests.csproj @@ -10,13 +10,14 @@ - - - - - - - + + + + + + + + @@ -25,10 +26,16 @@ + + + + diff --git a/APSIM.POStats.Tests/AzureTests.cs b/APSIM.POStats.Tests/AzureTests.cs new file mode 100644 index 0000000..9f8d5ea --- /dev/null +++ b/APSIM.POStats.Tests/AzureTests.cs @@ -0,0 +1,32 @@ +using APSIM.POStats.Portal.Models; + + +namespace APSIM.POStats.Tests; + +[TestFixture] +public class AzureTests +{ + // This can be used for testing the CloseBatchPoolAsync method. + // Make sure you have a pool called "testpool" in your Azure Batch account before + // [Test] + // public async Task TestCloseBatchPoolAsync() + // { + // using (File.OpenRead(".env")) + // if (File.Exists(".env")) + // { + // var lines = File.ReadAllLines(".env"); + // foreach (var line in lines) + // { + // var parts = line.Split('=', 2); + // if (parts.Length == 2) + // { + // Environment.SetEnvironmentVariable(parts[0], parts[1]); + // } + // } + // } + // string poolName = "testpool"; + // await AzureBatchManager.CloseBatchPoolAsync(poolName); + // } + +} + \ No newline at end of file diff --git a/APSIM.POStats.Tests/CollectorTests.cs b/APSIM.POStats.Tests/CollectorTests.cs index 276d0cc..be9081c 100644 --- a/APSIM.POStats.Tests/CollectorTests.cs +++ b/APSIM.POStats.Tests/CollectorTests.cs @@ -12,6 +12,8 @@ public class TestsCollector private string path; private SqliteConnection database; + private string[] files; + [SetUp] public void SetUp() { @@ -27,14 +29,15 @@ public void SetUp() var filename = Path.Combine(path, "Test.apsimx"); using (var writer = new FileStream(filename, FileMode.Create)) - using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("APSIM.POStats.Tests.Test.apsimx")) - if (stream != null) - stream.CopyTo(writer); + using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("APSIM.POStats.Tests.Test.apsimx")) + if (stream != null) + stream.CopyTo(writer); // Create an empty database. var dbFileName = Path.Combine(path, "Test.db"); database = new SqliteConnection($"Data source={dbFileName}"); database.Open(); + files = Directory.GetFiles(path, "*.apsimx"); } [TearDown] @@ -66,9 +69,10 @@ public void TestEnsureNormalCollectorOperationWorks() " 1,2000-01-04, 200.0, 210.0" + Environment.NewLine )); - var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), new string[] { path }); - string jsonString = JsonSerializer.Serialize(pullRequest);; + var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), "workflo-pool", files); + + string jsonString = JsonSerializer.Serialize(pullRequest); Assert.That(pullRequest.Files.ToList().Count, Is.EqualTo(1)); Assert.That(pullRequest.Files[0].Tables.Count, Is.EqualTo(2)); @@ -123,7 +127,7 @@ public void EnsurePredictedStringColumnsAreIgnored() )); database.Close(); - var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), new string[] { path }); + var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), "workflo-pool", files); Assert.That(pullRequest.Files.ToList().Count, Is.EqualTo(0)); } @@ -142,7 +146,7 @@ public void EnsureObservedStringColumnsAreIgnored() )); database.Close(); - var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), new string[] { path }); + var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), "workflo-pool", files); Assert.That(pullRequest.Files.ToList().Count, Is.EqualTo(0)); } @@ -161,7 +165,7 @@ public void EnsureObservedStringValuesInRowsAreIgnored() )); database.Close(); - var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), new string[] { path }); + var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), "workflo-pool", files); Assert.That(pullRequest.Files.ToList().Count, Is.EqualTo(1)); Assert.That(pullRequest.Files[0].Tables.Count, Is.EqualTo(1)); @@ -189,7 +193,7 @@ public void EnsurePOTableNotUnderDataStoreIsFound() )); database.Close(); - var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), new string[] { path }); + var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), "workflo-pool", files); Assert.That(pullRequest.Files.ToList().Count, Is.EqualTo(1)); Assert.That(pullRequest.Files[0].Tables.Count, Is.EqualTo(1)); @@ -216,7 +220,7 @@ public void EnsureCollectorFindsIntegers() )); database.Close(); - var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), new string[] { path }); + var pullRequest = Collector.RetrieveData(1234, "1", null, new DateTime(2000, 1, 1), "workflo-pool", files); Assert.That(pullRequest.Files.ToList().Count, Is.EqualTo(1)); Assert.That(pullRequest.Files[0].Tables.Count, Is.EqualTo(1)); diff --git a/APSIM.POStats.Tests/ComparisonTests.cs b/APSIM.POStats.Tests/ComparisonTests.cs index da0ee95..03c1f1e 100644 --- a/APSIM.POStats.Tests/ComparisonTests.cs +++ b/APSIM.POStats.Tests/ComparisonTests.cs @@ -13,7 +13,7 @@ public class ComparisonTests [Test] public void FileStatusWorks() { - var acceptedPullRequest = new PullRequest() + var acceptedPullRequest = new PullRequestDetails() { Files = new List() { @@ -21,7 +21,7 @@ public void FileStatusWorks() new ApsimFile() { Name = "file3" } } }; - var currentPullRequest = new PullRequest() + var currentPullRequest = new PullRequestDetails() { Files = new List() { @@ -43,7 +43,7 @@ public void FileStatusWorks() [Test] public void TableStatusWorks() { - var acceptedPullRequest = new PullRequest() + var acceptedPullRequest = new PullRequestDetails() { Files = new List() { @@ -58,7 +58,7 @@ public void TableStatusWorks() } } }; - var currentPullRequest = new PullRequest() + var currentPullRequest = new PullRequestDetails() { Files = new List() { @@ -88,7 +88,7 @@ public void TableStatusWorks() [Test] public void TableStatusWorksWithNoAccepted() { - var currentPullRequest = new PullRequest() + var currentPullRequest = new PullRequestDetails() { Files = new List() { @@ -116,7 +116,7 @@ public void TableStatusWorksWithNoAccepted() [Test] public void VariableStatusWork() { - var acceptedPullRequest = new PullRequest() + var acceptedPullRequest = new PullRequestDetails() { Files = new List() { @@ -152,7 +152,7 @@ public void VariableStatusWork() } } }; - var currentPullRequest = new PullRequest() + var currentPullRequest = new PullRequestDetails() { Files = new List() { @@ -214,7 +214,7 @@ public void VariableStatusWork() [Test] public void VariableStatusWorksWithNoAccepted() { - var currentPullRequest = new PullRequest() + var currentPullRequest = new PullRequestDetails() { Files = new List() { @@ -383,7 +383,7 @@ public void VariableComparisonOfInfinityPasses() [Test] public void EnsureOnlyShowChangedStatsWorks() { - var acceptedPullRequest = new PullRequest() + var acceptedPullRequest = new PullRequestDetails() { Files = new List() { @@ -419,7 +419,7 @@ public void EnsureOnlyShowChangedStatsWorks() } } }; - var currentPullRequest = new PullRequest() + var currentPullRequest = new PullRequestDetails() { Files = new List() { @@ -482,7 +482,7 @@ public void EnsureOnlyShowChangedStatsWorks() [Test] public void MissingTableDetected() { - var acceptedPullRequest = new PullRequest() + var acceptedPullRequest = new PullRequestDetails() { Files = new List() { @@ -526,7 +526,7 @@ public void MissingTableDetected() } } }; - var currentPullRequest = new PullRequest() + var currentPullRequest = new PullRequestDetails() { Files = new List() { diff --git a/APSIM.POStats.Tests/StatsDbTests.cs b/APSIM.POStats.Tests/StatsDbTests.cs index 710716b..1c1db48 100644 --- a/APSIM.POStats.Tests/StatsDbTests.cs +++ b/APSIM.POStats.Tests/StatsDbTests.cs @@ -17,7 +17,7 @@ public void TestOpenPullRequestThatAlreadyExists() db.OpenPullRequest(1234, "1", "author", 0); // Make sure the pr exists and has no data. - var pr = db.PullRequests.First(pr => pr.Number == 1234); + var pr = db.PullRequests.First(pr => pr.PullRequest == 1234); Assert.That(pr, !Is.Null); Assert.That(pr.Files.Count, Is.EqualTo(0)); } @@ -32,7 +32,7 @@ public void TestOpenPullRequestThatDoesntAlreadyExist() db.OpenPullRequest(5678, "1", "author", 0); // Make sure the pr exists and has no ydata. - var pr = db.PullRequests.First(pr => pr.Number == 5678); + var pr = db.PullRequests.First(pr => pr.PullRequest == 5678); Assert.That(pr, !Is.Null); Assert.That(pr.Files.Count, Is.EqualTo(0)); } @@ -45,9 +45,10 @@ public void TestAddDataToPullRequest() using var db = CreateInMemoryDB("db3"); db.OpenPullRequest(1234, "1", "author", 0); - PullRequest prToAdd = new() + PullRequestDetails prToAdd = new() { - Number = 1234, + PullRequest = 1234, + Commit = "1", Files = new() { new ApsimFile() @@ -85,10 +86,10 @@ public void TestAddDataToPullRequest() db.ClosePullRequest(1234); // Make sure the pr exists and has no data. - var pr = db.PullRequests.First(pr => pr.Number == 1234); + var pr = db.PullRequests.First(pr => pr.PullRequest == 1234); Assert.That(pr, !Is.Null); Assert.That(pr.DateStatsAccepted, Is.Null); // stats not accepted - Assert.That(pr.AcceptedPullRequest.Number, Is.EqualTo(5678)); // most recent pr that has been accepted. + Assert.That(pr.AcceptedPullRequest.PullRequest, Is.EqualTo(5678)); // most recent pr that has been accepted. Assert.That(pr.Files.Count, Is.EqualTo(1)); var variable = pr.Files[0].Tables[0].Variables[0]; Assert.That(variable.Name, Is.EqualTo("B")); @@ -115,10 +116,10 @@ private StatsDbContext CreateInMemoryDB(string databaseName) .UseInMemoryDatabase(databaseName) .Options; var db = new StatsDbContext(options); - db.PullRequests.Add(new PullRequest + db.PullRequests.Add(new PullRequestDetails { Id = 1, - Number = 1234, + PullRequest = 1234, DateStatsAccepted = new DateTime(2021,1,1), Files = new() { @@ -153,10 +154,10 @@ private StatsDbContext CreateInMemoryDB(string databaseName) } } }); - db.PullRequests.Add(new PullRequest + db.PullRequests.Add(new PullRequestDetails { Id = 2, - Number = 5678, + PullRequest = 5678, DateStatsAccepted = new DateTime(2020,1,1), Files = new() { diff --git a/build-and-push-to-dockerhub.sh b/build-and-push-to-dockerhub.sh new file mode 100644 index 0000000..726db09 --- /dev/null +++ b/build-and-push-to-dockerhub.sh @@ -0,0 +1,17 @@ +# This script builds and pushes the Docker images to Docker Hub + +echo "Building and pushing Docker images to Docker Hub..." +echo "Make sure you are logged in to Docker Hub using 'docker login' before running this script." +echo "Also ensure that you have permission to push to the 'apsiminitiative' repository." +echo "You can login as apsimbot if you have the credentials." +echo "You can run './build.sh' to build the images locally before pushing." +echo "" + +# build the image first +./build.sh + +# push the images to Docker Hub +docker push apsiminitiative/postats2-portal:latest +docker push apsiminitiative/postats2-collector:latest + +echo "Done." \ No newline at end of file diff --git a/build.sh b/build.sh index 41df470..15e0968 100644 --- a/build.sh +++ b/build.sh @@ -3,7 +3,7 @@ #Run this script to build the docker images localled. Not used by github actions. docker build --target postats-build -t postats-build . -docker build --target postats-collector -t apsiminitiative/postats-collector . -docker build --target postats-portal -t apsiminitiative/postats-portal . +docker build --target postats-collector -t apsiminitiative/postats2-collector . +docker build --target postats-portal -t apsiminitiative/postats2-portal . docker rmi postats-build \ No newline at end of file diff --git a/upload-dummy-pullrequest.sh b/upload-dummy-pullrequest.sh index 9b98749..6a56b05 100644 --- a/upload-dummy-pullrequest.sh +++ b/upload-dummy-pullrequest.sh @@ -2,17 +2,17 @@ echo Opening pull request curl --verbose \ - 'http://localhost:8001/api/open?pullRequestNumber=1234&author=author_name' + 'http://localhost:8081/api/open?pullRequestNumber=1234&author=author_name&commitid=123456&count=100' echo echo Adding data. curl --verbose \ --header "Content-Type: application/json" \ --data-binary "@dummy-pullrequest.json" \ - http://localhost:8001/api/adddata + http://localhost:8081/api/adddata echo -echo Closing pull request -curl --verbose \ - 'http://localhost:8001/api/close?pullRequestNumber=1234' -echo \ No newline at end of file +# echo Closing pull request +# curl --verbose \ +# 'http://localhost:8081/api/close?pullRequestNumber=1234' +# echo \ No newline at end of file