Skip to content

Commit 6cb0163

Browse files
authored
Add generate-job-summary input to control CI job summary generation (#93)
* add opt-out field * make prettier * update input and add test * add actionName to file name * make prettier * update common-utils version and yml file * update field name to generate-summary * update field description * remove continue-on-error * update variable name
1 parent aeae56c commit 6cb0163

7 files changed

Lines changed: 512 additions & 457 deletions

File tree

.github/workflows/bat.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ jobs:
4040
Simulink
4141
Simulink_Test
4242
Simulink_Coverage
43+
- name: Run MATLAB Tests with job summary disabled
44+
uses: ./
45+
with:
46+
source-folder: sample
47+
generate-summary: false
4348
- name: Run MATLAB Tests
44-
continue-on-error: true
4549
uses: ./
4650
with:
4751
source-folder: sample
@@ -65,7 +69,6 @@ jobs:
6569
- name: Set up diary for logging
6670
run: echo 'diary console.log' >> startup.m
6771
- name: Run run-test command
68-
continue-on-error: true
6972
uses: ./
7073
with:
7174
test-results-simulink-test: test-results/simulinktest.mldatx

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
## For development environment
22
.vscode
33

4+
# Claude
5+
.claude/
6+
47
# Don't include intermediate TypeScript compilation;
58
# it should be forcibly added on release
69
lib

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ inputs:
8484
Startup options for MATLAB
8585
required: false
8686
default: ""
87+
generate-summary:
88+
description: >-
89+
Option to generate a summary for the GitHub job summary
90+
required: false
91+
default: true
8792
code-coverage-metric-level:
8893
description: >-
8994
Level of coverage metrics to collect

package-lock.json

Lines changed: 475 additions & 440 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"dependencies": {
2323
"@actions/core": "^3.0.0",
2424
"@actions/exec": "^3.0.0",
25-
"common-utils": "github:matlab-actions/common-utils#v2.2.2"
25+
"common-utils": "github:matlab-actions/common-utils#v2.3.1"
2626
},
2727
"devDependencies": {
2828
"@types/jest": "^30.0.0",

plugins/+matlab/+unittest/+internal/+services/+plugins/CodeCoverageSummaryPluginService.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
productNames = string({verInfo.Name});
88
productName = 'MATLAB Test';
99
isProductInstalled = any(productNames.matches(productName));
10-
hasCoverageHTML = ~isempty(getenv('INPUT_CODE_COVERAGE_HTML'));
11-
hasCoverageCobertura = ~isempty(getenv('INPUT_CODE_COVERAGE_COBERTURA'));
10+
hasCoverageHTML = ~isempty(getenv('MW_INPUT_CODE_COVERAGE_HTML'));
11+
hasCoverageCobertura = ~isempty(getenv('MW_INPUT_CODE_COVERAGE_COBERTURA'));
1212
hasCoverageRequest = hasCoverageHTML || hasCoverageCobertura;
1313

1414
% Check if MATLAB Test license is available and MATLAB Test is installed
15-
if license('test', 'matlab_test') && isProductInstalled && ~hasCoverageRequest
15+
if strcmpi(getenv("MW_INPUT_GENERATE_SUMMARY"), "true") && ~hasCoverageRequest && license('test', 'matlab_test') && isProductInstalled
1616
% Get metric level from environment variable
17-
metricLevel = getenv('INPUT_CODE_COVERAGE_METRIC_LEVEL');
17+
metricLevel = getenv('MW_INPUT_CODE_COVERAGE_METRIC_LEVEL');
1818

1919
% Create a shared CoverageResult format object
2020
format = matlab.unittest.plugins.codecoverage.CoverageResult;
@@ -23,7 +23,7 @@
2323
plugins = matlab.unittest.plugins.TestRunnerPlugin.empty(0);
2424

2525
% Get source folder from environment variable
26-
sourceFolder = getenv('INPUT_SOURCE_FOLDER');
26+
sourceFolder = getenv('MW_INPUT_SOURCE_FOLDER');
2727
if isempty(sourceFolder)
2828
sourceFolder = pwd;
2929
end

src/index.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ async function run() {
3131
LoggingLevel: core.getInput("logging-level"),
3232
};
3333

34+
const generateSummary = core.getBooleanInput("generate-summary");
3435
var codeCoverageMetricLevel = core.getInput("code-coverage-metric-level").toLowerCase();
3536

3637
// Validate metric level
@@ -50,10 +51,11 @@ async function run() {
5051
env: {
5152
...process.env,
5253
MW_BATCH_LICENSING_ONLINE: "true", // Remove when online batch licensing is the default
53-
INPUT_CODE_COVERAGE_METRIC_LEVEL: codeCoverageMetricLevel,
54-
INPUT_SOURCE_FOLDER: options.SourceFolder!, // Add source folder to environment
55-
INPUT_CODE_COVERAGE_HTML: options.HTMLCodeCoverage!,
56-
INPUT_CODE_COVERAGE_COBERTURA: options.CoberturaCodeCoverage!,
54+
MW_INPUT_CODE_COVERAGE_METRIC_LEVEL: codeCoverageMetricLevel,
55+
MW_INPUT_SOURCE_FOLDER: options.SourceFolder!, // Add source folder to environment
56+
MW_INPUT_CODE_COVERAGE_HTML: options.HTMLCodeCoverage!,
57+
MW_INPUT_CODE_COVERAGE_COBERTURA: options.CoberturaCodeCoverage!,
58+
MW_INPUT_GENERATE_SUMMARY: String(generateSummary),
5759
},
5860
};
5961
core.info("Successfully generated test script!");
@@ -67,12 +69,19 @@ async function run() {
6769
startupOptions,
6870
)
6971
.finally(() => {
70-
const runnerTemp = process.env.RUNNER_TEMP || "";
71-
const runId = process.env.GITHUB_RUN_ID || "";
72+
if (generateSummary) {
73+
const runnerTemp = process.env.RUNNER_TEMP || "";
74+
const runId = process.env.GITHUB_RUN_ID || "";
75+
const actionName = process.env.GITHUB_ACTION || "";
7276

73-
//add test results and code coverage view
74-
testResultsSummary.processAndAddTestSummary(runnerTemp, runId, workspaceDir);
75-
core.summary.write();
77+
testResultsSummary.processAndAddTestSummary(
78+
runnerTemp,
79+
runId,
80+
actionName,
81+
workspaceDir,
82+
);
83+
core.summary.write();
84+
}
7685
});
7786
}
7887

0 commit comments

Comments
 (0)