Skip to content

Commit

Permalink
fix issues for reporting and manual run (#288) (#289)
Browse files Browse the repository at this point in the history
* fix reporting and manual run issues

* add files

* fix another bug

---------

Co-authored-by: dhuang <dhuang@MacBook-Pro-2.local>
  • Loading branch information
dhuangnm and dhuang committed Oct 31, 2023
1 parent cb3e6f4 commit 1e16957
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- 'release/[0-9]+.[0-9]+'
workflow_dispatch:
workflow_dispatch:

jobs:

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/result.xml.fail
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="BuildStatus" tests="1" failures="1" errors="1">
<testcase name="BuildStatus">
<failure message="build failed" type="Error"/>
</testcase>
</testsuite>
5 changes: 5 additions & 0 deletions .github/workflows/result.xml.success
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="BuildStatus" tests="1" failures="0" errors="0">
<testcase name="BuildStatus">
</testcase>
</testsuite>
67 changes: 29 additions & 38 deletions .github/workflows/util.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:

jobs:

BUILD:
BUILD_AND_REPORT:
runs-on: ${{ inputs.runs_on }}
outputs:
status: ${{ steps.build.outputs.status }}
Expand Down Expand Up @@ -77,11 +77,16 @@ jobs:
aws s3 cp dist/*.whl s3://nm-github-actions/${{ github.event.repository.name }}/
if [ $? -eq 0 ]; then
echo "ok: copied to s3://nm-github-actions/${{ github.event.repository.name }}/"
echo "status=success" >> "$GITHUB_OUTPUT"
else
echo "failed: copied to s3://nm-github-actions/${{ github.event.repository.name }}/"
exitCode=1
fi
if [ ${exitCode} -eq 1 ]; then
echo "status=failed" >> "$GITHUB_OUTPUT"
exit 1
cp .github/workflows/result.xml.fail result.xml
else
echo "status=success" >> "$GITHUB_OUTPUT"
cp .github/workflows/result.xml.success result.xml
fi
oldDate=`date --date='-2 month' +%Y%m%d`
oldWhl=`(aws s3 ls s3://nm-github-actions/${{ github.event.repository.name }}/ | grep nightly | grep "${oldDate}") || echo "notfound"`
Expand All @@ -92,44 +97,30 @@ jobs:
aws s3 rm s3://nm-github-actions/${{ github.event.repository.name }}/${oldwhl}
done
fi
TESTMO:
if: success() || failure()
needs: BUILD
runs-on: ${{ inputs.runs_on }}
steps:

- id: report
run: |
echo "node: $(node -v)"
echo "npm: $(npm -v)"
echo "Installing testmo cli..."
sudo npm install -g @testmo/testmo-cli
export TESTMO_TOKEN=${{ secrets.TESTMO_TEST_TOKEN }}
TESTMO_URL="https://neuralmagic.testmo.net"
todaytime=`date +%Y%m%d`
name="${{ github.event.repository.name }} ${{ inputs.build_type }} ${todaytime} ${{ needs.BUILD.outputs.commitid }} RunID:${{ inputs.run_id }}"
echo "========== Build info ==========="
echo "name: ${name}"
echo "build status: ${{ needs.BUILD.outputs.status }}"
echo "<status>${{ needs.BUILD.outputs.status }}</status>" > result.xml
exit_code=1
if [[ "${{ needs.BUILD.outputs.status }}" = "success" ]]; then
exit_code=0
fi
echo "echo \"GHA job ${{ needs.BUILD.outputs.status }}: https://github.com/neuralmagic/${{ github.event.repository.name }}/actions/runs/${{ inputs.run_id }}\"; exit ${exit_code}" > result.sh
echo "========== Report to testmo ==========="
echo "testmo automation:run:submit \\"
echo " --instance ${TESTMO_URL} \\"
echo " --project-id ${{ inputs.testmo_project_id }} \\"
echo " --name ${name} \\"
echo " --source ${{ github.event.repository.name }} \\"
echo " --results result.xml"
testmo automation:run:submit \
# TESTMO
echo "node: $(node -v)"
echo "npm: $(npm -v)"
echo "Installing testmo cli..."
sudo npm install -g @testmo/testmo-cli
export TESTMO_TOKEN=${{ secrets.TESTMO_TEST_TOKEN }}
TESTMO_URL="https://neuralmagic.testmo.net"
todaytime=`date +%Y%m%d`
name="${{ github.event.repository.name }} ${{ inputs.build_type }} ${todaytime} ${GITHUB_SHA:0:7} RunID:${{ inputs.run_id }}"
echo "========== Build info ==========="
echo "name: ${name}"
echo "build: $GITHUB_OUTPUT"
echo "echo \"GHA job $GITHUB_OUTPUT: https://github.com/neuralmagic/${{ github.event.repository.name }}/actions/runs/${{ inputs.run_id }}\"; exit ${exitCode}" > result.sh
echo "========== Report to testmo ==========="
echo "testmo automation:run:submit \\"
echo " --instance ${TESTMO_URL} \\"
echo " --project-id ${{ inputs.testmo_project_id }} \\"
echo " --name ${name} \\"
echo " --source ${{ github.event.repository.name }} \\"
echo " --results result.xml"
testmo automation:run:submit \
--instance "${TESTMO_URL}" \
--project-id ${{ inputs.testmo_project_id }} \
--name "${name}" \
--source "${{ github.event.repository.name }}" \
--results result.xml \
-- bash result.sh

0 comments on commit 1e16957

Please sign in to comment.