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

Refactor testmo-run-submit-thread #35

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
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 @@ -37,42 +37,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
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
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