From 8c2ea999a9d50b7804ce8a69ce5511f7ddd7693d Mon Sep 17 00:00:00 2001 From: Joakim Hassila Date: Mon, 21 Sep 2026 11:25:28 +0200 Subject: [PATCH] ci(patch): Recover the benchmark check's exit status and find the coverage executable Two workflow defects hit every pull request. The benchmark comparison step runs under `bash -e`, so a non-zero exit from `benchmark baseline check` aborted the step before the exit-code mapping and every threshold deviation reported as an unknown failure; the workflow has failed on all eight runs in its history. With the mapping reachable, a crash or a missing baseline also needs a comment producer, so the failure text now covers every status that is not same, regression or improvement. The coverage export looked for `PackageTests.xctest`, but the package is named FixedPointDecimal, and since the `swift:latest` container moved to 6.4 the default Swift Build backend emits per-target runner and `.so` artifacts, so the fallback `find` came back empty and `llvm-cov` ran with no file. The coverage run now uses the native build system, whose single `PackageTests.xctest` executable the export step finds by package name, and the step lists the build directory when it finds nothing instead of invoking `llvm-cov` without a file. Co-Authored-By: Claude Fable 5.1 --- .github/workflows/swift-benchmark-delta.yml | 13 +++++++++++-- .github/workflows/swift-code-coverage.yml | 19 ++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/swift-benchmark-delta.yml b/.github/workflows/swift-benchmark-delta.yml index 5a4f7fa..a4fc515 100644 --- a/.github/workflows/swift-benchmark-delta.yml +++ b/.github/workflows/swift-benchmark-delta.yml @@ -57,8 +57,12 @@ jobs: continue-on-error: true run: | echo $(date) >> $GITHUB_STEP_SUMMARY + # The step runs under `bash -e`: without the guard a non-zero exit from the check aborts the + # step here, before the mapping below, and every deviation reports as an unknown failure. + set +e swift package ${BENCHMARK_PACKAGE_PATH} benchmark baseline check main pull_request --format markdown >> $GITHUB_STEP_SUMMARY 2>benchmark_stderr rawExitStatus=$? + set -e cat benchmark_stderr >&2 # SwiftPM maps all non-zero plugin exit codes to 1, so parse stderr to recover the real status if [ "$rawExitStatus" -eq 0 ]; then @@ -81,11 +85,16 @@ jobs: echo "_Pull request is the same as baseline_" echo "[Pull request benchmark comparison [${{ matrix.os }}] with 'main' run at $(date -Iseconds)]($BENCHMARK_RUN_URL)" } > benchmark_comment - - if: ${{ env.exitStatus == '1' }} + - if: ${{ env.exitStatus != '0' && env.exitStatus != '2' && env.exitStatus != '4' }} name: Pull request comment text failure run: | + case "${{ env.exitStatus }}" in + 3) text="_Pull request benchmark crashed_" ;; + 5) text="_Pull request benchmark baseline not found_" ;; + *) text="_Pull request had an unknown failure (exit status ${{ env.exitStatus }})_" ;; + esac { - echo "_Pull request had an unknown failure_" + echo "$text" echo "[Pull request benchmark comparison [${{ matrix.os }}] with 'main' run at $(date -Iseconds)]($BENCHMARK_RUN_URL)" } > benchmark_comment - if: ${{ env.exitStatus == '2' }} diff --git a/.github/workflows/swift-code-coverage.yml b/.github/workflows/swift-code-coverage.yml index f51da6a..02cb148 100644 --- a/.github/workflows/swift-code-coverage.yml +++ b/.github/workflows/swift-code-coverage.yml @@ -28,19 +28,24 @@ jobs: - name: Run tests continue-on-error: true run: | - [ -d Tests ] && swift test --parallel --enable-code-coverage + # The native build system keeps the single PackageTests.xctest executable that the export + # step reads; the Swift Build backend, the default since 6.4, emits per-target runner and .so files. + [ -d Tests ] && swift test --parallel --enable-code-coverage --build-system native - name: Export code coverage run: | - xctest_binary=".build/debug/${{ github.event.repository.name }}PackageTests.xctest" - if [ ! -f ${xctest_binary} ]; then + # The executable carries the package name, not the repository name. + xctest_binary=$(find .build/debug/ -maxdepth 1 -type f -name "*PackageTests.xctest" | head -1) + if [ -z "${xctest_binary}" ]; then xctest_binary=$(find .build/debug/ -type f -name "*.xctest" | tail -1) - echo "Will llvm-cov '${xctest_binary}'" fi - - if [ -f ${xctest_binary} ]; then - llvm-cov export -format="lcov" ${xctest_binary} -instr-profile .build/debug/codecov/default.profdata > info.lcov + if [ -z "${xctest_binary}" ]; then + echo "No test executable found under .build/debug:" + ls -la .build/debug/ + exit 1 fi + echo "Will llvm-cov '${xctest_binary}'" + llvm-cov export -format="lcov" "${xctest_binary}" -instr-profile .build/debug/codecov/default.profdata > info.lcov - name: Upload codecov uses: codecov/codecov-action@v5