Skip to content

Commit 30cb837

Browse files
authored
Refactor code and add support for test results summary via common-utils (#61)
* update code for common-utils * add test results summary generation step * update as per feedback and add sample test * add MATLAB test file * revert plugins path logic * update package-lock.json * update plugins path * use common-utils v1.0.0
1 parent d44fc9f commit 30cb837

15 files changed

Lines changed: 549 additions & 827 deletions

.github/workflows/bat.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,28 @@ jobs:
3434

3535
- name: Perform 'setup-matlab'
3636
uses: matlab-actions/setup-matlab@v2
37+
with:
38+
products: MATLAB_Test
3739

3840
- name: Create buildfile.m in project root for tests
3941
shell: bash
4042
run: |
4143
cat <<'_EOF' >> "buildfile.m"
4244
function plan = buildfile
45+
import matlab.buildtool.tasks.TestTask
46+
4347
plan = buildplan(localfunctions);
48+
plan("preMadeTest") = TestTask;
49+
plan("preMadeTest").Dependencies = "build";
4450
plan("test").Dependencies = "build";
4551
plan("deploy").Dependencies = "test";
4652
4753
plan.DefaultTasks = "test";
54+
end
4855
4956
function buildTask(~)
5057
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'building\n'); fclose(f);
58+
end
5159
5260
function testTask(~,tests,options)
5361
arguments
@@ -60,16 +68,20 @@ jobs:
6068
fprintf(f, '%s\n', tests);
6169
fprintf(f, '%s\n', options.OutputDetail);
6270
fclose(f);
71+
end
6372
6473
function deployTask(~)
6574
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'deploying\n'); fclose(f);
75+
end
6676
6777
function checkTask(~)
6878
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'checking\n'); fclose(f);
79+
end
6980
7081
function errorTask(~)
7182
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'erroring\n'); fclose(f);
7283
error('Error occured in errorTask');
84+
end
7385
_EOF
7486
7587
- name: Run build with default tasks
@@ -213,6 +225,11 @@ jobs:
213225
grep "::error::error task failed" console.log
214226
rm console.log
215227
228+
- name: Run build with premade TestTask for test summary
229+
uses: ./
230+
with:
231+
tasks: preMadeTest
232+
216233
- name: Run build with invalid task
217234
continue-on-error: true
218235
uses: ./

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

package-lock.json

Lines changed: 502 additions & 506 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-
"run-matlab-command-action": "github:matlab-actions/run-command#v2.3.0"
24+
"common-utils": "github:matlab-actions/common-utils#v1.0.0"
2525
},
2626
"devDependencies": {
2727
"@types/jest": "^30.0.0",

plugins/+ciplugins/+github/BuildSummaryPlugin.m

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

plugins/+ciplugins/+github/GitHubLogPlugin.m

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

plugins/+ciplugins/+github/ParallelizableBuildSummaryPlugin.m

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

plugins/+ciplugins/+github/getDefaultPlugins.m

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

sample/TheTruth.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
classdef TheTruth < matlab.unittest.TestCase
2+
methods (Test)
3+
function testTheTestOfAllTime(testCase)
4+
onetyone = 11;
5+
testCase.verifyEqual(onetyone, 11);
6+
end
7+
end
8+
end

scripts/setupdeps.sh

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +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-
# Create plugin directory and copy plugin code
11-
cp -R plugins $(pwd)/dist/
12-
13-
# Download and extract in a temporary directory
14-
WORKINGDIR=$(mktemp -d -t rmc_build.XXXXXX)
15-
cd $WORKINGDIR
16-
17-
wget -O "$WORKINGDIR/license.txt" "$RMC_BASE_URL/license.txt"
18-
wget -O "$WORKINGDIR/thirdpartylicenses.txt" "$RMC_BASE_URL/thirdpartylicenses.txt"
19-
20-
for os in ${SUPPORTED_OS[@]}
21-
do
22-
if [[ $os == 'win64' ]] ; then
23-
bin_ext='.exe'
24-
else
25-
bin_ext=''
26-
fi
27-
mkdir -p "$WORKINGDIR/$os"
28-
wget -O "$WORKINGDIR/$os/run-matlab-command$bin_ext" "$RMC_BASE_URL/$os/run-matlab-command$bin_ext"
29-
done
30-
31-
mv -f ./* "$DISTDIR/"
32-
rm -rf $WORKINGDIR
5+
mv -f ./* "$DISTDIR/bin"
6+
rm -rf $WORKINGDIR

0 commit comments

Comments
 (0)