Skip to content

Commit 866ba16

Browse files
ci(homebrew): enable test coverage
1 parent 7d887bc commit 866ba16

File tree

3 files changed

+41
-65
lines changed

3 files changed

+41
-65
lines changed

.github/workflows/ci-homebrew.yml

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,6 @@ jobs:
5151
- name: Checkout
5252
uses: actions/checkout@v5
5353

54-
- name: Fix homebrew python
55-
if: matrix.os_name == 'macos' && matrix.os_version == '13'
56-
run: |
57-
rm '/usr/local/bin/2to3'
58-
rm '/usr/local/bin/2to3-3.12'
59-
rm '/usr/local/bin/idle3'
60-
rm '/usr/local/bin/idle3.12'
61-
rm '/usr/local/bin/idle3.13'
62-
rm '/usr/local/bin/pip3.12'
63-
rm '/usr/local/bin/pip3.13'
64-
rm '/usr/local/bin/pydoc3'
65-
rm '/usr/local/bin/pydoc3.12'
66-
rm '/usr/local/bin/pydoc3.13'
67-
rm '/usr/local/bin/python3'
68-
rm '/usr/local/bin/python3.12'
69-
rm '/usr/local/bin/python3.13'
70-
rm '/usr/local/bin/python3-config'
71-
rm '/usr/local/bin/python3.12-config'
72-
rm '/usr/local/bin/python3.13-config'
73-
brew install python3
74-
7554
- name: Configure formula
7655
env:
7756
INPUT_RELEASE_VERSION: ${{ inputs.release_version }}
@@ -165,37 +144,6 @@ jobs:
165144
validate: true
166145
- run: echo "::remove-matcher owner=gcc-strip3::"
167146

168-
- name: Setup python
169-
id: python
170-
if: false
171-
uses: actions/setup-python@v6
172-
with:
173-
python-version: '3.11'
174-
175-
- name: Generate gcov report
176-
id: test_report
177-
# any except canceled or skipped
178-
# TODO: fix coverage, no .gcno files are being created
179-
# TODO: .gcno files are supposed to be created next to .o files
180-
if: false
181-
# if: >-
182-
# always() &&
183-
# matrix.release != true &&
184-
# (steps.test.outcome == 'success' || steps.test.outcome == 'failure')
185-
run: |
186-
cp -rf ${{ steps.test.outputs.buildpath }}/build/ ./build/
187-
cd build
188-
ls -Ra
189-
190-
${{ steps.python.outputs.python-path }} -m pip install gcovr
191-
${{ steps.python.outputs.python-path }} -m gcovr . -r ../src \
192-
--exclude-noncode-lines \
193-
--exclude-throw-branches \
194-
--exclude-unreachable-branches \
195-
--verbose \
196-
--xml-pretty \
197-
-o coverage.xml
198-
199147
- name: Upload coverage artifact
200148
if: >-
201149
always() &&
@@ -206,8 +154,8 @@ jobs:
206154
with:
207155
name: coverage-Homebrew-${{ matrix.os_name }}-${{ matrix.os_version }}
208156
path: |
209-
build/coverage.xml
210-
${{ steps.test.outputs.testpath }}/test_results.xml
157+
${{ steps.test.outputs.testpath }}/coverage.xml
158+
${{ steps.test.outputs.testpath }}/tests/test_results.xml
211159
if-no-files-found: error
212160

213161
- name: Patch homebrew formula

.github/workflows/ci.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,28 +152,20 @@ jobs:
152152
matrix:
153153
include:
154154
- name: FreeBSD-14.3-amd64
155-
coverage: true
156155
pr: true
157156
- name: FreeBSD-14.3-aarch64
158-
coverage: true
159157
pr: false
160158
- name: Linux-AppImage
161-
coverage: true
162159
pr: true
163160
- name: Homebrew-macos-14
164-
coverage: false
165161
pr: true
166162
- name: Homebrew-macos-15
167-
coverage: false
168163
pr: true
169164
- name: Homebrew-macos-26
170-
coverage: false
171165
pr: true
172166
- name: Homebrew-ubuntu-latest
173-
coverage: false
174167
pr: true
175168
- name: Windows-AMD64
176-
coverage: true
177169
pr: true
178170
steps:
179171
- name: Should run
@@ -208,7 +200,7 @@ jobs:
208200
verbose: true
209201

210202
- name: Upload coverage
211-
if: steps.should_run.outputs.SHOULD_RUN == 'true' && matrix.coverage != false
203+
if: steps.should_run.outputs.SHOULD_RUN == 'true'
212204
uses: codecov/codecov-action@v5
213205
with:
214206
disable_search: true

packaging/sunshine.rb

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
require "language/node"
22

33
class Sunshine < Formula
4+
GCC_VERSION = "14".freeze
5+
GCC_FORMULA = "gcc@#{GCC_VERSION}".freeze
6+
47
# conflicts_with "sunshine", because: "sunshine and sunshine-beta cannot be installed at the same time"
58
desc "@PROJECT_DESCRIPTION@"
69
homepage "@PROJECT_HOMEPAGE_URL@"
@@ -28,16 +31,22 @@ class Sunshine < Formula
2831

2932
depends_on "cmake" => :build
3033
depends_on "doxygen" => :build
34+
depends_on GCC_FORMULA => [:build, :test]
3135
depends_on "graphviz" => :build
3236
depends_on "node" => :build
3337
depends_on "pkgconf" => :build
38+
depends_on "gcovr" => :test
3439
depends_on "curl"
3540
depends_on "miniupnpc"
3641
depends_on "openssl"
3742
depends_on "opus"
3843
depends_on "boost" => :recommended
3944
depends_on "icu4c" => :recommended
4045

46+
on_macos do
47+
depends_on "llvm" => [:build, :test]
48+
end
49+
4150
on_linux do
4251
depends_on "avahi"
4352
depends_on "gnu-which"
@@ -76,6 +85,11 @@ def install
7685
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
7786
ENV["COMMIT"] = "@GITHUB_COMMIT@"
7887

88+
# Use GCC because gcov from llvm cannot handle our paths
89+
gcc_path = Formula[GCC_FORMULA]
90+
ENV["CC"] = "#{gcc_path.opt_bin}/gcc-#{GCC_VERSION}"
91+
ENV["CXX"] = "#{gcc_path.opt_bin}/g++-#{GCC_VERSION}"
92+
7993
args = %W[
8094
-DBUILD_WERROR=ON
8195
-DCMAKE_CXX_STANDARD=23
@@ -169,7 +183,29 @@ def caveats
169183
system bin/"sunshine", "--version"
170184

171185
# run the test suite
172-
system bin/"test_sunshine", "--gtest_color=yes", "--gtest_output=xml:test_results.xml"
173-
assert_path_exists testpath/"test_results.xml"
186+
system bin/"test_sunshine", "--gtest_color=yes", "--gtest_output=xml:tests/test_results.xml"
187+
assert_path_exists File.join(testpath, "tests", "test_results.xml")
188+
189+
# create gcovr report
190+
buildpath = ENV.fetch("HOMEBREW_BUILDPATH", "")
191+
unless buildpath.empty?
192+
# Change to the source directory for gcovr to work properly
193+
cd "#{buildpath}/build" do
194+
# Use GCC version to match what was used during compilation
195+
gcc_path = Formula[GCC_FORMULA]
196+
gcov_executable = "#{gcc_path.opt_bin}/gcov-#{GCC_VERSION}"
197+
198+
system "gcovr", ".",
199+
"-r", "../src",
200+
"--gcov-executable", gcov_executable,
201+
"--exclude-noncode-lines",
202+
"--exclude-throw-branches",
203+
"--exclude-unreachable-branches",
204+
"--verbose", # TODO: remove verbose once working for macOS
205+
"--xml-pretty",
206+
"-o=#{testpath}/coverage.xml"
207+
end
208+
assert_path_exists File.join(testpath, "coverage.xml")
209+
end
174210
end
175211
end

0 commit comments

Comments
 (0)