From 8b475564d9f4ab5afb3a2b3b7572c1b58d3e547e Mon Sep 17 00:00:00 2001 From: Max Revitt Date: Fri, 5 Aug 2022 15:28:56 +0100 Subject: [PATCH] feat(ci): hive xunit output parse (#4945) --- .github/workflows/ci.yml | 19 +------ .github/workflows/hive-results.yml | 89 +++++++++++++----------------- 2 files changed, 39 insertions(+), 69 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9781d2e34..9a961e02b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,20 +148,5 @@ jobs: uses: actions/upload-artifact@v3 if: always() with: - name: hive-ci-output - path: results/*.xml - - event_file: - needs: - - tests - - tests-windows - - docker - name: archive event file - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} - steps: - - name: upload - uses: actions/upload-artifact@v2 - with: - name: event file - path: ${{ github.event_path }} + name: test-results + path: results/*.xml \ No newline at end of file diff --git a/.github/workflows/hive-results.yml b/.github/workflows/hive-results.yml index 607efdcd7..279a4e14f 100644 --- a/.github/workflows/hive-results.yml +++ b/.github/workflows/hive-results.yml @@ -18,58 +18,43 @@ jobs: actions: read steps: - - name: download and extract artifacts - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - run: | - mkdir -p artifacts && cd artifacts - - artifacts_url=${{ github.event.workflow_run.artifacts_url }} - - gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact - do - IFS=$'\t' read name url <<< "$artifact" - gh api $url > "$name.zip" - unzip -d "$name" "$name.zip" - done + - name: parse hive results + uses: phoenix-actions/test-reporting@v8 + with: + artifact: test-results + name: Tests + path: '*.xml' + reporter: java-junit - - name: publish hive test results - uses: EnricoMi/publish-unit-test-result-action@v1 - with: - commit: ${{ github.event.workflow_run.head_sha }} - event_file: artifacts/event.json - event_name: ${{ github.event.workflow_run.event }} - files: "artifacts/**/*.xml" + - name: set badge color + shell: bash + run: | + case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in + success) + echo "BADGE_COLOR=31c653" >> $GITHUB_ENV + ;; + failure) + echo "BADGE_COLOR=800000" >> $GITHUB_ENV + ;; + neutral) + echo "BADGE_COLOR=696969" >> $GITHUB_ENV + ;; + esac - - name: set badge color - shell: bash - run: | - case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in - success) - echo "BADGE_COLOR=31c653" >> $GITHUB_ENV - ;; - failure) - echo "BADGE_COLOR=800000" >> $GITHUB_ENV - ;; - neutral) - echo "BADGE_COLOR=696969" >> $GITHUB_ENV - ;; - esac + - name: create badge + uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1 + with: + label: Hive + status: '${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}' + color: ${{ env.BADGE_COLOR }} + path: badge.svg - - name: create badge - uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1 - with: - label: Hive - status: '${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}' - color: ${{ env.BADGE_COLOR }} - path: badge.svg - - - name: upload badge to gist - if: > - github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'devel' || - github.event_name != 'workflow_run' && github.ref == 'refs/heads/devel' - uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d - with: - token: ${{ secrets.GIST_TOKEN }} - gistURL: https://gist.githubusercontent.com/revittm/dc492845ba6eb694e6c7279224634b20 - file: badge.svg \ No newline at end of file + - name: upload badge to gist + if: > + github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'devel' || + github.event_name != 'workflow_run' && github.ref == 'refs/heads/devel' + uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d + with: + token: ${{ secrets.GIST_TOKEN }} + gistURL: https://gist.githubusercontent.com/revittm/dc492845ba6eb694e6c7279224634b20 + file: badge.svg \ No newline at end of file