Skip to content

Commit

Permalink
WIP replace use of TestMo with ReportPortal for test results data
Browse files Browse the repository at this point in the history
  • Loading branch information
derekk-nm committed Feb 10, 2025
1 parent cd836aa commit c18759f
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 0 deletions.
77 changes: 77 additions & 0 deletions actions/reportportal_launch_create/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: create reportportal launch
description: create neuralmagic reportportal launch and return its ID

inputs:
reportportal_url:
description: reportportal URL
required: true
reportportal_token:
description: reportportal token
required: true
source:
description: source for reportportal, e.g. 'build-test'
required: true
project_id:
description: reportportal project id
required: true
run_name:
description: run name
required: false

outputs:
id:
description: reportportal launch id
value: ${{ steps.reportportal_create_launch_id.outputs.launch_id }}

runs:
using: composite
steps:
- name: create launch
id: reportportal_create_launch_id
run: |
echo "creating reportportal launch ..."
## CHECK reportportal_url and token
if [[ -z "${REPORTPORTAL_URL}" ]]; then
echo "The REPORTPORTAL_URL secret is not defined for this repository"
exit 1
fi
if [[ -z "${REPORTPORTAL_TOKEN}" ]]; then
echo "The REPORTPORTAL_TOKEN secret is not defined for this repository"
exit 1
fi
## construct name
REPORTPORTAL_RUN_NAME="${{ inputs.run_name }}"
if [[ -z "${{ inputs.run_name }}" ]]; then
BRANCH_NAME=${GITHUB_REF_NAME}
TMP=${ACTOR}-${BRANCH_NAME}
REPORTPORTAL_RUN_NAME=$(echo ${TMP} | awk '{print tolower($0)}')
fi
echo "test run name: ${REPORTPORTAL_RUN_NAME}"
starttime=$(date -Iseconds)
## construct launch request
LAUNCH_ID = $(curl -L -X POST "${REPORTPORTAL_URL}/api/v1/plugin/${PROJECT_ID}/junit/import" \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer ${REPORTPORTAL_TOKEN}" \
-F 'file=@"file_path.zip";type=application/x-zip-compressed' \
-F 'launchImportRq="{
\"attributes\": [
{
\"key\": \"skippedIsNotIssue\",
\"system\": true,
\"value\": \"true\"
}
],
\"description\": \"vllm tests\",
\"mode\": \"DEFAULT\",
\"name\": \"${REPORTPORTAL_RUN_NAME}\",
\"startTime\": \"${starttime}\"
}";type=application/json' | jq -r .id)
echo "launch_id=${LAUNCH_ID}" >> "${GITHUB_OUTPUT}"
env:
REPORTPORTAL_URL: ${{ inputs.reportportal_url }}
REPORTPORTAL_TOKEN: ${{ inputs.reportportal_token }}
PROJECT_ID: ${{ inputs.project_id }}
shell: bash
79 changes: 79 additions & 0 deletions actions/reportportal_submit_execution_results/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
name: submit reportportal execution results
description: submit JUnitXML formatted test execution results to ReportPortal

inputs:
reportportal_url:
description: reportportal URL
required: true
reportportal_token:
description: reportportal token
required: true
source:
description: source for reportportal, e.g. 'build-test'
required: true
project_id:
description: reportportal project id
required: true
run_name:
description: run name
required: false
launch_id:
description: ID of the launch to append results to
required: true
results:
description: directory of JUnit '*.xml' formatted result files
required: true

outputs:
id:
description: test results execution id
value: ${{ steps.reportportal_submit_results_xml.outputs.id }}

runs:
using: composite
steps:
- name: upload results
id: reportportal_submit_results_xml
run: |
echo "submitting test run to ReportPortal..."
## CHECK reportportal_url and token
if [[ -z "${REPORTPORTAL_URL}" ]]; then
echo "The REPORTPORTAL_URL secret is not defined for this repository"
exit 1
fi
if [[ -z "${REPORTPORTAL_TOKEN}" ]]; then
echo "The REPORTPORTAL_TOKEN secret is not defined for this repository"
exit 1
fi
# 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
# verify results folder contains XML result files
readarray -d '' RESULTS < <(find "$RESULTS_FOLDER" -type f -name "*.xml" -print0)
if [[ ${#RESULTS[@]} == 0 ]]; 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
## TODO: what does the request look like? does it need to loop through the files list?
# submit results
SUCCESS=0
-- step-status.sh "$STEP_STATUS" || SUCCESS=$?
echo "status=$SUCCESS" >> "$GITHUB_OUTPUT"
exit "$SUCCESS"
env:
REPORTPORTAL_URL: ${{ inputs.reportportal_url }}
REPORTPORTAL_TOKEN: ${{ inputs.reportportal_token }}
PROJECT_ID: ${{ inputs.project_id }}
shell: bash

0 comments on commit c18759f

Please sign in to comment.