Build and publish test reports #201
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and publish test reports | |
| on: | |
| workflow_run: | |
| workflows: | |
| - "Simple build and test" | |
| types: | |
| - completed | |
| permissions: | |
| contents: read | |
| checks: write | |
| statuses: write | |
| pages: write | |
| id-token: write | |
| pull-requests: write | |
| jobs: | |
| get-pr-info: | |
| runs-on: ubuntu-latest | |
| name: Get PR info | |
| if: (github.event.workflow_run.event == 'pull_request') && (github.repository == 'docling-project/docling-java') | |
| outputs: | |
| pr_number: ${{ steps.pr.outputs.number }} | |
| steps: | |
| - name: Download PR metadata | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: pr-metadata | |
| path: pr-metadata | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Read PR number | |
| id: pr | |
| run: echo "number=$(cat pr-metadata/number)" >> $GITHUB_OUTPUT | |
| build-reports: | |
| runs-on: ubuntu-latest | |
| name: Build test report | |
| if: (github.event.workflow_run.event == 'pull_request') && (github.repository == 'docling-project/docling-java') | |
| needs: get-pr-info | |
| steps: | |
| - name: Download test report artifacts | |
| uses: actions/download-artifact@v6 | |
| with: | |
| pattern: build-reports-java*-${{ github.event.workflow_run.run_attempt }}* | |
| path: build-reports-artifacts | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish JUnit test report (PR comment with collapsed failures) | |
| uses: mikepenz/action-junit-report@v6 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| # Aggregate all JUnit XMLs from all matrix jobs | |
| report_paths: build-reports-artifacts/**/build/test-results/**/*.xml | |
| check_name: Gradle Test Results (all modules & JDKs) | |
| comment: true | |
| detailed_summary: true | |
| group_suite: true | |
| include_passed: false | |
| include_skipped: true | |
| require_tests: false | |
| fail_on_failure: true | |
| fail_on_parse_error: true | |
| token: ${{ env.GITHUB_TOKEN }} | |
| commit: ${{ github.event.workflow_run.head_sha }} | |
| pr_id: ${{ needs.get-pr-info.outputs.pr_number}} | |
| check_annotations: true | |
| - name: Comment with HTML reports link | |
| uses: actions/github-script@v8 | |
| env: | |
| RUN_ID: ${{ github.event.workflow_run.id }} | |
| PR_NUMBER: ${{ needs.get-pr-info.outputs.pr_number}} | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const runId = process.env.RUN_ID; | |
| const prNumber = process.env.PR_NUMBER; | |
| const body = [ | |
| "HTML test reports are available as workflow artifacts (zipped HTML).", | |
| `\n• Download: [Artifacts for this run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId})`, | |
| ].join("\n"); | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body, | |
| }); |