Skip to content

Commit 19870a7

Browse files
committed
update to use common-utils
1 parent 44b566a commit 19870a7

File tree

10 files changed

+598
-4050
lines changed

10 files changed

+598
-4050
lines changed

.github/workflows/bat.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
name: built-action
3434
- name: Perform 'setup-matlab'
3535
uses: matlab-actions/setup-matlab@v2
36+
with:
37+
products: MATLAB_Test
3638
- name: Greet the world in style
3739
uses: ./
3840
with:

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
"package": "ncc build --minify",
1414
"test": "jest",
1515
"all": "npm test && npm run build && npm run package",
16-
"ci": "npm run clean && npm run deps && npm ci && npm run all"
16+
"ci": "npm run clean && npm ci && npm run deps && npm run all"
1717
},
1818
"files": [
1919
"lib/"
2020
],
2121
"dependencies": {
2222
"@actions/core": "^1.11.1",
2323
"@actions/exec": "^1.1.1",
24-
"uuid": "^11.1.0"
24+
"common-utils": "github:matlab-actions/common-utils#kapilg/refactor"
2525
},
2626
"devDependencies": {
2727
"@types/jest": "^30.0.0",

scripts/setupdeps.sh

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,6 @@
11
#!/bin/bash
22

3-
RMC_BASE_URL='https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2'
4-
SUPPORTED_OS=('win64' 'maci64' 'maca64' 'glnxa64')
3+
source ./node_modules/common-utils/scripts/setupdeps.sh
54

6-
# Create dist directory if it doesn't already exist
7-
DISTDIR="$(pwd)/dist/bin"
8-
mkdir -p $DISTDIR
9-
10-
# Download and extract in a temporary directory
11-
WORKINGDIR=$(mktemp -d -t rmc_build.XXXXXX)
12-
cd $WORKINGDIR
13-
14-
wget -O "$WORKINGDIR/license.txt" "$RMC_BASE_URL/license.txt"
15-
wget -O "$WORKINGDIR/thirdpartylicenses.txt" "$RMC_BASE_URL/thirdpartylicenses.txt"
16-
17-
for os in ${SUPPORTED_OS[@]}
18-
do
19-
if [[ $os == 'win64' ]] ; then
20-
bin_ext='.exe'
21-
else
22-
bin_ext=''
23-
fi
24-
mkdir -p "$WORKINGDIR/$os"
25-
wget -O "$WORKINGDIR/$os/run-matlab-command$bin_ext" "$RMC_BASE_URL/$os/run-matlab-command$bin_ext"
26-
done
27-
28-
mv -f ./* "$DISTDIR/"
5+
mv -f ./* "$DISTDIR/bin"
296
rm -rf $WORKINGDIR

src/index.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// Copyright 2020-2023 The MathWorks, Inc.
1+
// Copyright 2020-2025 The MathWorks, Inc.
22

33
import * as core from "@actions/core";
44
import * as exec from "@actions/exec";
5-
import * as matlab from "./matlab";
6-
7-
export { matlab };
5+
// TODO: update common-utils version when new version is released
6+
import { matlab, testResultsSummary, buildSummary } from "common-utils";
7+
import * as path from "path";
88

99
/**
1010
* Gather action inputs and then run action.
@@ -13,14 +13,31 @@ async function run() {
1313
const platform = process.platform;
1414
const architecture = process.arch;
1515
const workspaceDir = process.cwd();
16-
const command = core.getInput("command");
16+
17+
const pluginsPath = path.join(__dirname, "plugins").replaceAll("'","''");
18+
const command = "addpath('"+ pluginsPath +"'); " + core.getInput("command");
1719
const startupOpts = core.getInput("startup-options").split(" ");
1820

1921
const helperScript = await matlab.generateScript(workspaceDir, command);
2022
const execOpts = {
21-
env: {...process.env, MW_BATCH_LICENSING_ONLINE:'true'} // Remove when online batch licensing is the default
23+
env: {
24+
...process.env,
25+
MW_BATCH_LICENSING_ONLINE:'true', // Remove when online batch licensing is the default
26+
"MW_MATLAB_BUILDTOOL_DEFAULT_PLUGINS_FCN_OVERRIDE": "buildframework.getDefaultPlugins",
27+
}
2228
};
23-
await matlab.runCommand(helperScript, platform, architecture, (cmd,args)=>exec.exec(cmd,args,execOpts), startupOpts);
29+
await matlab.runCommand(helperScript, platform, architecture, (cmd,args)=>exec.exec(cmd,args,execOpts), startupOpts).finally(() => {
30+
const runnerTemp = process.env.RUNNER_TEMP || '';
31+
const runId = process.env.GITHUB_RUN_ID || '';
32+
const actionName = process.env.GITHUB_ACTION || '';
33+
34+
buildSummary.processAndDisplayBuildSummary(runnerTemp, runId, actionName);
35+
36+
const testResultsData = testResultsSummary.getTestResults(runnerTemp, runId, workspaceDir);
37+
if(testResultsData) {
38+
testResultsSummary.writeSummary(testResultsData, actionName);
39+
}
40+
});
2441
}
2542

2643
// Only run this action if it is invoked directly. Do not run if this node

src/matlab.ts

Lines changed: 0 additions & 109 deletions
This file was deleted.

src/matlab.unit.test.ts

Lines changed: 0 additions & 161 deletions
This file was deleted.

0 commit comments

Comments
 (0)