From 782fb1241907ce9bbdcf0b486794869e28e389df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9cate=20Kleidukos?= Date: Sun, 1 Sep 2024 11:46:34 +0200 Subject: [PATCH] Collect all test reports in a single workflow and print it in GitHub closes #21 --- .github/workflows/ci.yml | 25 ++++++++++++++++++------- .github/workflows/test-reports.yml | 30 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/test-reports.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a539a99..3eb8172 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 }} @@ -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/* @@ -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 }} @@ -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 diff --git a/.github/workflows/test-reports.yml b/.github/workflows/test-reports.yml new file mode 100644 index 0000000..e2e2670 --- /dev/null +++ b/.github/workflows/test-reports.yml @@ -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'