-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.ts
More file actions
83 lines (73 loc) · 3.15 KB
/
Copy pathindex.ts
File metadata and controls
83 lines (73 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2020-2026 The MathWorks, Inc.
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as scriptgen from "./scriptgen.js";
import { matlab, testResultsSummary } from "common-utils";
/**
* Gather action inputs and then run action
*/
async function run() {
const platform = process.platform;
const architecture = process.arch;
const workspaceDir = process.cwd();
const codeCoverageMetrics = core.getInput("code-coverage-metrics").toLowerCase().trim();
const options: scriptgen.RunTestsOptions = {
JUnitTestResults: core.getInput("test-results-junit"),
CoberturaCodeCoverage: core.getInput("code-coverage-cobertura"),
HTMLCodeCoverage: core.getInput("code-coverage-html"),
SourceFolder: core.getInput("source-folder"),
PDFTestReport: core.getInput("test-results-pdf"),
HTMLTestReport: core.getInput("test-results-html"),
SimulinkTestResults: core.getInput("test-results-simulink-test"),
CoberturaModelCoverage: core.getInput("model-coverage-cobertura"),
HTMLModelCoverage: core.getInput("model-coverage-html"),
SelectByTag: core.getInput("select-by-tag"),
SelectByFolder: core.getInput("select-by-folder"),
Strict: core.getBooleanInput("strict"),
UseParallel: core.getBooleanInput("use-parallel"),
OutputDetail: core.getInput("output-detail"),
LoggingLevel: core.getInput("logging-level"),
CodeCoverageMetrics: codeCoverageMetrics,
};
const generateSummary = core.getBooleanInput("generate-summary");
const command = scriptgen.generateCommand(options);
const startupOptions = core.getInput("startup-options").split(" ");
const helperScript = await matlab.generateScript(workspaceDir, command);
const execOptions = {
env: {
...process.env,
MW_BATCH_LICENSING_ONLINE: "true", // Remove when online batch licensing is the default
MW_INPUT_CODE_COVERAGE_METRICS: options.CodeCoverageMetrics!,
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!");
await matlab
.runCommand(
helperScript,
platform,
architecture,
(cmd, args) => exec.exec(cmd, args, execOptions),
startupOptions,
)
.finally(() => {
if (generateSummary) {
const runnerTemp = process.env.RUNNER_TEMP || "";
const runId = process.env.GITHUB_RUN_ID || "";
const actionName = process.env.GITHUB_ACTION || "";
testResultsSummary.processAndAddTestSummary(
runnerTemp,
runId,
actionName,
workspaceDir,
);
core.summary.write();
}
});
}
run().catch((e) => {
core.setFailed(e);
});