Skip to content

Running unit tests in CI#89

Open
alan-george-lk wants to merge 12 commits intomainfrom
feature/ci_unit_tests
Open

Running unit tests in CI#89
alan-george-lk wants to merge 12 commits intomainfrom
feature/ci_unit_tests

Conversation

@alan-george-lk
Copy link
Copy Markdown
Contributor

@alan-george-lk alan-george-lk commented Apr 9, 2026

This PR adjusts the CI to do the following:

  • Build stage now builds release-tests
  • An additional step to run the unit tests is added
  • An existing folder integration/ existed in the tests directory, but contained unit-level testing. A new folder unit/ was added, which is now being executed in CI
    • Note: "Integration" tests are scoped as tests that require a LiveKit server instance running, and ideally will be invoked in CI on a later PR to match other SDK convention
  • Changes needed to get the unit tests buildable across all platforms

Note: part of the time spent on this PR was spent investigating a separate testing stage for unit testing (and upcoming clang-tidy), but passing artifacts between stages became pretty cumbersome and affected overall build usefulness. I think a future refactor of the CI jobs should be considered to improve this.

@alan-george-lk alan-george-lk changed the title Draft - Running unit tests in CI Running unit tests in CI Apr 10, 2026
Copy link
Copy Markdown
Contributor

@stephen-derosa stephen-derosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me thanks for doing this!

- os: ubuntu-latest
name: linux-x64
build_cmd: ./build.sh release-examples
build_cmd: ./build.sh release-tests
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be using build-all here? note it will add significant time since it builds debug/release tests/exampls

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to it, I can profile that. Would be good to build all but yeah, will increase time

fi
return 1
}
for pair in "SimpleRoom:simple_room" "SimpleRpc:simple_rpc" "SimpleDataStream:simple_data_stream"; do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it safe to completely remove the smoke tests? Does it make sense to keeo them to ensure that they are compiled and be executed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The smoke tests were failing to build early in this endeavor, that might have been before I split the unit tests out. Can put this back, let me review and get back to you

& "${{ matrix.build_dir }}/bin/livekit_unit_tests.exe" `
--gtest_output=xml:${{ matrix.build_dir }}/unit-test-results.xml

- name: Upload test results
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

int sample_rate = 0;
int num_channels = 0;

// TODO: figure out what generates this welcome.wav file such that this test isn't skipped
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please create a ticket for this and use TODO(project-ticketid). I am guilt of not doing this as much as i should.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a TODO for me before this PR, ideally I'll fix it before we merge, otherwise 100% will do

int sample_rate = 0;
int num_channels = 0;

// TODO: figure out what generates this welcome.wav file such that this test isn't skipped
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xianshijing-lk insights here?

Copy link
Copy Markdown
Collaborator

@xianshijing-lk xianshijing-lk Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was something very basic, I generated it by using the the say cmd on macbook, like
say "Hello world" -o hello_world.wav

- os: macos-latest
name: macos-arm64
build_cmd: ./build.sh release-examples
build_cmd: ./build.sh release-tests
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curiously, should we build all instead ?

like
./build.sh release-all

shell: pwsh
run: ${{ matrix.build_cmd }}

# ---------- Smoke test cpp-example-collection binaries ----------
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume it is still useful to run this cpp-example-collection ?

If any change is required inside the cpp-example-collection, that raise a flag that we might have a breaking API change ?

# ============================================================================

file(GLOB UNIT_TEST_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/unit/*.cpp"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, generally it is better to add all the cpp files explicitly to a list.

For instance, with this current code, when adding new test files, CMake won't automatically rerun.

${Protobuf_INCLUDE_DIRS}
)
if(TARGET absl::base)
get_target_property(_livekit_unit_test_absl_inc absl::base INTERFACE_INCLUDE_DIRECTORIES)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This smells a bit.

Why do we need such special handling of absl::base ?

I wonder if we have some real problem with our SDK, technically, consumers of livekit SDK needs to manually have the include dirs from absl::base unless the tests use them ?

${LIVEKIT_ROOT_DIR}/include
${LIVEKIT_ROOT_DIR}/src
${LIVEKIT_BINARY_DIR}/generated
${Protobuf_INCLUDE_DIRS}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why protobuf is needed ?

maybe some tests are not correctly written ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants