From 4b08a451141d23bb61cdc576500bc2d2646b9ed4 Mon Sep 17 00:00:00 2001 From: Joshua Villalta <93329405+vgoat21@users.noreply.github.com> Date: Mon, 16 Nov 2026 09:39:34 +0000 Subject: [PATCH] ci(ENG-4588): complete a test report check the reporter left in progress dorny/test-reporter creates its check run and updates it with the results a moment later. That update intermittently 404s, because the new check run is not visible to the API yet; continue-on-error keeps the job green, but the check run stays in progress for good, so the PR never shows all checks finished. When the report step fails, find any 'Tests (Ghidra X)' check run for the head commit that is not completed, retrying while it becomes visible, and complete it with the outcome of the Run tests step. Look them up with filter=all: with filter=latest the endpoint returned no runs at all for two of the three stuck checks. --- .github/workflows/build.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b2ff3003..250248f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,6 +66,7 @@ jobs: run: $GHIDRA_INSTALL_DIR/support/sleigh $GHIDRA_INSTALL_DIR/Ghidra/Processors/x86/data/languages/x86-64.slaspec - name: Run tests + id: tests run: xvfb-run ./gradlew test - name: Upload test results @@ -76,6 +77,7 @@ jobs: path: build/reports/tests/test/ - name: Publish test report + id: report if: always() # Updating the check run right after creating it intermittently 404s, which failed jobs whose # tests had passed. Failing tests already fail "Run tests", so the report is display only. @@ -85,3 +87,34 @@ jobs: name: Tests (Ghidra ${{ matrix.ghidra }}) path: build/test-results/test/*.xml reporter: java-junit + + - name: Complete a test report left in progress + # When the reporter's update 404s, the check run it created stays "in progress" for good, so the PR never + # shows all checks finished. Complete it with the outcome of the tests. Display only, like the report. + if: always() && steps.report.outcome == 'failure' + continue-on-error: true + env: + GH_TOKEN: ${{ github.token }} + CHECK_NAME: Tests (Ghidra ${{ matrix.ghidra }}) + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + CONCLUSION: ${{ steps.tests.outcome == 'success' && 'success' || 'failure' }} + run: | + summary="The test reporter could not attach the results to this check (HTTP 404). See the Run tests step and the test-results artifact." + # The check run may not be visible to the API yet, which is what made the reporter's update fail + for attempt in 1 2 3 4 5; do + ids=$(gh api -X GET "repos/$GITHUB_REPOSITORY/commits/$HEAD_SHA/check-runs" \ + -f check_name="$CHECK_NAME" -f filter=all \ + --jq '.check_runs[] | select(.status != "completed") | .id') || ids="" + completed=true + for id in $ids; do + gh api -X PATCH "repos/$GITHUB_REPOSITORY/check-runs/$id" \ + -f status=completed -f conclusion="$CONCLUSION" \ + -f "output[title]=$CHECK_NAME" -f "output[summary]=$summary" >/dev/null || completed=false + done + if [ -n "$ids" ] && [ "$completed" = true ]; then + echo "Completed '$CHECK_NAME' ($ids) as $CONCLUSION" + exit 0 + fi + sleep 5 + done + echo "::warning::Could not find or complete an in-progress '$CHECK_NAME' check"