From 3037b946b398ed07df1a181b1a515d880e8b2818 Mon Sep 17 00:00:00 2001 From: "tbhb.dev Agent" Date: Mon, 23 Nov 2026 04:07:37 -0500 Subject: [PATCH] ci: retry the macOS Test step once on transient failures Generated-by: LLM harness=codex;model=openai:gpt-6.2-sol Generated-by: LLM effort=high;harness=codex:0.171.0;model=openai:gpt-6.2-sol;session=sha-256-64:1d0e2fd5d865c676;surface=exec --- .github/actions/setup-bazel-ci/test.sh | 47 ++++++++++++++++++++++++++ .github/workflows/ci.yml | 9 +---- 2 files changed, 48 insertions(+), 8 deletions(-) create mode 100755 .github/actions/setup-bazel-ci/test.sh diff --git a/.github/actions/setup-bazel-ci/test.sh b/.github/actions/setup-bazel-ci/test.sh new file mode 100755 index 00000000..133ff4ac --- /dev/null +++ b/.github/actions/setup-bazel-ci/test.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright Tony Burns + +set -euo pipefail + +run_tests() { + # Exclude mutation reports and their dependents, including suites + # and failure proofs. Mutation runs in its own nightly workflow. + # cspell:ignore rdeps + # The pipeline tests this function's status, so check each setup command. + bazelisk query 'rdeps(//..., kind("mutmut_report|gomutants_report", //...))' >"$RUNNER_TEMP/mutation-excludes" || return + echo '//...' >"$RUNNER_TEMP/test-targets" || return + sed 's/^/-/' "$RUNNER_TEMP/mutation-excludes" >>"$RUNNER_TEMP/test-targets" || return + bazelisk test --config=ci --target_pattern_file="$RUNNER_TEMP/test-targets" +} + +# Rule: Retry only transient runner failures on macOS and log each retry. +# If retries for `tar: Write error` recur, investigate the root cause. +if [[ $RUNNER_OS != macOS ]]; then + run_tests + exit +fi + +out=$(mktemp "$RUNNER_TEMP/bazel-test.XXXXXX") +if run_tests 2>&1 | tee "$out"; then + exit 0 +else + # cspell:ignore PIPESTATUS + statuses=("${PIPESTATUS[@]}") +fi + +status=${statuses[0]} +if ((status == 0)); then + exit "${statuses[1]}" +fi + +if grep -qF 'Unknown host' "$out"; then + pattern='Unknown host' +elif grep -qF 'tar: Write error' "$out"; then + pattern='tar: Write error' +else + exit "$status" +fi + +echo "::warning::macOS Test step retried after a transient failure (matched: $pattern)" +run_tests diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d70db355..71d4dc4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -264,14 +264,7 @@ jobs: - name: Test working-directory: ${{ matrix.workspace.dir }} - run: | - # Exclude mutation reports and their dependents, including suites - # and failure proofs. Mutation runs in its own nightly workflow. - # cspell:ignore rdeps - bazelisk query 'rdeps(//..., kind("mutmut_report|gomutants_report", //...))' >"$RUNNER_TEMP/mutation-excludes" - echo '//...' >"$RUNNER_TEMP/test-targets" - sed 's/^/-/' "$RUNNER_TEMP/mutation-excludes" >>"$RUNNER_TEMP/test-targets" - bazelisk test --config=ci --target_pattern_file="$RUNNER_TEMP/test-targets" + run: bash "$GITHUB_WORKSPACE/.github/actions/setup-bazel-ci/test.sh" # Prints disk and temp space after the tests, including when they fail. - name: Report macOS disk and temp space after the tests