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

Build options #16

Merged
merged 25 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
36 changes: 36 additions & 0 deletions .github/workflows/bat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:

function checkTask(~)
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'checking\n'); fclose(f);

function errorTask(~)
f = fopen('buildlog.txt', 'a+'); fprintf(f, 'erroring\n'); fclose(f);
error('Error occured in errorTask');
_EOF

- name: Run build with default tasks
Expand Down Expand Up @@ -93,3 +97,35 @@ jobs:
! grep "check" buildlog2.txt
rm buildlog.txt
rm buildlog2.txt

- name: Run build with task skipping
uses: ./
with:
tasks: deploy
additional-build-options: -skip test

- name: Verify correct tasks appear in buildlog.txt
run: |
set -e
grep "building" buildlog.txt
! grep "testing" buildlog.txt
grep "deploying" buildlog.txt
! grep "checking" buildlog.txt
rm buildlog.txt

- name: Run build with continue on failure
continue-on-error: true
uses: ./
with:
tasks: error deploy
additional-build-options: -continueOnFailure

- name: Verify correct tasks appear in buildlog.txt
run: |
set -e
grep "erroring" buildlog.txt
grep "building" buildlog.txt
grep "testing" buildlog.txt
grep "deploying" buildlog.txt
! grep "checking" buildlog.txt
rm buildlog.txt
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 The MathWorks, Inc.
# Copyright 2022-2024 The MathWorks, Inc.

name: Run MATLAB Build
description: >-
Expand All @@ -9,6 +9,11 @@ inputs:
Space-separated list of tasks to run
required: false
default: ""
additional-build-options:
description: >-
Additional build options for MATLAB build tool
required: false
mw-kapilg marked this conversation as resolved.
Show resolved Hide resolved
default: ""
startup-options:
description: >-
Startup options for MATLAB
Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"@actions/core": "^1.4.0",
"@actions/exec": "^1.1.0",
"run-matlab-command-action": "github:matlab-actions/run-command#v1.2.0"
"run-matlab-command-action": "github:matlab-actions/run-command#v1.2.3"
mw-kapilg marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@types/jest": "^27.0.3",
Expand Down
9 changes: 7 additions & 2 deletions src/buildtool.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
// Copyright 2022 The MathWorks, Inc.
// Copyright 2022-2024 The MathWorks, Inc.

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

export function generateCommand(options: RunBuildOptions): string {
let command: string = "buildtool";
if (options.Tasks) {
command = command + " " + options.Tasks;
}
return command
if (options.AdditionalBuildOptions) {
command = command + " " + options.AdditionalBuildOptions + " -ignoreUnknownOptions";
}

return command;
}
25 changes: 23 additions & 2 deletions src/buildtool.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright 2022 The MathWorks, Inc.
// Copyright 2022-2024 The MathWorks, Inc.

import * as buildtool from "./buildtool";

describe("command generation", () => {
it("buildtool invocation with unspecified options", () => {
it("buildtool invocation with unspecified tasks and build options", () => {
const options: buildtool.RunBuildOptions = {
Tasks: "",
AdditionalBuildOptions: "",
};
mw-kapilg marked this conversation as resolved.
Show resolved Hide resolved

const actual = buildtool.generateCommand(options);
Expand All @@ -15,10 +16,30 @@ describe("command generation", () => {
it("buildtool invocation with tasks specified", () => {
const options: buildtool.RunBuildOptions = {
Tasks: "compile test",
AdditionalBuildOptions: "",
};
mw-kapilg marked this conversation as resolved.
Show resolved Hide resolved

const actual = buildtool.generateCommand(options);
expect(actual).toBe("buildtool compile test")
});

it("buildtool invocation with only build options", () => {
const options: buildtool.RunBuildOptions = {
Tasks: "",
AdditionalBuildOptions: "-continueOnFailure -skip check",
};

const actual = buildtool.generateCommand(options);
expect(actual).toBe("buildtool -continueOnFailure -skip check -ignoreUnknownOptions")
});

it("buildtool invocation with specified tasks and build options", () => {
const options: buildtool.RunBuildOptions = {
Tasks: "compile test",
AdditionalBuildOptions: "-continueOnFailure -skip check",
};

const actual = buildtool.generateCommand(options);
expect(actual).toBe("buildtool compile test -continueOnFailure -skip check -ignoreUnknownOptions")
});
});
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 The MathWorks, Inc.
// Copyright 2022-2024 The MathWorks, Inc.

import * as core from "@actions/core";
import * as exec from "@actions/exec";
Expand All @@ -15,6 +15,7 @@ async function run() {

const options: buildtool.RunBuildOptions = {
Tasks: core.getInput("tasks"),
AdditionalBuildOptions: core.getInput("additional-build-options"),
};

const command = buildtool.generateCommand(options);
Expand Down
Loading