From 423a46f24253466de0551208c5ce59f0954def5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wa=C5=9B?= Date: Mon, 16 Sep 2024 14:53:43 +0200 Subject: [PATCH] Generate job annotations without GHA REST API The separate annotate workflow was added to work around permission issues in forked repositories. This is not needed when not using the GHA REST API. Adding annotations via the API was not working correctly anyway, since it added a check for a commit, but one commit can have multiple runs associated with it, and the check sometimes did not show up in the main run. --- .../actions/process-test-results/action.yml | 29 +++++---- .github/workflows/annotate.yml | 64 ------------------- 2 files changed, 17 insertions(+), 76 deletions(-) delete mode 100644 .github/workflows/annotate.yml diff --git a/.github/actions/process-test-results/action.yml b/.github/actions/process-test-results/action.yml index 65c9856d5b7c0..63e21fa6dc6e8 100644 --- a/.github/actions/process-test-results/action.yml +++ b/.github/actions/process-test-results/action.yml @@ -28,18 +28,6 @@ runs: testing/trino-product-tests/target/* logs/* retention-days: 5 - - name: Upload test report - uses: actions/upload-artifact@v4 - # Always upload the test report for the annotate.yml workflow, - # but only the single XML file to keep the artifact small - with: - # Name prefix is checked in the `Annotate checks` workflow - name: test report ${{ inputs.artifact-name }} - if-no-files-found: 'ignore' - path: | - **/surefire-reports/TEST-*.xml - testing/trino-product-tests/target/reports/**/testng-results.xml - retention-days: 5 - name: Upload heap dump uses: actions/upload-artifact@v4 if: format('{0}', inputs.upload-heap-dump) == 'true' @@ -49,3 +37,20 @@ runs: path: | **/*.hprof retention-days: 14 + - name: Process unit and integration test reports + uses: trinodb/github-actions/action-surefire-report@b63800bedfbc7ab1ff2e5fe7eaecf5ab82ce6a70 + if: format('{0}', inputs.has-failed-tests) == 'true' + with: + # this workflow should never fail, as it is not a quality gateway + fail_if_no_tests: false + # don't create or update checks, only annotate current job + skip_publishing: true + - name: Process Product Test reports + uses: starburstdata/action-testng-report@f245422953fb97ec5075d07782a1b596124b7cc4 + if: format('{0}', inputs.has-failed-tests) == 'true' + with: + # this workflow should never fail, as it is not a quality gateway + fail_if_empty: false + github_token: ${{ github.token }} + # don't create or update checks, only annotate current job + skip_publishing: true diff --git a/.github/workflows/annotate.yml b/.github/workflows/annotate.yml deleted file mode 100644 index e2d5caaf9df14..0000000000000 --- a/.github/workflows/annotate.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Annotate checks - -on: - workflow_run: - workflows: ["ci", "docs"] - types: - - completed - -defaults: - run: - shell: bash --noprofile --norc -euo pipefail {0} - -jobs: - annotate: - if: github.repository_owner == 'trinodb' - runs-on: ubuntu-latest - steps: - - name: 'Download artifact' - uses: actions/github-script@v7 - with: - script: | - const fs = require('fs'); - const opts = github.rest.actions.listWorkflowRunArtifacts.endpoint.merge({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: ${{github.event.workflow_run.id }}, - }); - const artifacts = await github.paginate(opts); - for (const artifact of artifacts) { - if (!artifact.name.startsWith('test report ')) { - continue; - } - const download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: artifact.id, - archive_format: 'zip', - }); - fs.writeFileSync('${{github.workspace}}/' + artifact.name + '.zip', Buffer.from(download.data)); - } - - run: | - set -x - pwd - ls - for archive in *.zip; do - # $archive is literally *.zip if there are no zip files matching the glob expression - [ -f "$archive" ] || continue - name=$(basename "$archive" .zip) - mkdir "$name" - (cd "$name" && unzip ../"$archive") - done - # Process unit and integration test reports - - uses: scacap/action-surefire-report@7263a78ba060b395c8a0a0e58fc897efb1bddb7c # v1.6.2 - with: - # this workflow should never fail, as it is not a quality gateway - fail_if_no_tests: false - commit: ${{github.event.workflow_run.head_sha}} - # Process Product Test reports - - uses: starburstdata/action-testng-report@01dfdf31e0f8cc1d3c3f3ba727c7e7a3b438e187 # v1.0.4 - with: - # this workflow should never fail, as it is not a quality gateway - fail_if_empty: false - commit: ${{github.event.workflow_run.head_sha}} - github_token: ${{ github.token }}