-
Notifications
You must be signed in to change notification settings - Fork 14
Add support for test results summary and logs grouping via common-utils #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c65784c
b1b3d32
5494434
824d0ea
0c02d1e
3edc95d
57c89c2
a8a74e2
cd76bb4
60641a0
cea78e6
49e97fc
1f7e10f
fab87bb
1f15178
1ae1bfc
4ba0f44
82f871c
a413836
5b575c2
d6d9106
8bf52cc
a785b2a
c6ebf80
6bebf1d
e389346
fc3675b
db06047
0738bc4
f24d519
bdb3d50
19fcb17
e15aa46
e402790
e14c1e8
821cb5e
cfc99c9
ae65450
34242c0
9b81017
9c9c939
252ead3
f7804a6
126f970
b2da600
a5d8879
fa99631
3015c86
dd37154
f68026d
1e4bd63
56aaf64
3068d2e
c7abd6b
9efca69
712cd93
20d8caf
7735ea7
2682c53
b39d2c9
a2bde78
0781a4e
0030d91
a74e69d
6edaa6e
01cee5f
a40dfd1
b4a9df5
f7f6a8c
f7f0650
697994b
58550a6
7c10b22
0d63cbd
e5e8998
bcd0513
7e4c242
5947a9e
fe98514
dfca60d
7545e5d
cc6bc1a
8105fed
f299b18
fd05f9a
19617c3
6de7664
b35c765
ed72862
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| classdef GitHubLogPluginService < matlab.buildtool.internal.services.ciplugins.CITestRunnerPluginService | ||
| % Copyright 2025 The MathWorks, Inc. | ||
|
|
||
| methods | ||
| function plugins = providePlugins(~, ~) | ||
| plugins = testframework.GitHubLogPlugin(); | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| classdef GitHubLogPlugin < matlab.unittest.plugins.TestRunnerPlugin | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add |
||
| % Copyright 2025 The MathWorks, Inc. | ||
|
|
||
| methods (Access=protected) | ||
| function runTestClass(plugin, pluginData) | ||
| % Add GitHub workflow command for starting a test class output group | ||
| disp("::group::" + pluginData.Name); | ||
|
|
||
| % Invoke the superclass method | ||
| [email protected](plugin, pluginData); | ||
|
|
||
| % End the test class output group | ||
| disp("::endgroup::"); | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| classdef tAssumptionFailure < matlab.unittest.TestCase | ||
| methods (Test) | ||
| function testAssumptionFailure(testCase) | ||
| testCase.assumeEqual(1+1, 11); | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| classdef tVerificationAndAssertionFailure < matlab.unittest.TestCase | ||
| methods (Test) | ||
| function testVerificationFailure(testCase) | ||
| % Two verifications to show that the test continues after a verification failure | ||
| testCase.verifyEqual(1+1, 11); | ||
| testCase.verifyEqual(1+1, 11); | ||
| end | ||
|
|
||
| function testAssertionFailure(testCase) | ||
| % Two assertions to show that the test ends after an assertion failure | ||
| testCase.assertEqual(1+1, 11); | ||
| testCase.assertEqual(1+1, 11); | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,11 @@ | ||
| #!/bin/bash | ||
|
|
||
| SCRIPTGEN_URL='https://ssd.mathworks.com/supportfiles/ci/matlab-script-generator/v0/matlab-script-generator.zip' | ||
| RMC_BASE_URL='https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2' | ||
| SUPPORTED_OS=('win64' 'maci64' 'maca64' 'glnxa64') | ||
|
|
||
| # Create dist directory if it doesn't already exist | ||
| DISTDIR="$(pwd)/dist" | ||
| mkdir -p $DISTDIR/bin | ||
|
|
||
| # Download and extract in a temporary directory | ||
| WORKINGDIR=$(mktemp -d -t rmc_build.XXXXXX) | ||
| cd $WORKINGDIR | ||
| source ./node_modules/common-utils/scripts/setupdeps.sh | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this makes me a little bit nervous. I might almost rather have the same contents in both scripts rather than calling an upstream script. It feels like it makes it much more fragile, and I'm slightly worried about security concerns if that script happens to be hijacked. That's just my preference though. I'll let others weigh in but I think I like it that the entire set up script is captured within the action itself. |
||
|
|
||
| wget -O "$WORKINGDIR/license.txt" "$RMC_BASE_URL/license.txt" | ||
| wget -O "$WORKINGDIR/thirdpartylicenses.txt" "$RMC_BASE_URL/thirdpartylicenses.txt" | ||
| # Copy action specific plugins to dist | ||
| cp -R ./plugins $(pwd)/dist/ | ||
|
|
||
| for os in ${SUPPORTED_OS[@]} | ||
| do | ||
| if [[ $os == 'win64' ]] ; then | ||
| bin_ext='.exe' | ||
| else | ||
| bin_ext='' | ||
| fi | ||
| mkdir -p "$WORKINGDIR/$os" | ||
| wget -O "$WORKINGDIR/$os/run-matlab-command$bin_ext" "$RMC_BASE_URL/$os/run-matlab-command$bin_ext" | ||
| done | ||
| SCRIPTGEN_URL='https://ssd.mathworks.com/supportfiles/ci/matlab-script-generator/v0/matlab-script-generator.zip' | ||
|
|
||
| wget -O scriptgen.zip $SCRIPTGEN_URL | ||
| unzip -qod scriptgen scriptgen.zip | ||
|
|
@@ -33,4 +14,3 @@ rm scriptgen.zip | |
|
|
||
| mv -f ./* "$DISTDIR/bin" | ||
| rm -rf $WORKINGDIR | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| // Copyright 2020-2023 The MathWorks, Inc. | ||
| // Copyright 2020-2025 The MathWorks, Inc. | ||
|
|
||
| import * as core from "@actions/core"; | ||
| import * as exec from "@actions/exec"; | ||
| import { matlab } from "run-matlab-command-action"; | ||
| import * as scriptgen from "./scriptgen"; | ||
| // TODO: update common-utils version when new version is released | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this TODO still left to do later? |
||
| import { matlab, testResultsSummary } from "common-utils"; | ||
| import * as path from "path"; | ||
|
|
||
| /** | ||
| * Gather action inputs and then run action | ||
|
|
@@ -31,17 +33,22 @@ async function run() { | |
| LoggingLevel: core.getInput("logging-level"), | ||
| }; | ||
|
|
||
| const command = scriptgen.generateCommand(options); | ||
| const pluginsPath = path.join(__dirname, "plugins").replaceAll("'","''"); | ||
| const command = "addpath('"+ pluginsPath +"'); " + scriptgen.generateCommand(options); | ||
|
Comment on lines
+36
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we extract this logic to somewhere else? It seems like it will likely have to be run by all of the actions to make sure the plugins get added correctly. |
||
| const startupOptions = core.getInput("startup-options").split(" "); | ||
|
|
||
| const helperScript = await core.group("Generate script", async () => { | ||
| const helperScript = await matlab.generateScript(workspaceDir, command); | ||
| core.info("Successfully generated script"); | ||
| return helperScript; | ||
| }); | ||
| const helperScript = await matlab.generateScript(workspaceDir, command); | ||
| core.info("Successfully generated test script!"); | ||
|
|
||
| await core.group("Run command", async () => { | ||
| await matlab.runCommand(helperScript, platform, architecture, exec.exec, startupOptions); | ||
| await matlab.runCommand(helperScript, platform, architecture, exec.exec, startupOptions).finally(() => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we be setting the exec options (specifically |
||
| const runnerTemp = process.env.RUNNER_TEMP || ''; | ||
| const runId = process.env.GITHUB_RUN_ID || ''; | ||
| const actionName = process.env.GITHUB_ACTION || ''; | ||
|
|
||
| const testResultsData = testResultsSummary.getTestResults(runnerTemp, runId, workspaceDir); | ||
| if(testResultsData) { | ||
| testResultsSummary.writeSummary(testResultsData, actionName); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to ship and set up this plugin in the common component? That way tests always run with groupings on the output?