Skip to content

ci(homebrew): enable test coverage #3842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
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
63 changes: 27 additions & 36 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,6 @@ jobs:
rm '/usr/local/bin/python3.13-config'
brew install python

- name: Setup python
id: python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Configure formula
run: |
# variables for formula
Expand Down Expand Up @@ -621,7 +615,7 @@ jobs:
- name: Validate Homebrew Formula
id: test
if: matrix.release != true
uses: LizardByte/homebrew-release-action@v2025.503.165455
uses: LizardByte/homebrew-release-action@v2025.506.15440
with:
formula_file: ${{ github.workspace }}/homebrew/sunshine.rb
git_email: ${{ secrets.GH_BOT_EMAIL }}
Expand All @@ -630,29 +624,26 @@ jobs:
token: ${{ secrets.GH_BOT_TOKEN }}
validate: true

- name: Generate gcov report
id: test_report
# any except canceled or skipped
# TODO: fix coverage, no .gcno files are being created
# TODO: .gcno files are supposed to be created next to .o files
if: false
# if: >-
# always() &&
# matrix.release != true &&
# (steps.test.outcome == 'success' || steps.test.outcome == 'failure')
- name: Debug upload gcda artifact
if: always() && matrix.release != true
uses: actions/upload-artifact@v4
with:
name: homebrew-gcda-${{ matrix.os_name }}-${{ matrix.os_version }}
path: ${{ steps.test.outputs.buildpath }}/build/tests/CMakeFiles/test_sunshine.dir/__/src/audio.cpp.gcda

- name: Debug homebrew buildpath
if: always() && matrix.release != true
run: |
cp -rf ${{ steps.test.outputs.buildpath }}/build/ ./build/
cd build
# print the build path
echo "Build path: ${{ steps.test.outputs.buildpath }}"
echo "contents:"
ls -Ra

${{ steps.python.outputs.python-path }} -m pip install gcovr
${{ steps.python.outputs.python-path }} -m gcovr . -r ../src \
--exclude-noncode-lines \
--exclude-throw-branches \
--exclude-unreachable-branches \
--verbose \
--xml-pretty \
-o coverage.xml
# print the test path
echo "----"
echo "Test path: ${{ steps.test.outputs.testpath }}"
echo "contents:"
ls -Ra

- name: Upload test results to Codecov
# any except canceled or skipped
Expand All @@ -673,18 +664,16 @@ jobs:

- name: Upload coverage
# any except canceled or skipped
# TODO: enable this once coverage report is fixed
if: false
# if: >-
# always() &&
# matrix.release != true &&
# (steps.test_report.outcome == 'success') &&
# startsWith(github.repository, 'LizardByte/')
if: >-
always() &&
matrix.release != true &&
(steps.test_report.outcome == 'success') &&
startsWith(github.repository, 'LizardByte/')
uses: codecov/codecov-action@v5
with:
disable_search: true
fail_ci_if_error: true
files: ./build/coverage.xml
files: ${{ steps.test.outputs.testpath }}/build/coverage.xml
flags: ${{ matrix.os_name }}-${{ matrix.os_version }} (Homebrew)
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
Expand Down Expand Up @@ -992,7 +981,9 @@ jobs:
- name: Generate gcov report
id: test_report
# any except canceled or skipped
if: always() && (steps.test.outcome == 'success' || steps.test.outcome == 'failure')
if: >-
always() &&
(steps.test.outcome == 'success' || steps.test.outcome == 'failure')
shell: msys2 {0}
working-directory: build
run: |
Expand Down
17 changes: 17 additions & 0 deletions packaging/sunshine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class @PROJECT_NAME@ < Formula
depends_on "ninja" => :build
depends_on "node" => :build
depends_on "pkg-config" => :build
depends_on "gcovr" => :test
depends_on "curl"
depends_on "miniupnpc"
depends_on "openssl"
Expand Down Expand Up @@ -353,5 +354,21 @@ def caveats
# run the test suite
system bin/"test_sunshine", "--gtest_color=yes", "--gtest_output=xml:test_results.xml"
assert_path_exists testpath/"test_results.xml"

# create gcovr report
if ENV["HOMEBREW_BUILDPATH"]

cd File.join(ENV["HOMEBREW_BUILDPATH"], "build") do
system "gcovr", ".",
"-r", "../src",
"--exclude-noncode-lines",
"--exclude-throw-branches",
"--exclude-unreachable-branches",
"--verbose",
"--xml-pretty",
"-o=coverage.xml"
end
assert_path_exists File.join(ENV["HOMEBREW_BUILDPATH"], "build", "coverage.xml")
end
end
end
Loading