From 1e169576939e51b1d2eb2d807b7368c2a6eb973c Mon Sep 17 00:00:00 2001 From: dhuangnm <74931910+dhuangnm@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:49:44 -0400 Subject: [PATCH] fix issues for reporting and manual run (#288) (#289) * fix reporting and manual run issues * add files * fix another bug --------- Co-authored-by: dhuang --- .github/workflows/build-release.yml | 2 +- .github/workflows/result.xml.fail | 6 +++ .github/workflows/result.xml.success | 5 +++ .github/workflows/util.yml | 67 ++++++++++++---------------- 4 files changed, 41 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/result.xml.fail create mode 100644 .github/workflows/result.xml.success diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index c8d102c0..fbeb1d42 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -4,7 +4,7 @@ on: push: branches: - 'release/[0-9]+.[0-9]+' - workflow_dispatch: + workflow_dispatch: jobs: diff --git a/.github/workflows/result.xml.fail b/.github/workflows/result.xml.fail new file mode 100644 index 00000000..948fd309 --- /dev/null +++ b/.github/workflows/result.xml.fail @@ -0,0 +1,6 @@ + + + + + + diff --git a/.github/workflows/result.xml.success b/.github/workflows/result.xml.success new file mode 100644 index 00000000..d7608df3 --- /dev/null +++ b/.github/workflows/result.xml.success @@ -0,0 +1,5 @@ + + + + + diff --git a/.github/workflows/util.yml b/.github/workflows/util.yml index b69d123f..9af6b2be 100644 --- a/.github/workflows/util.yml +++ b/.github/workflows/util.yml @@ -21,7 +21,7 @@ on: jobs: - BUILD: + BUILD_AND_REPORT: runs-on: ${{ inputs.runs_on }} outputs: status: ${{ steps.build.outputs.status }} @@ -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"` @@ -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 "${{ needs.BUILD.outputs.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 -