Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow command support for MATLAB Build results #32

Merged
merged 80 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
35758be
Added workflow command support
nbhoski May 14, 2024
efdf3d6
Added test case in bat.yml
nbhoski May 14, 2024
3438257
updated test case in bat.yml
nbhoski May 14, 2024
e32eb50
updated test case in bat.yml
nbhoski May 14, 2024
439a1a0
updated test case in bat.yml
nbhoski May 14, 2024
32c6af6
updated test case in bat.yml
nbhoski May 14, 2024
334bc6b
updated test case in bat.yml
nbhoski May 14, 2024
e9712ef
updated test case in bat.yml
nbhoski May 14, 2024
d915d32
updated test case in bat.yml
nbhoski May 14, 2024
d322f1e
updated test case in bat.yml
nbhoski May 14, 2024
c7699ff
updated test case in bat.yml
nbhoski May 14, 2024
0541e26
updated test case in bat.yml
nbhoski May 14, 2024
fa7ec71
updated test case in bat.yml
nbhoski May 14, 2024
944e31d
updated test case in bat.yml
nbhoski May 15, 2024
8c40a9d
updated test case in bat.yml
nbhoski May 15, 2024
7fcae0d
updated test case in bat.yml
nbhoski May 15, 2024
64e9061
updated test case in bat.yml
nbhoski May 15, 2024
e504311
updated test case in bat.yml
nbhoski May 15, 2024
aa1ecc7
updated test case in bat.yml
nbhoski May 15, 2024
4b7b3df
updated test case in bat.yml
nbhoski May 15, 2024
7602966
updated test case in bat.yml
nbhoski May 15, 2024
9f7b1de
updated test case in bat.yml
nbhoski May 15, 2024
277c902
updated test case in bat.yml
nbhoski May 15, 2024
536a5b3
updated test case in bat.yml
nbhoski May 15, 2024
f22faa8
updated as per review coments
nbhoski May 16, 2024
9fd251e
updated as per review coments
nbhoski May 16, 2024
f99223a
updated as per review coments
nbhoski May 16, 2024
86a78ac
updated as per review coments
nbhoski May 16, 2024
0595577
updated as per review coments
nbhoski May 16, 2024
3d02c04
updated as per review coments
nbhoski May 16, 2024
3a7de8d
updated as per review coments
nbhoski May 16, 2024
a1e87bd
updated as per review coments
nbhoski May 16, 2024
e66e7e6
updated as per review coments
nbhoski May 16, 2024
16f5c13
updated as per review coments
nbhoski May 16, 2024
2abbe1f
updated as per review coments
nbhoski May 16, 2024
028ee8a
updated as per review coments
nbhoski May 16, 2024
bc14d9a
updated as per review coments
nbhoski May 16, 2024
814a293
updated as per review coments
nbhoski May 16, 2024
47f2b89
updated exec option
nbhoski May 16, 2024
a547663
updated exec option
nbhoski May 16, 2024
33586a9
updated exec option
nbhoski May 16, 2024
01c8024
updated exec option
nbhoski May 16, 2024
64f6a93
updated exec option
nbhoski May 16, 2024
9722d24
updated exec option
nbhoski May 16, 2024
44487b8
updated exec option
nbhoski May 16, 2024
9b55a5a
Added test to parse log
nbhoski May 16, 2024
4851124
Added test to parse log
nbhoski May 16, 2024
8c149e8
Testing grep
nbhoski May 16, 2024
62ea9ca
Testing grep
nbhoski May 16, 2024
3a43c1f
Testing grep
nbhoski May 16, 2024
fac0db3
Testing grep
nbhoski May 16, 2024
1c187fc
Testing grep
nbhoski May 16, 2024
52147e9
Testing grep
nbhoski May 16, 2024
d38df4d
Testing grep
nbhoski May 16, 2024
5c14e54
Testing grep
nbhoski May 16, 2024
71b6f33
Testing grep
nbhoski May 16, 2024
d01a23c
reverted log changes
nbhoski May 16, 2024
1166e0f
Added tests using log read
nbhoski May 16, 2024
a652940
Added tests using log read
nbhoski May 16, 2024
d85a848
Added tests using log read
nbhoski May 16, 2024
652eccf
Added tests using log read
nbhoski May 16, 2024
3eb7edc
Added tests using log read
nbhoski May 16, 2024
717f101
Added tests using log read
nbhoski May 16, 2024
693f9b6
Added tests using log read
nbhoski May 16, 2024
85aa216
Added tests using log read
nbhoski May 16, 2024
2d9adef
Updated review comments
nbhoski May 16, 2024
23bb592
changed copy path
nbhoski May 16, 2024
971d260
changed copy path
nbhoski May 16, 2024
02c1f8e
Reverted copy changes
nbhoski May 16, 2024
a89b9eb
Reverted copy changes
nbhoski May 16, 2024
0785f29
Changed -cp strategy and plugin name
nbhoski May 17, 2024
2f562cd
Updated the test case
nbhoski May 17, 2024
a4225dd
Updated task name in group display
nbhoski May 17, 2024
b194eed
Changed env variable setting
nbhoski May 17, 2024
2887995
Changed env variable setting
nbhoski May 17, 2024
943f02d
Changed env variable setting
nbhoski May 17, 2024
c6323a0
Changed env variable setting
nbhoski May 17, 2024
4d89220
Changed env variable setting
nbhoski May 17, 2024
38ed051
Changed env variable setting
nbhoski May 20, 2024
286b899
Refactored test variables
nbhoski May 20, 2024
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
14 changes: 14 additions & 0 deletions .github/workflows/bat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,17 @@ jobs:
grep "deploying" buildlog.txt
! grep "checking" buildlog.txt
rm buildlog.txt

- name: Run build with startup options
continue-on-error: true
uses: ./
with:
tasks: deploy error
build-options: -continueOnFailure
startup-options: -logfile console.log

- name: Verify workflow command is added
run: |
grep "::group::deploy" console.log
grep "::error::error task failed" console.log
rm console.log
22 changes: 22 additions & 0 deletions plugins/+ciplugins/+github/GitHubLogPlugin.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
classdef GitHubLogPlugin < matlab.buildtool.plugins.BuildRunnerPlugin

% Copyright 2024 The MathWorks, Inc.

methods (Access=protected)

function runTask(plugin, pluginData)
% Add Github workflow command for grouping the tasks
disp("::group::" + pluginData.TaskResults.Name);

[email protected](plugin, pluginData);

% Add Github workflow command ::error:: if the task is failed
if pluginData.TaskResults.Failed
disp("::error::" + pluginData.TaskResults.Name + " task failed");
end

% Complete the group command
disp("::endgroup::");
end
end
end
13 changes: 13 additions & 0 deletions plugins/+ciplugins/+github/getDefaultPlugins.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function plugins = getDefaultPlugins(pluginProviderData)

% Copyright 2024 The MathWorks, Inc.

arguments
pluginProviderData (1,1) struct = struct();
end

plugins = [ ...
matlab.buildtool.internal.getFactoryDefaultPlugins(pluginProviderData) ...
ciplugins.github.GitHubLogPlugin() ...
];
end
3 changes: 3 additions & 0 deletions scripts/setupdeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ SUPPORTED_OS=('win64' 'maci64' 'maca64' 'glnxa64')
DISTDIR="$(pwd)/dist/bin"
mkdir -p $DISTDIR

# Create plugin directory and copy plugin code
cp -R plugins $(pwd)/dist/

# Download and extract in a temporary directory
WORKINGDIR=$(mktemp -d -t rmc_build.XXXXXX)
cd $WORKINGDIR
Expand Down
4 changes: 3 additions & 1 deletion src/buildtool.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Copyright 2022-2024 The MathWorks, Inc.
import * as path from "path";

export interface RunBuildOptions {
Tasks?: string;
BuildOptions?: string;
}

export function generateCommand(options: RunBuildOptions): string {
let command: string = "buildtool";
const pluginsPath = path.join(__dirname,"plugins").replace("'","''");
let command: string = "addpath('"+ pluginsPath +"');buildtool"
if (options.Tasks) {
command = command + " " + options.Tasks;
}
Expand Down
9 changes: 5 additions & 4 deletions src/buildtool.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright 2022-2024 The MathWorks, Inc.

import * as path from "path";
import * as buildtool from "./buildtool";

describe("command generation", () => {
Expand All @@ -10,7 +11,7 @@ describe("command generation", () => {
};

const actual = buildtool.generateCommand(options);
expect(actual).toBe("buildtool")
expect(actual).toBe("addpath('"+ path.join(__dirname, "plugins").replace("'","''") +"');buildtool")
nbhoski marked this conversation as resolved.
Show resolved Hide resolved
});

it("buildtool invocation with tasks specified", () => {
Expand All @@ -19,7 +20,7 @@ describe("command generation", () => {
};

const actual = buildtool.generateCommand(options);
expect(actual).toBe("buildtool compile test")
expect(actual).toBe("addpath('"+ path.join(__dirname, "plugins").replace("'","''") +"');buildtool compile test")
});

it("buildtool invocation with only build options", () => {
Expand All @@ -29,7 +30,7 @@ describe("command generation", () => {
};

const actual = buildtool.generateCommand(options);
expect(actual).toBe("buildtool -continueOnFailure -skip check")
expect(actual).toBe("addpath('"+ path.join(__dirname, "plugins").replace("'","''") +"');buildtool -continueOnFailure -skip check")
});

it("buildtool invocation with specified tasks and build options", () => {
Expand All @@ -39,6 +40,6 @@ describe("command generation", () => {
};

const actual = buildtool.generateCommand(options);
expect(actual).toBe("buildtool compile test -continueOnFailure -skip check")
expect(actual).toBe("addpath('"+ path.join(__dirname, "plugins").replace("'","''") +"');buildtool compile test -continueOnFailure -skip check")
});
});
16 changes: 7 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ async function run() {
const command = buildtool.generateCommand(options);
const startupOptions = core.getInput("startup-options").split(" ");

const helperScript = await core.group("Generate script", async () => {
const helperScript = await matlab.generateScript(workspaceDir, command);
core.info("Successfully generated script");
return helperScript;
});

await core.group("Run command", async () => {
await matlab.runCommand(helperScript, platform, architecture, exec.exec, startupOptions);
});
const helperScript = await matlab.generateScript(workspaceDir, command);
const execOptions = { env: {
...process.env,
"MW_MATLAB_BUILDTOOL_DEFAULT_PLUGINS_FCN_OVERRIDE":"ciplugins.github.getDefaultPlugins",
}};

await matlab.runCommand(helperScript, platform, architecture, (cmd,args)=>exec.exec(cmd,args,execOptions), startupOptions);
nbhoski marked this conversation as resolved.
Show resolved Hide resolved
}

run().catch((e) => {
Expand Down
Loading