Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/bat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ jobs:
Simulink
Simulink_Test
Simulink_Coverage
- name: Run MATLAB Tests with job summary disabled
uses: ./
with:
source-folder: sample
generate-summary: false
Comment thread
mw-kapilg marked this conversation as resolved.
- name: Run MATLAB Tests
continue-on-error: true
uses: ./
with:
source-folder: sample
Expand All @@ -65,7 +69,6 @@ jobs:
- name: Set up diary for logging
run: echo 'diary console.log' >> startup.m
- name: Run run-test command
continue-on-error: true
uses: ./
with:
test-results-simulink-test: test-results/simulinktest.mldatx
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## For development environment
.vscode

# Claude
.claude/

# Don't include intermediate TypeScript compilation;
# it should be forcibly added on release
lib
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ inputs:
Startup options for MATLAB
required: false
default: ""
generate-summary:
description: >-
Option to generate a summary for the GitHub job summary
required: false
default: true
code-coverage-metric-level:
description: >-
Level of coverage metrics to collect
Expand Down
921 changes: 478 additions & 443 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"@actions/core": "^3.0.0",
"@actions/exec": "^3.0.0",
"common-utils": "github:matlab-actions/common-utils#v2.2.2"
"common-utils": "github:matlab-actions/common-utils#v2.3.1"
},
"devDependencies": {
"@types/jest": "^30.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
productNames = string({verInfo.Name});
productName = 'MATLAB Test';
isProductInstalled = any(productNames.matches(productName));
hasCoverageHTML = ~isempty(getenv('INPUT_CODE_COVERAGE_HTML'));
hasCoverageCobertura = ~isempty(getenv('INPUT_CODE_COVERAGE_COBERTURA'));
hasCoverageHTML = ~isempty(getenv('MW_INPUT_CODE_COVERAGE_HTML'));
hasCoverageCobertura = ~isempty(getenv('MW_INPUT_CODE_COVERAGE_COBERTURA'));
hasCoverageRequest = hasCoverageHTML || hasCoverageCobertura;

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

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

% Get source folder from environment variable
sourceFolder = getenv('INPUT_SOURCE_FOLDER');
sourceFolder = getenv('MW_INPUT_SOURCE_FOLDER');
if isempty(sourceFolder)
sourceFolder = pwd;
end
Expand Down
27 changes: 18 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async function run() {
LoggingLevel: core.getInput("logging-level"),
};

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

// Validate metric level
Expand All @@ -50,10 +51,11 @@ async function run() {
env: {
...process.env,
MW_BATCH_LICENSING_ONLINE: "true", // Remove when online batch licensing is the default
INPUT_CODE_COVERAGE_METRIC_LEVEL: codeCoverageMetricLevel,
INPUT_SOURCE_FOLDER: options.SourceFolder!, // Add source folder to environment
INPUT_CODE_COVERAGE_HTML: options.HTMLCodeCoverage!,
INPUT_CODE_COVERAGE_COBERTURA: options.CoberturaCodeCoverage!,
MW_INPUT_CODE_COVERAGE_METRIC_LEVEL: codeCoverageMetricLevel,
MW_INPUT_SOURCE_FOLDER: options.SourceFolder!, // Add source folder to environment
MW_INPUT_CODE_COVERAGE_HTML: options.HTMLCodeCoverage!,
MW_INPUT_CODE_COVERAGE_COBERTURA: options.CoberturaCodeCoverage!,
MW_INPUT_GENERATE_SUMMARY: String(generateSummary),
},
};
core.info("Successfully generated test script!");
Expand All @@ -67,12 +69,19 @@ async function run() {
startupOptions,
)
.finally(() => {
const runnerTemp = process.env.RUNNER_TEMP || "";
const runId = process.env.GITHUB_RUN_ID || "";
if (generateSummary) {
const runnerTemp = process.env.RUNNER_TEMP || "";
const runId = process.env.GITHUB_RUN_ID || "";
const actionName = process.env.GITHUB_ACTION || "";

//add test results and code coverage view
testResultsSummary.processAndAddTestSummary(runnerTemp, runId, workspaceDir);
core.summary.write();
testResultsSummary.processAndAddTestSummary(
runnerTemp,
runId,
actionName,
workspaceDir,
);
core.summary.write();
}
});
}

Expand Down
Loading