Skip to content

Commit

Permalink
Refactor testmo-run-submit-thread (#35)
Browse files Browse the repository at this point in the history
* Refactor testmo-run-submit-thread

* Try referencing job name

* Fail on error
  • Loading branch information
dbarbuzzi authored Dec 12, 2024
1 parent ce61432 commit 50e6d5d
Showing 1 changed file with 35 additions and 29 deletions.
64 changes: 35 additions & 29 deletions actions/testmo-run-submit-thread/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,48 @@ runs:

- id: submit_thread
run: |
# verify there are result files to be submitted
ls -Al
REPORT=1
RESULTS=
if [[ ! -d ${{ inputs.results }} ]]; then
REPORT=0
else
RESULTS=$(find ${{ inputs.results }} -type f -name "*.xml")
# verify results folder exists
if [[ ! -d "$RESULTS_FOLDER" ]]; then
echo "Results folder '$RESULTS_FOLDER' does not exist in working directory:"
ls -A
echo "::warning title=$GITHUB_JOB - MISSING RESULTS FOLDER::Results folder does not exist in working directory"
exit 1
fi
if [[ -z "${RESULTS}" ]]; then
REPORT=0
# verify results folder contains XML result files
RESULTS=$(find "$RESULTS_FOLDER" -type f -name "*.xml")
if [[ -z "$RESULTS" ]]; then
echo "Results folder '$RESULTS_FOLDER' does not contain any XML result files:"
ls -A "$RESULTS_FOLDER"
echo "::warning title=$GITHUB_JOB - MISSING RESULT FILES::Results folder did not contain any XML result files"
exit 1
fi
# generate resources file if necessary
if [[ -f "$THREAD_RESOURCES" ]]; then
thread_resources=$THREAD_RESOURCES
else
echo '{}' > thread_resources.json
thread_resources=thread_resources.json
fi
# submit results
SUCCESS=0
if [[ ${REPORT} -eq 1 ]]; then
echo "submitting results to TESTMO run ..."
## not checking testmo_url and token as this should be
## called between "create" and "complete"
if [[ -f "${{ inputs.thread_resources }}" ]]; then
thread_resources=${{ inputs.thread_resources }}
else
echo '{}' > thread_resources.json
thread_resources=thread_resources.json
fi
npx testmo automation:run:submit-thread \
--instance ${TESTMO_URL} \
--run-id ${TESTMO_RUN_ID} \
--results ${RESULTS} \
--thread-resources ${thread_resources} \
-- step-status.sh "${{ inputs.step_status }}" || SUCCESS=$?
fi
echo "status=${SUCCESS}" >> "$GITHUB_OUTPUT"
exit ${SUCCESS}
echo "submitting results to TESTMO run ..."
npx testmo automation:run:submit-thread \
--instance "$TESTMO_URL" \
--run-id "$TESTMO_RUN_ID" \
--results "$RESULTS" \
--thread-resources "$thread_resources" \
-- step-status.sh "$STEP_STATUS" || SUCCESS=$?
echo "status=$SUCCESS" >> "$GITHUB_OUTPUT"
exit "$SUCCESS"
env:
TESTMO_URL: ${{ inputs.testmo_url }}
TESTMO_TOKEN: ${{ inputs.testmo_token }}
TESTMO_RUN_ID: ${{ inputs.testmo_run_id }}
RESULTS_FOLDER: ${{ inputs.results }}
THREAD_RESOURCES: ${{ inputs.thread_resources }}
STEP_STATUS: ${{ inputs.step_status }}
shell: bash

0 comments on commit 50e6d5d

Please sign in to comment.