diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index 3fb204ef42..3f6543f88f 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -291,7 +291,9 @@ jobs: path: test-results # Best-effort: a read-only token (e.g. fork PRs) can't write the check, so # don't let a publish failure fail the run. The test jobs gate correctness. + # Skipped when every build failed: there is nothing to publish. - name: Publish Test Results + if: ${{ hashFiles('test-results/**/*.xml') != '' }} continue-on-error: true uses: EnricoMi/publish-unit-test-result-action@v2 with: diff --git a/.github/workflows/build_optional.yml b/.github/workflows/build_optional.yml index fa2f356999..3e4c1391fc 100644 --- a/.github/workflows/build_optional.yml +++ b/.github/workflows/build_optional.yml @@ -17,12 +17,14 @@ # listed instead. The macOS and the cl.exe builds never start on their own: # what breaks only cl comes from source changes, which no path rule can see. # -# Each label added starts a run of its own, and the pull request's checks show -# the newest run only, so every run builds everything the labels and the -# changed files ask for. Each build keeps its own concurrency group: the newest -# run's build cancels the one an earlier run of the commit started, and a push -# cancels the builds of the commit it replaces. cancel_closed_pr_builds.yml -# joins the groups by name, so update that file with any change here. +# Each build-* or macos-priority label added starts a run of its own, and the +# pull request's checks show the newest run only, so every run builds +# everything the labels and the changed files ask for; any other label builds +# nothing. Each build keeps its own concurrency group: a build entering its +# group cancels the one already in it, so when two runs start together the +# last to enter wins, not necessarily the newest run. A push cancels the +# builds of the commit it replaces. cancel_closed_pr_builds.yml joins the +# groups by name, so update that file with any change here. name: Optional builds on: @@ -60,6 +62,9 @@ on: jobs: select: name: Select builds + # A label that asks for no build must not restart the builds in progress. + # macos-priority restarts them, to move the macOS build to its own line. + if: ${{ github.event.action != 'labeled' || startsWith(github.event.label.name, 'build-') || github.event.label.name == 'macos-priority' }} runs-on: ubuntu-24.04 outputs: flatpak: ${{ steps.select.outputs.flatpak }} @@ -186,7 +191,9 @@ jobs: publish_test_results: name: Publish Test Results needs: [flatpak, unit_tests_windows_arm64] - if: ${{ !cancelled() && (needs.flatpak.result != 'skipped' || needs.unit_tests_windows_arm64.result != 'skipped') }} + # Concurrency cancels the builds of a superseded run, not the run, so + # !cancelled() alone would still publish for it. + if: ${{ !cancelled() && (contains(fromJSON('["success", "failure"]'), needs.flatpak.result) || contains(fromJSON('["success", "failure"]'), needs.unit_tests_windows_arm64.result)) }} runs-on: ubuntu-latest steps: - name: Download Test Results @@ -196,7 +203,10 @@ jobs: path: test-results # Best-effort, as in build_all.yml: a read-only token (e.g. fork PRs) # can't write the check. The test jobs gate correctness. + # A build that failed runs no tests; publishing nothing would post an + # empty result. - name: Publish Test Results + if: ${{ hashFiles('test-results/**/*.xml') != '' }} continue-on-error: true uses: EnricoMi/publish-unit-test-result-action@v2 with: