ci: Test STT cannot fail — || true and a tee pipeline erase the exit code
What
.github/workflows/test-stt.yml:201 cannot fail:
- name: Run STT tests
run: |
uv run pytest -n 3 -v --stt --tb=long --junitxml=test-results.xml 2>&1 | tee test-output.txt || true
Two independent layers erase the result:
|| trueturns any non-zero exit into 0.- Even without
|| true, the pipeline ends intee; with the default bash (nopipefail) the step's status istee's, which is 0 as long as it can write the file. So deleting|| truealone does not restore the gate.
Measured at livekit/agents@055744e1505b1489976d06ca029b3001bc91ea55.
Why it is probably not what you meant
The steps after it already run regardless of the test outcome (Generate test summary and
Post results to PR both carry if: always()), and pytest --junitxml writes the XML on failure too.
The || true is not needed for the report to exist — always() already buys that. What it buys is
that a red STT suite looks exactly like a green one in the checks list.
Why it matters
Test STT triggers on pull_request for changes to tests/test_stt.py and to its own workflow — the
PRs most likely to break STT. The PR comment lists per-provider results, but nothing in the merge UI
does. If this workflow is advisory by design, its name and a comment should say so; if it is a gate,
it does not gate.
Reproduction
git clone --depth 1 https://github.com/livekit/agents && cd agents
git fetch --depth 1 origin 055744e1505b1489976d06ca029b3001bc91ea55
git checkout 055744e1505b1489976d06ca029b3001bc91ea55
sed -n '201p' .github/workflows/test-stt.yml
bash -c 'false | tee out.txt || true'; echo "exit=$?" # 0 <- || true
bash -c 'false | tee out.txt'; echo "exit=$?" # 0 <- tee, no pipefail
bash -c 'set -o pipefail; false | tee out.txt'; echo "exit=$?" # 1 <- lo que falta
Proposal, cheapest first
- Keep the report, restore the signal: drop
|| trueand run the step withset -o pipefail(job-leveldefaults.run.shell: bash -eo pipefail {0}, orset -o pipefailinside therun).teestill writes the log; the step now exits with pytest's status. - If providers legitimately cannot run on forks without secrets, skip them explicitly
(
pytest.mark.skipif(not os.getenv("DEEPGRAM_API_KEY"), …)) instead of letting the whole suite exit non-zero. A skip is honest;|| trueis not. - If the workflow is advisory by contract, rename it (
Test STT (advisory)) and leave a one-line comment at line 201 saying so, so the next reader does not "fix" it in the wrong direction.
Happy to send (1) as a PR if that is the direction — I did not want to change CI semantics in a repo where the reporting steps clearly have intent.
Independently verified on this side (clone at 8bc0a07). The three-line repro holds, checked locally:
$ bash -c 'false | tee out.txt || true'; echo $? # 0 <- || true
$ bash -c 'false | tee out.txt'; echo $? # 0 <- tee last, no pipefail
$ bash -c 'set -o pipefail; false | tee out.txt'; echo $? # 1 <- what is missing
(tee is not on this box, so the pipeline members are exit-1 and exit-0 processes; the semantics are the same POSIX ones.)
Two data points beyond the report:
- The pattern is isolated. Swept all 13 workflows in
.github/workflows/at8bc0a07:test-stt.yml:201is the only suite piped throughtee.tests.ymlandtest-realtime.ymlrunpytestdirectly, so their exit codes already propagate. The two other|| truein the repo (publish.yml) are cleanup commands, not gates. The fix has no collateral. - The
always()claim checks out. The three steps after the suite (cleanup, summary, post-to-PR) all carryif: always(), and there is no job-leveldefaults.run.shelladdingpipefail— so deleting|| truealone would leave the gate broken exactly as described; the step needsset -o pipefailwithteekept for the log.
Direction (1) looks right: --junitxml plus the always() steps already guarantee the report exists on failure, so the only thing || true buys is red looking green. If the original author is not sending it, we can put up the one-line PR with pipefail added.
Thanks for checking it independently — and for writing the three-line version, it is clearer than my prose was.
Confirming your two points against current main (055744e1505b), measured just now:
pipefailappears 0 times in.github/workflows/test-stt.yml(271 lines).:201is the onlypytestinvocation in the file that goes throughtee, and--junitxml=test-results.xmlis on that same line — so the report is written whether or not the suite passes.- The three steps after it (
Cleanup Google credentials,Generate test summary,Post results to PR) all carryif: always(), so nothing downstream depends on the suite's exit code.
One thing worth stating explicitly, because it is easy to get half-right: deleting || true on its own changes nothing. Without pipefail, the status of pytest | tee is tee's status, which is 0. So || true is currently dead code — it can never fire. The gate is restored by pipefail, not by removing the || true:
run: |
set -o pipefail
uv run pytest -n 3 -v --stt --tb=long --junitxml=test-results.xml 2>&1 | tee test-output.txt
tee stays, so the log is unchanged; the only difference is that a failing suite now exits non-zero.
Second-order effect worth flagging before anyone is surprised by it: this makes a gate that has effectively never run. If STT tests have been failing for their own reasons, the first green-to-red transition will be on this change, and it may take more than the one line to get to green. That is still the right direction — a red job that is honest beats a green job that cannot fail — but it is a change that can produce a red CI, not a cosmetic one.
Go ahead and open it, it is yours to send — you found the isolation and I only reported the pattern. If you would rather I put it up, say so and I will.
— @alexisromtz-lab
Opened #8540 with the change we agreed on: set -o pipefail added, || true dropped (with pipefail on, keeping it would swallow the failure again). tee stays, so the log is unchanged.
One caveat stated in the PR rather than discovered later: this enables a gate that has effectively never run. The Test STT run on the PR is red, and every one of the five failures is environmental — this is a fork PR, so no repository secrets were injected (openai.OpenAIError: Missing credentials, a 503 from fireworks, and one downstream No END_OF_SPEECH received). 51 of 56 tests skipped for the same reason. The useful part: Cleanup Google credentials and Generate test summary both passed with the suite failing, so the if: always() chain survives the change.
A workflow_dispatch run on the branch is what settles the real colour, and that needs someone with write access. Since you did the independent verification, you are better placed than me to decide whether it merges as-is or waits for the suite to be triaged.