feat(ci): hive xunit output parse (#4945)

This commit is contained in:
Max Revitt 2022-08-05 15:28:56 +01:00 committed by GitHub
parent 7a2e7e8c06
commit 8b475564d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 69 deletions

View File

@ -148,20 +148,5 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
if: always() if: always()
with: with:
name: hive-ci-output name: test-results
path: results/*.xml 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 }}

View File

@ -18,58 +18,43 @@ jobs:
actions: read actions: read
steps: steps:
- name: download and extract artifacts - name: parse hive results
env: uses: phoenix-actions/test-reporting@v8
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} with:
run: | artifact: test-results
mkdir -p artifacts && cd artifacts name: Tests
path: '*.xml'
artifacts_url=${{ github.event.workflow_run.artifacts_url }} reporter: java-junit
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: publish hive test results - name: set badge color
uses: EnricoMi/publish-unit-test-result-action@v1 shell: bash
with: run: |
commit: ${{ github.event.workflow_run.head_sha }} case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
event_file: artifacts/event.json success)
event_name: ${{ github.event.workflow_run.event }} echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
files: "artifacts/**/*.xml" ;;
failure)
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
;;
neutral)
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
;;
esac
- name: set badge color - name: create badge
shell: bash uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
run: | with:
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in label: Hive
success) 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 }}'
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV color: ${{ env.BADGE_COLOR }}
;; path: badge.svg
failure)
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
;;
neutral)
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
;;
esac
- name: create badge - name: upload badge to gist
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1 if: >
with: github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'devel' ||
label: Hive github.event_name != 'workflow_run' && github.ref == 'refs/heads/devel'
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 }}' uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
color: ${{ env.BADGE_COLOR }} with:
path: badge.svg token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/revittm/dc492845ba6eb694e6c7279224634b20
- name: upload badge to gist file: badge.svg
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