From 996fd4a226bcdcd54a712d5236bc996126588fe5 Mon Sep 17 00:00:00 2001 From: Kai Hudalla Date: Thu, 22 Aug 2024 12:47:03 +0200 Subject: [PATCH] Add input to fail Action on OFT error (#6) --- action.yaml | 9 ++++++++- run-oft.sh | 14 +++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/action.yaml b/action.yaml index b9323d1..bb5e73c 100644 --- a/action.yaml +++ b/action.yaml @@ -20,16 +20,23 @@ inputs: description: The format of the report that OpenFastTrace should produce. default: "plain" required: false + fail-on-error: + description: | + By default, the action will never fail but indicate the result of running the trace command in the "oft-exit-code" output variable. + Setting this parameter to "true" will let the Action return the exit code produced by running OpenFastTrace. + default: "false" + required: false outputs: oft-exit-code: description: | - The exit code indicating the outcome of running OpenFastTrace (0: success, 1: failure). + The exit code indicating the outcome of running OpenFastTrace (0: success, > 0: failure). The report is created in any case, as long as OpenFastTrace could be run at all. runs: using: "docker" image: "Dockerfile" args: + - ${{ inputs.fail-on-error }} - ${{ inputs.report-filename }} - ${{ inputs.report-format }} - ${{ inputs.file-patterns }} diff --git a/run-oft.sh b/run-oft.sh index 5f522f6..0ee056a 100755 --- a/run-oft.sh +++ b/run-oft.sh @@ -1,10 +1,10 @@ #!/bin/sh # [impl->req~run-oft-trace-command~1] - -report_file_name=$1 -report_format=$2 -files=$3 +fail_on_error=$1 +report_file_name=$2 +report_format=$3 +files=$4 echo "::notice::using OpenFastTrace JARs from: ${LIB_DIR}" @@ -19,6 +19,10 @@ then echo "oft-exit-code=0" >> "${GITHUB_OUTPUT}" echo "All specification items are covered." >> "${GITHUB_STEP_SUMMARY}" else - echo "oft-exit-code=$?" >> "${GITHUB_OUTPUT}" + oft_exit_code=$? + echo "oft-exit-code=${oft_exit_code}" >> "${GITHUB_OUTPUT}" echo "Some specification items are not covered. See created report (${report_file_name}) for details." >> "${GITHUB_STEP_SUMMARY}" + if [ "${fail_on_error}" = "true" ]; then + exit ${oft_exit_code} + fi fi