From 536b4c17500eaa92b55aa070ac1249a144dbc305 Mon Sep 17 00:00:00 2001 From: Nikhil Bhoski <47204011+nbhoski@users.noreply.github.com> Date: Tue, 21 May 2024 11:46:11 +0530 Subject: [PATCH] Added Summary plugin --- .../+ciplugins/+github/BuildSummaryPlugin.m | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plugins/+ciplugins/+github/BuildSummaryPlugin.m diff --git a/plugins/+ciplugins/+github/BuildSummaryPlugin.m b/plugins/+ciplugins/+github/BuildSummaryPlugin.m new file mode 100644 index 0000000..a14e025 --- /dev/null +++ b/plugins/+ciplugins/+github/BuildSummaryPlugin.m @@ -0,0 +1,29 @@ +classdef BuildSummaryPlugin < matlab.buildtool.plugins.BuildRunnerPlugin + +% Copyright 2024 The MathWorks, Inc. + + methods (Access=protected) + + function runTaskGraph(plugin, pluginData) + runTaskGraph@matlab.buildtool.plugins.BuildRunnerPlugin(plugin, pluginData); + [fID, msg] = fopen(fullfile(tempdir ,"buildSummary" + getenv("GITHUB_RUN_ID") + ".json"), "w"); + + if fID == -1 + warning("ciplugins:github:BuildSummaryPlugin:UnableToOpenFile","Could not open a file for GitHub build summary table due to: %s", msg); + else + closeFile = onCleanup(@()fclose(fID)); + taskDetails = struct(); + for idx = 1:numel(pluginData.TaskResults) + taskDetails(idx).name = pluginData.TaskResults(idx).Name; + taskDetails(idx).description = pluginData.TaskGraph.Tasks(idx).Description; + taskDetails(idx).failed = pluginData.TaskResults(idx).Failed; + taskDetails(idx).skipped = pluginData.TaskResults(idx).Skipped; + taskDetails(idx).duration = string(pluginData.TaskResults(idx).Duration); + end + a = struct("taskDetails",taskDetails); + s = jsonencode(a,PrettyPrint=true); + fprintf(fID, "%s",s); + end + end + end +end \ No newline at end of file