Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test("test runs", () => {
process.env["INPUT_JUNIT-OUTPUT"] = "junit-output";
process.env["INPUT_SARIF-OUTPUT"] = "sarif-output";
process.env["INPUT_COVERAGE-OUTPUT"] = "coverage-output";
process.env["INPUT_FAIL-ON-DEFECTS"] = "false";

const np = process.execPath;
const ip = path.join(__dirname, "..", "lib", "main.js");
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ inputs:
coverage-output:
description: coverage report output path (must be a directory, doesn't have to exist yet). You can upload the artifacts to GitHub using the 'actions/upload-artifact' action
required: false
fail-on-defects:
description: should we fail the workflow upon detecting a defect?
required: false
default: "false"
verbosity:
description: verbosity level for starting runs
required: false
Expand Down
13 changes: 11 additions & 2 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ async function run(): Promise<void> {
const sarifOutput: string = core.getInput("sarif-output") || "";
const junitOutput: string = core.getInput("junit-output") || "";
const coverageOutput: string = core.getInput("coverage-output") || "";
const failOnDefects: boolean =
core.getBooleanInput("fail-on-defects") || false;
const verbosity: string = core.getInput("verbosity") || "info";
const owner: string = core.getInput("owner").toLowerCase();
const args: string[] = (core.getInput("args") || "").split(" ");
Expand Down Expand Up @@ -90,6 +92,9 @@ async function run(): Promise<void> {
if (coverageOutput) {
waitArgs.push("--coverage");
}
if (failOnDefects) {
waitArgs.push("--fail-on-defects");
}

// create wait args string
const waitArgsString = waitArgs.join(" ");
Expand Down Expand Up @@ -136,9 +141,11 @@ async function run(): Promise<void> {
runName="$(echo $run | awk -F / '{ print $(NF-1) }')";

# wait for run to finish
${cli} --verbosity ${verbosity} wait $run \
if ! ${cli} --verbosity ${verbosity} wait $run \
--owner ${owner} \
${waitArgsString};
${waitArgsString}; then
exit 3;
fi

# check status, exit with non-zero status if failed or stopped
status=$(${cli} --verbosity ${verbosity} show \
Expand Down Expand Up @@ -174,6 +181,8 @@ async function run(): Promise<void> {
"The Mayhem for Code scan detected the Mayhem run for your " +
"target was unsuccessful."
);
} else if (res == 3) {
throw new Error("The Mayhem for Code scan found defects in your target.");
}
} catch (err: unknown) {
if (err instanceof Error) {
Expand Down