Skip to content

Commit

Permalink
Collect all test reports in a single workflow and print it in GitHub
Browse files Browse the repository at this point in the history
closes #21
  • Loading branch information
Hécate Kleidukos committed Sep 1, 2024
1 parent 6ec16e1 commit 782fb12
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ jobs:
- name: Build
run: cabal build --project-file=cabal.release.project

- name: Test
run: cabal test --project-file=cabal.release.project --test-options "--xml=../print-api/report-${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}.xml" all

- name: Upload the test report
uses: actions/upload-artifact@v4
if: success() || failure() # always run even if the previous step fails
with:
name: junit-test-results
path: report-${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}.xml

- name: Install
run: |
mkdir distribution
Expand Down Expand Up @@ -105,7 +115,7 @@ jobs:
echo "PRINTAPI_EXEC_TAR=${archive}" >> $GITHUB_ENV
- name: Upload the executables archive
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifact
path: ${{ env.PRINTAPI_EXEC_TAR }}
Expand Down Expand Up @@ -164,13 +174,14 @@ jobs:
echo "$GITHUB_WORKSPACE/distribution" >> "$GITHUB_PATH"
- name: Test
run: cabal test --project-file=cabal.static.project --test-options "--xml=../print-api/report.xml" all
run: cabal test --project-file=cabal.static.project --test-options "--xml=../print-api/report-${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}.xml" all

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
- name: Upload the test report
uses: actions/upload-artifact@v4
if: success() || failure() # always run even if the previous step fails
with:
report_paths: "report.xml"
name: junit-test-results
path: report-${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}.xml

- name: File type
run: file distribution/*
Expand All @@ -193,7 +204,7 @@ jobs:
echo "PRINTAPI_EXEC_TAR=${archive}" >> $GITHUB_ENV
- name: Upload the executables archive
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifact
path: ${{ env.PRINTAPI_EXEC_TAR }}
Expand All @@ -204,7 +215,7 @@ jobs:
needs: ['builds', 'build-alpine']

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact
path: ./out
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/test-reports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test Reports
on:
workflow_run:
workflows: [ builds, build-alpine ]
types: [ completed ]

permissions:
checks: write

jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Install juitparser
run: |
pip install junitparser==3.2.0
- name: Download Test Report
uses: dawidd6/action-download-artifact@v6
with:
name: junit-test-results
workflow: ${{ github.event.workflow.id }}
run_id: ${{ github.event.workflow_run.id }}
- name: Merge XML files
run: |
junitparser merge --glob *.xml final-report.xml
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
with:
commit: ${{github.event.workflow_run.head_sha}}
report_paths: 'final-report.xml'

0 comments on commit 782fb12

Please sign in to comment.