Skip to content

Commit 80130a2

Browse files
Combined unit/integration test code coverage in CI (#289)
* Combined unit/integration test code coverage in CI * Fix coverage workflow failure handling Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 250bf4e commit 80130a2

2 files changed

Lines changed: 61 additions & 7 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,17 +466,19 @@ jobs:
466466

467467
# ============================================================================
468468
# Code Coverage (Linux only)
469-
# Runs a debug build through gcov/lcov and generates an inline action summary
470-
# alongside an HTML report of unit test coverage.
469+
# Runs a debug build through gcov and generates an inline action summary
470+
# alongside an HTML report. Unit and integration tests both execute against
471+
# that build so their .gcda data is included in the same report.
471472
# ============================================================================
472473
coverage:
473474
name: Code Coverage
474475
if: inputs.run_coverage
475476
runs-on: ubuntu-24.04
476477
# A debug build instrumented with --coverage is far heavier (RAM + disk)
477478
# than the release builds. Cap the wall-clock so a stuck/OOM build fails
478-
# fast and visibly instead of hanging toward the 6h default.
479-
timeout-minutes: 45
479+
# fast and visibly instead of hanging toward the 6h default. The extra
480+
# time beyond the build covers the integration server and test run.
481+
timeout-minutes: 60
480482

481483
steps:
482484
- name: Checkout (with submodules)
@@ -583,13 +585,64 @@ jobs:
583585
- name: Build
584586
run: cmake --build build-debug --parallel 2
585587

586-
# ---------- Run unit tests ----------
588+
# ---------- Run unit and integration tests ----------
589+
# Both binaries write .gcda for the instrumented liblivekit, so running
590+
# them in sequence produces one combined coverage report.
587591
- name: Run unit tests
588592
timeout-minutes: 5
589593
run: |
590594
build-debug/bin/livekit_unit_tests \
591595
--gtest_output=xml:build-debug/unit-test-results.xml
592596
597+
- name: Start livekit-server
598+
if: inputs.integration_repeat > 0
599+
id: livekit_server
600+
uses: livekit/dev-server-action@5d4d5337a875e2d1afd37bed03c601d159dab002 # v1.1.1
601+
with:
602+
github-token: ${{ github.token }}
603+
version: v1.13.3
604+
config: |
605+
enable_participant_data_blob: true
606+
607+
- name: Install livekit-cli
608+
if: inputs.integration_repeat > 0
609+
run: |
610+
set -euxo pipefail
611+
curl -sSL https://get.livekit.io/cli | bash
612+
lk --version
613+
614+
- name: Start token server
615+
if: inputs.integration_repeat > 0
616+
id: token_server
617+
uses: livekit/token-server-action@a1e42c649a1998d5b224f5102f252c07762024f0 # v0.0.1
618+
with:
619+
livekit-url: ws://localhost:7880
620+
api-key: devkey
621+
api-secret: secret
622+
623+
- name: Run integration tests
624+
if: inputs.integration_repeat > 0
625+
timeout-minutes: ${{ inputs.integration_timeout_minutes }}
626+
env:
627+
RUST_LOG: "metrics=debug"
628+
LIVEKIT_CREATE_TOKEN_URL: ${{ steps.token_server.outputs.token-url }}
629+
run: |
630+
set -euo pipefail
631+
source scripts/set-test-tokens.sh
632+
# TODO(BOT-477) Temporarily disable platform audio integration tests in CI until instability is resolved
633+
bash scripts/run-with-backtrace.sh \
634+
build-debug/bin/livekit_integration_tests \
635+
--gtest_filter='-PlatformAudioIntegrationTest.*' \
636+
--gtest_output=xml:build-debug/integration-test-results.xml
637+
638+
- name: Dump livekit-server log on failure
639+
if: failure() && steps.livekit_server.outputs.log-path != ''
640+
run: tail -n 500 "${{ steps.livekit_server.outputs.log-path }}" || true
641+
642+
- name: Dump token server log on failure
643+
if: failure() && steps.token_server.outputs.log-path != ''
644+
run: tail -n 200 "${{ steps.token_server.outputs.log-path }}" || true
645+
593646
# Make resource-exhaustion failures visible instead of silent. Runs only
594647
# if an earlier step failed (e.g. OOM during Build).
595648
- name: Diagnostics on failure
@@ -602,6 +655,7 @@ jobs:
602655
603656
# ---------- Generate coverage reports ----------
604657
- name: Generate coverage reports
658+
if: (success() || failure()) && hashFiles('build-debug/**/*.gcda') != ''
605659
run: |
606660
mkdir -p coverage-html
607661
gcovr build-debug \
@@ -619,6 +673,7 @@ jobs:
619673
--txt coverage-summary.txt
620674
621675
- name: Add coverage summary to job
676+
if: (success() || failure()) && hashFiles('coverage-summary.txt') != ''
622677
run: |
623678
{
624679
echo '## Code Coverage Summary'

‎.gitignore‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ cmake_install.cmake
88
out
99
build.log
1010
build/
11-
build-debug/
12-
build-release/
11+
build-*/
1312
local-install/
1413
release/
1514
vcpkg_installed/

0 commit comments

Comments
 (0)