Skip to content

Commit 432b24e

Browse files
ci(homebrew): enable test coverage
1 parent 458a4a5 commit 432b24e

File tree

3 files changed

+67
-57
lines changed

3 files changed

+67
-57
lines changed

.github/workflows/ci-homebrew.yml

Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,12 @@ jobs:
4949
- name: Checkout
5050
uses: actions/checkout@v5
5151

52-
- name: Fix homebrew python
53-
if: matrix.os_name == 'macos' && matrix.os_version == '13'
52+
- name: Fix homebrew cmake # # see https://github.com/actions/runner-images/issues/12912
53+
if: matrix.os_name == 'macos'
5454
run: |
55-
rm '/usr/local/bin/2to3'
56-
rm '/usr/local/bin/2to3-3.12'
57-
rm '/usr/local/bin/idle3'
58-
rm '/usr/local/bin/idle3.12'
59-
rm '/usr/local/bin/idle3.13'
60-
rm '/usr/local/bin/pip3.12'
61-
rm '/usr/local/bin/pip3.13'
62-
rm '/usr/local/bin/pydoc3'
63-
rm '/usr/local/bin/pydoc3.12'
64-
rm '/usr/local/bin/pydoc3.13'
65-
rm '/usr/local/bin/python3'
66-
rm '/usr/local/bin/python3.12'
67-
rm '/usr/local/bin/python3.13'
68-
rm '/usr/local/bin/python3-config'
69-
rm '/usr/local/bin/python3.12-config'
70-
rm '/usr/local/bin/python3.13-config'
71-
brew install python3
55+
brew uninstall cmake
56+
brew untap local/pinned
57+
brew install cmake
7258
7359
- name: Configure formula
7460
env:
@@ -161,36 +147,28 @@ jobs:
161147
validate: true
162148
- run: echo "::remove-matcher owner=gcc-strip3::"
163149

164-
- name: Setup python
165-
id: python
166-
if: false
167-
uses: actions/setup-python@v5
150+
# TODO: remove this step
151+
- name: Debug upload gcda artifact
152+
if: always() && matrix.release != true
153+
uses: actions/upload-artifact@v4
168154
with:
169-
python-version: '3.11'
170-
171-
- name: Generate gcov report
172-
id: test_report
173-
# any except canceled or skipped
174-
# TODO: fix coverage, no .gcno files are being created
175-
# TODO: .gcno files are supposed to be created next to .o files
176-
if: false
177-
# if: >-
178-
# always() &&
179-
# matrix.release != true &&
180-
# (steps.test.outcome == 'success' || steps.test.outcome == 'failure')
155+
name: homebrew-gcda-${{ matrix.os_name }}-${{ matrix.os_version }}
156+
path: ${{ steps.test.outputs.buildpath }}/build/tests/CMakeFiles/test_sunshine.dir/__/src/audio.cpp.gcda
157+
158+
# TODO: remove this step
159+
- name: Debug homebrew buildpath
160+
if: always() && matrix.release != true
181161
run: |
182-
cp -rf ${{ steps.test.outputs.buildpath }}/build/ ./build/
183-
cd build
184-
ls -Ra
185-
186-
${{ steps.python.outputs.python-path }} -m pip install gcovr
187-
${{ steps.python.outputs.python-path }} -m gcovr . -r ../src \
188-
--exclude-noncode-lines \
189-
--exclude-throw-branches \
190-
--exclude-unreachable-branches \
191-
--verbose \
192-
--xml-pretty \
193-
-o coverage.xml
162+
# print the build path
163+
echo "Build path: ${{ steps.test.outputs.buildpath }}"
164+
echo "contents:"
165+
ls -Ra ${{ steps.test.outputs.buildpath }}
166+
167+
# print the test path
168+
echo "----"
169+
echo "Test path: ${{ steps.test.outputs.testpath }}"
170+
echo "contents:"
171+
ls -Ra ${{ steps.test.outputs.testpath }}
194172
195173
- name: Upload coverage artifact
196174
if: >-
@@ -202,8 +180,8 @@ jobs:
202180
with:
203181
name: coverage-Homebrew-${{ matrix.os_name }}-${{ matrix.os_version }}
204182
path: |
205-
build/coverage.xml
206-
${{ steps.test.outputs.testpath }}/test_results.xml
183+
${{ steps.test.outputs.testpath }}/coverage.xml
184+
${{ steps.test.outputs.testpath }}/tests/test_results.xml
207185
if-no-files-found: error
208186

209187
- name: Patch homebrew formula

.github/workflows/ci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,10 @@ jobs:
135135
matrix:
136136
include:
137137
- name: Linux-AppImage
138-
coverage: true
139138
- name: Homebrew-macos-14
140-
coverage: false
141139
- name: Homebrew-macos-15
142-
coverage: false
143140
- name: Homebrew-ubuntu-latest
144-
coverage: false
145141
- name: Windows-AMD64
146-
coverage: true
147142
steps:
148143
- name: Checkout
149144
uses: actions/checkout@v5
@@ -166,7 +161,6 @@ jobs:
166161

167162
- name: Upload coverage
168163
uses: codecov/codecov-action@v5
169-
if: matrix.coverage != false
170164
with:
171165
disable_search: true
172166
fail_ci_if_error: true

packaging/sunshine.rb

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,20 @@ class @PROJECT_NAME@ < Formula
3131
depends_on "graphviz" => :build
3232
depends_on "node" => :build
3333
depends_on "pkgconf" => :build
34+
depends_on "gcovr" => :test
3435
depends_on "curl"
3536
depends_on "miniupnpc"
3637
depends_on "openssl"
3738
depends_on "opus"
3839
depends_on "icu4c" => :recommended
3940

4041
on_macos do
42+
depends_on "llvm" => [:build, :test]
4143
depends_on xcode: ["15.3", :build]
4244
end
4345

4446
on_linux do
47+
depends_on "gcc@14" => [:build, :test]
4548
depends_on "avahi"
4649
depends_on "libayatana-appindicator"
4750
depends_on "libcap"
@@ -78,6 +81,13 @@ def install
7881
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
7982
ENV["COMMIT"] = "@GITHUB_COMMIT@"
8083

84+
# Ensure we use GCC 14 consistently on Linux
85+
if OS.linux?
86+
gcc14 = Formula["gcc@14"]
87+
ENV["CC"] = "#{gcc14.opt_bin}/gcc-14"
88+
ENV["CXX"] = "#{gcc14.opt_bin}/g++-14"
89+
end
90+
8191
args = %W[
8292
-DBUILD_WERROR=ON
8393
-DCMAKE_CXX_STANDARD=23
@@ -171,7 +181,35 @@ def caveats
171181
system bin/"sunshine", "--version"
172182

173183
# run the test suite
174-
system bin/"test_sunshine", "--gtest_color=yes", "--gtest_output=xml:test_results.xml"
175-
assert_path_exists testpath/"test_results.xml"
184+
system bin/"test_sunshine", "--gtest_color=yes", "--gtest_output=xml:tests/test_results.xml"
185+
assert_path_exists File.join(testpath, "tests", "test_results.xml")
186+
187+
# create gcovr report
188+
if ENV["HOMEBREW_BUILDPATH"]
189+
buildpath = ENV["HOMEBREW_BUILDPATH"]
190+
191+
# Change to the source directory for gcovr to work properly
192+
cd "#{buildpath}/build" do
193+
# Use the same GCC version that was used for compilation
194+
gcov_executable = "#{Formula["llvm"].opt_bin}/llvm-cov gcov"
195+
196+
if OS.linux?
197+
# Use GCC 14 to match what was used during compilation
198+
gcc14 = Formula["gcc@14"]
199+
gcov_executable = "#{gcc14.opt_bin}/gcov-14"
200+
end
201+
202+
system "gcovr", ".",
203+
"-r", "../src",
204+
"--gcov-executable", gcov_executable,
205+
"--exclude-noncode-lines",
206+
"--exclude-throw-branches",
207+
"--exclude-unreachable-branches",
208+
"--verbose", # TODO: remove verbose once working
209+
"--xml-pretty",
210+
"-o=#{testpath}/coverage.xml"
211+
end
212+
assert_path_exists File.join(testpath, "coverage.xml")
213+
end
176214
end
177215
end

0 commit comments

Comments
 (0)