Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/ci-archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ jobs:
tar -czf sunshine.pkg.tar.gz -C pkg .

- name: Build PKGBUILD
env:
DISPLAY: :1
id: build
shell: bash
working-directory: pkg
Expand All @@ -131,9 +129,6 @@ jobs:

source /etc/profile # ensure cuda is in the PATH

# Run Xvfb for headless testing
Xvfb "${DISPLAY}" -screen 0 1024x768x24 &

# Check PKGBUILD
sudo -u builder namcap -i PKGBUILD

Expand Down Expand Up @@ -173,7 +168,7 @@ jobs:
name: coverage-Archlinux
path: |
pkg/src/build/coverage.xml
pkg/src/build/tests/test_results.xml
pkg/src/build/tests/test_results
if-no-files-found: error

- name: Copy Artifacts
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci-freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
x11/libXfixes \
x11/libXrandr \
x11/libXtst \
x11-servers/xorg-server
x11-servers/xorg-server@xvfb

# create symlink for shebang bash compatibility
ln -s /usr/local/bin/bash /bin/bash
Expand Down Expand Up @@ -168,7 +168,7 @@ jobs:
run: |
set -e
cd "${GITHUB_WORKSPACE}"
ninja -C build
cmake --build build

- name: Package
shell: freebsd {0}
Expand Down Expand Up @@ -215,13 +215,13 @@ jobs:
shell: freebsd {0}
run: |
set -e
cd "${GITHUB_WORKSPACE}/build/tests"
cd "${GITHUB_WORKSPACE}/build"

export DISPLAY=:1
Xvfb ${DISPLAY} -screen 0 1024x768x24 &
XVFB_PID=$!

./test_sunshine --gtest_color=yes --gtest_output=xml:test_results.xml
ctest --output-on-failure

kill ${XVFB_PID}

Expand Down Expand Up @@ -252,7 +252,7 @@ jobs:
name: coverage-FreeBSD-${{ matrix.cmake_processor }}
path: |
build/coverage.xml
build/tests/test_results.xml
build/tests/test_results
if-no-files-found: error

- name: Upload Artifacts
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ jobs:
sudo make install
cd .. && rm -rf libva-*

- name: Setup virtual desktop
uses: LizardByte/actions/actions/virtual_desktop@188c8ccad593e0f68bcf6aacb6bf84f10359d26f # v2026.905.43751

- name: Build Linux
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
Expand All @@ -108,7 +111,7 @@ jobs:
working-directory: build
run: |
# install sunshine to the DESTDIR
DESTDIR=AppDir ninja install
DESTDIR=AppDir cmake --install .
test -f AppDir/usr/share/sunshine/udev/rules.d/60-sunshine.rules
grep -Fq 'IMPORT{parent}="HID_*"' \
AppDir/usr/share/sunshine/udev/rules.d/60-sunshine.rules
Expand Down Expand Up @@ -188,9 +191,6 @@ jobs:
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*

- name: Setup virtual desktop
uses: LizardByte/actions/actions/virtual_desktop@188c8ccad593e0f68bcf6aacb6bf84f10359d26f # v2026.905.43751

- name: Setup uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
Expand All @@ -209,8 +209,8 @@ jobs:

- name: Run tests
id: test
working-directory: build/tests
run: ./test_sunshine --gtest_color=yes --gtest_output=xml:test_results.xml
working-directory: build
run: ctest --output-on-failure

- name: Upload system tray screenshots
if: >-
Expand Down Expand Up @@ -248,7 +248,7 @@ jobs:
name: coverage-Linux-${{ matrix.name }}
path: |
build/coverage.xml
build/tests/test_results.xml
build/tests/test_results
if-no-files-found: error

- name: Upload Artifacts
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
cmake \
doxygen \
graphviz \
ninja \
node \
pkgconf \
icu4c@78 \
Expand Down Expand Up @@ -127,6 +128,7 @@ jobs:
mkdir -p build
cmake \
-B build \
-G Ninja \
-S . \
-DBUILD_DOCS="${{ matrix.build_docs }}" \
-DBUILD_WERROR=ON \
Expand All @@ -144,7 +146,7 @@ jobs:
- name: Build
run: |
echo "::add-matcher::.github/matchers/gcc.json"
cmake --build build -j "$(sysctl -n hw.ncpu)"
cmake --build build --parallel "$(sysctl -n hw.ncpu)"
echo "::remove-matcher owner=gcc::"

- name: Package DMG
Expand Down Expand Up @@ -192,8 +194,8 @@ jobs:

- name: Test
id: test
working-directory: build/tests
run: ./test_sunshine --gtest_color=yes --gtest_output=xml:test_results.xml
working-directory: build
run: ctest --output-on-failure

- name: Upload system tray screenshots
if: >-
Expand Down Expand Up @@ -230,7 +232,7 @@ jobs:
name: coverage-${{ matrix.name }}
path: |
build/coverage.xml
build/tests/test_results.xml
build/tests/test_results
if-no-files-found: error

- name: Set artifact prefix
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ jobs:
-DSUNSHINE_PUBLISHER_WEBSITE="https://app.lizardbyte.dev" \
-DSUNSHINE_PUBLISHER_ISSUE_URL="https://app.lizardbyte.dev/support"
echo "::add-matcher::.github/matchers/gcc.json"
ninja -C build
cmake --build build
echo "::remove-matcher owner=gcc::"

- name: Check Windows linkage
Expand Down Expand Up @@ -351,22 +351,21 @@ jobs:
run: cat ./build/cpack_artifacts/_CPack_Packages/win64/WIX/wix.log || true

- name: Initialize tray icon
working-directory: build/tests
working-directory: build
env:
SUNSHINE_CONFIGURE_TRAY_ICONS: '1'
run: >-
./test_sunshine.exe
--gtest_color=yes
--gtest_filter=SystemTrayTest.InitializesTrayForWorkflowConfiguration
ctest --output-on-failure
--tests-regex '^SystemTrayTest\.InitializesTrayForWorkflowConfiguration$'

- name: Configure Windows tray screenshots
uses: LizardByte/tray/.github/actions/configure-windows-tray-screenshots@master

- name: Run tests
id: test
shell: msys2 {0}
working-directory: build/tests
run: ./test_sunshine.exe --gtest_color=yes --gtest_output=xml:test_results.xml
working-directory: build
run: ctest --output-on-failure

- name: Upload system tray screenshots
if: >-
Expand Down Expand Up @@ -406,7 +405,7 @@ jobs:
name: coverage-${{ matrix.name }}
path: |
build/coverage.xml
build/tests/test_results.xml
build/tests/test_results
if-no-files-found: error

- name: Package Windows Debug Info
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,8 @@ jobs:
- name: Upload test results
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
disable_search: true
directory: ./_coverage/tests
fail_ci_if_error: true
files: ./_coverage/tests/test_results.xml
report_type: test_results
flags: ${{ matrix.name }}
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions cmake/dependencies/libevdev_Sunshine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ else()
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND sh <SOURCE_DIR>/autogen.sh && <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
BUILD_COMMAND make
BUILD_BYPRODUCTS <SOURCE_DIR>/libevdev/.libs/libevdev.a
INSTALL_COMMAND ""
)

Expand Down
20 changes: 20 additions & 0 deletions cmake/targets/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,26 @@ endif()

# tests
if(BUILD_TESTS)
enable_testing()

# CMAKE_TEST_LAUNCHER was added in CMake 3.29. Use xvfb-run automatically
# for headless Unix builds while preserving an existing X11 or Wayland
# desktop, such as the one used by the tray screenshot tests.
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.29"
AND UNIX
AND NOT APPLE
AND NOT DEFINED CMAKE_TEST_LAUNCHER
AND "$ENV{DISPLAY}" STREQUAL ""
AND "$ENV{WAYLAND_DISPLAY}" STREQUAL "")
find_program(SUNSHINE_XVFB_EXECUTABLE NAMES Xvfb NO_CACHE)
find_program(SUNSHINE_XVFB_RUN_EXECUTABLE NAMES xvfb-run NO_CACHE)

if(SUNSHINE_XVFB_EXECUTABLE AND SUNSHINE_XVFB_RUN_EXECUTABLE)
set(CMAKE_TEST_LAUNCHER "${SUNSHINE_XVFB_RUN_EXECUTABLE}" -a)
message(STATUS "Using xvfb-run for headless tests: ${SUNSHINE_XVFB_RUN_EXECUTABLE}")
endif()
endif()

add_subdirectory(tests)
endif()

Expand Down
6 changes: 2 additions & 4 deletions docker/debian.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@ set -e
_BUILD

# run tests
WORKDIR /build/sunshine/build/tests
WORKDIR /build/sunshine/build
RUN <<_TEST
#!/bin/bash
set -e
export DISPLAY=:1
Xvfb "${DISPLAY}" -screen 0 1024x768x24 &
./test_sunshine --gtest_color=yes
ctest --output-on-failure
_TEST

FROM sunshine-base AS sunshine
Expand Down
2 changes: 1 addition & 1 deletion docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ mkdir build

```bash
cmake -B build -G Ninja -S .
ninja -C build
cmake --build build
```

> [!TIP]
Expand Down
9 changes: 6 additions & 3 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Read our contribution guide in our organization level

@tabs{
@tab{CMake | ```bash
cmake -B build -G Ninja -S . --target web-ui
ninja -C build web-ui
cmake -B build -G Ninja -S .
cmake --build build --target web-ui
```}
@tab{Manual | ```bash
npm run dev
Expand Down Expand Up @@ -176,9 +176,12 @@ can be disabled by setting the `BUILD_TESTS` CMake option to `OFF`.
To run the tests, execute the following command.

```bash
./build/tests/test_sunshine
ctest --test-dir build --output-on-failure
```

On headless Linux systems using CMake 3.29 or newer, CMake automatically runs the tests through `xvfb-run` when both
`Xvfb` and `xvfb-run` are installed. An existing X11 or Wayland display is used as-is.

To see all available options, run the tests with the `--help` flag.

```bash
Expand Down
10 changes: 5 additions & 5 deletions packaging/linux/Arch/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ makedepends=(
'desktop-file-utils'
"gcc${_gcc_dep_suffix}"
'git'
'make'
'ninja'
'nodejs'
'npm'
'python-jinja' # required by the glad OpenGL/EGL loader generator
Expand Down Expand Up @@ -138,6 +138,7 @@ build() {
local _cmake_options=(
-S "$pkgname"
-B build
-G Ninja
-Wno-dev
-D BUILD_DOCS=OFF
-D BUILD_WERROR=ON
Expand Down Expand Up @@ -190,16 +191,15 @@ check() {
export CC="gcc${_gcc_env_suffix}"
export CXX="g++${_gcc_env_suffix}"

cd "${srcdir}/build/tests"
cd "${srcdir}/build"
# Do not silently upload misleading coverage if the gcov runtime cannot
# write profile data, such as when its version differs from the compiler.
GCOV_EXIT_AT_ERROR=1 ./test_sunshine --gtest_color=yes --gtest_output=xml:test_results.xml
GCOV_EXIT_AT_ERROR=1 \
ctest --output-on-failure

# Generate coverage report
# Run gcovr from the build directory (where all .gcda/.gcno files are)
# This matches the pattern used in ci-linux.yml
cd "${srcdir}/build"

# Dynamically find the gcov executable from the selected compiler.
# This ensures we use the same gcov version that produced the .gcno files.
local gcov_path
Expand Down
Loading
Loading