From c5f44e4d0e3bbc45fb8ffed174dd76587bb5be02 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 1 Sep 2025 15:07:53 -0400 Subject: [PATCH 1/3] ci(homebrew): enable test coverage --- .github/workflows/ci-homebrew.yml | 56 ++----------------------------- .github/workflows/ci.yml | 10 +----- packaging/sunshine.rb | 40 ++++++++++++++++++++-- 3 files changed, 41 insertions(+), 65 deletions(-) diff --git a/.github/workflows/ci-homebrew.yml b/.github/workflows/ci-homebrew.yml index 06b6b4a608a..82ba121669f 100644 --- a/.github/workflows/ci-homebrew.yml +++ b/.github/workflows/ci-homebrew.yml @@ -51,27 +51,6 @@ jobs: - name: Checkout uses: actions/checkout@v6 - - name: Fix homebrew python - if: matrix.os_name == 'macos' && matrix.os_version == '13' - run: | - rm '/usr/local/bin/2to3' - rm '/usr/local/bin/2to3-3.12' - rm '/usr/local/bin/idle3' - rm '/usr/local/bin/idle3.12' - rm '/usr/local/bin/idle3.13' - rm '/usr/local/bin/pip3.12' - rm '/usr/local/bin/pip3.13' - rm '/usr/local/bin/pydoc3' - rm '/usr/local/bin/pydoc3.12' - rm '/usr/local/bin/pydoc3.13' - rm '/usr/local/bin/python3' - rm '/usr/local/bin/python3.12' - rm '/usr/local/bin/python3.13' - rm '/usr/local/bin/python3-config' - rm '/usr/local/bin/python3.12-config' - rm '/usr/local/bin/python3.13-config' - brew install python3 - - name: Configure formula env: INPUT_RELEASE_VERSION: ${{ inputs.release_version }} @@ -165,37 +144,6 @@ jobs: validate: true - run: echo "::remove-matcher owner=gcc-strip3::" - - name: Setup python - id: python - if: false - uses: actions/setup-python@v6 - with: - python-version: '3.11' - - - 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') - run: | - cp -rf ${{ steps.test.outputs.buildpath }}/build/ ./build/ - cd build - 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 - - name: Upload coverage artifact if: >- always() && @@ -206,8 +154,8 @@ jobs: with: name: coverage-Homebrew-${{ matrix.os_name }}-${{ matrix.os_version }} path: | - build/coverage.xml - ${{ steps.test.outputs.testpath }}/test_results.xml + ${{ steps.test.outputs.testpath }}/coverage.xml + ${{ steps.test.outputs.testpath }}/tests/test_results.xml if-no-files-found: error - name: Patch homebrew formula diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45e5fb0fb2a..329428b3e67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -152,28 +152,20 @@ jobs: matrix: include: - name: FreeBSD-14.3-amd64 - coverage: true pr: true - name: FreeBSD-14.3-aarch64 - coverage: true pr: false - name: Linux-AppImage - coverage: true pr: true - name: Homebrew-macos-14 - coverage: false pr: true - name: Homebrew-macos-15 - coverage: false pr: true - name: Homebrew-macos-26 - coverage: false pr: true - name: Homebrew-ubuntu-latest - coverage: false pr: true - name: Windows-AMD64 - coverage: true pr: true steps: - name: Should run @@ -208,7 +200,7 @@ jobs: verbose: true - name: Upload coverage - if: steps.should_run.outputs.SHOULD_RUN == 'true' && matrix.coverage != false + if: steps.should_run.outputs.SHOULD_RUN == 'true' uses: codecov/codecov-action@v5 with: disable_search: true diff --git a/packaging/sunshine.rb b/packaging/sunshine.rb index 159778a86b8..599c0be253c 100644 --- a/packaging/sunshine.rb +++ b/packaging/sunshine.rb @@ -1,6 +1,9 @@ require "language/node" class Sunshine < Formula + GCC_VERSION = "14".freeze + GCC_FORMULA = "gcc@#{GCC_VERSION}".freeze + # conflicts_with "sunshine", because: "sunshine and sunshine-beta cannot be installed at the same time" desc "@PROJECT_DESCRIPTION@" homepage "@PROJECT_HOMEPAGE_URL@" @@ -28,9 +31,11 @@ class Sunshine < Formula depends_on "cmake" => :build depends_on "doxygen" => :build + depends_on GCC_FORMULA => [:build, :test] depends_on "graphviz" => :build depends_on "node" => :build depends_on "pkgconf" => :build + depends_on "gcovr" => :test depends_on "curl" depends_on "miniupnpc" depends_on "openssl" @@ -38,6 +43,10 @@ class Sunshine < Formula depends_on "boost" => :recommended depends_on "icu4c" => :recommended + on_macos do + depends_on "llvm" => [:build, :test] + end + on_linux do depends_on "avahi" depends_on "gnu-which" @@ -76,6 +85,11 @@ def install ENV["BUILD_VERSION"] = "@BUILD_VERSION@" ENV["COMMIT"] = "@GITHUB_COMMIT@" + # Use GCC because gcov from llvm cannot handle our paths + gcc_path = Formula[GCC_FORMULA] + ENV["CC"] = "#{gcc_path.opt_bin}/gcc-#{GCC_VERSION}" + ENV["CXX"] = "#{gcc_path.opt_bin}/g++-#{GCC_VERSION}" + args = %W[ -DBUILD_WERROR=ON -DCMAKE_CXX_STANDARD=23 @@ -169,7 +183,29 @@ def caveats system bin/"sunshine", "--version" # run the test suite - system bin/"test_sunshine", "--gtest_color=yes", "--gtest_output=xml:test_results.xml" - assert_path_exists testpath/"test_results.xml" + system bin/"test_sunshine", "--gtest_color=yes", "--gtest_output=xml:tests/test_results.xml" + assert_path_exists File.join(testpath, "tests", "test_results.xml") + + # create gcovr report + buildpath = ENV.fetch("HOMEBREW_BUILDPATH", "") + unless buildpath.empty? + # Change to the source directory for gcovr to work properly + cd "#{buildpath}/build" do + # Use GCC version to match what was used during compilation + gcc_path = Formula[GCC_FORMULA] + gcov_executable = "#{gcc_path.opt_bin}/gcov-#{GCC_VERSION}" + + system "gcovr", ".", + "-r", "../src", + "--gcov-executable", gcov_executable, + "--exclude-noncode-lines", + "--exclude-throw-branches", + "--exclude-unreachable-branches", + "--verbose", # TODO: remove verbose once working for macOS + "--xml-pretty", + "-o=#{testpath}/coverage.xml" + end + assert_path_exists File.join(testpath, "coverage.xml") + end end end From 9ee6007f1788eeab2f342db009cc7e978370d30f Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 26 Nov 2025 09:55:31 -0500 Subject: [PATCH 2/3] Move GCC dependency and gcov logic to Linux only GCC dependency and related environment setup are now only applied on Linux, aligning with platform-specific requirements. The gcovr coverage generation and assertion are also restricted to Linux. --- packaging/sunshine.rb | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/packaging/sunshine.rb b/packaging/sunshine.rb index 599c0be253c..6cc240fb25f 100644 --- a/packaging/sunshine.rb +++ b/packaging/sunshine.rb @@ -31,7 +31,6 @@ class Sunshine < Formula depends_on "cmake" => :build depends_on "doxygen" => :build - depends_on GCC_FORMULA => [:build, :test] depends_on "graphviz" => :build depends_on "node" => :build depends_on "pkgconf" => :build @@ -48,6 +47,7 @@ class Sunshine < Formula end on_linux do + depends_on GCC_FORMULA => [:build, :test] depends_on "avahi" depends_on "gnu-which" depends_on "libayatana-appindicator" @@ -85,10 +85,12 @@ def install ENV["BUILD_VERSION"] = "@BUILD_VERSION@" ENV["COMMIT"] = "@GITHUB_COMMIT@" - # Use GCC because gcov from llvm cannot handle our paths - gcc_path = Formula[GCC_FORMULA] - ENV["CC"] = "#{gcc_path.opt_bin}/gcc-#{GCC_VERSION}" - ENV["CXX"] = "#{gcc_path.opt_bin}/g++-#{GCC_VERSION}" + if OS.linux? + # Use GCC because gcov from llvm cannot handle our paths + gcc_path = Formula[GCC_FORMULA] + ENV["CC"] = "#{gcc_path.opt_bin}/gcc-#{GCC_VERSION}" + ENV["CXX"] = "#{gcc_path.opt_bin}/g++-#{GCC_VERSION}" + end args = %W[ -DBUILD_WERROR=ON @@ -192,20 +194,22 @@ def caveats # Change to the source directory for gcovr to work properly cd "#{buildpath}/build" do # Use GCC version to match what was used during compilation - gcc_path = Formula[GCC_FORMULA] - gcov_executable = "#{gcc_path.opt_bin}/gcov-#{GCC_VERSION}" - - system "gcovr", ".", - "-r", "../src", - "--gcov-executable", gcov_executable, - "--exclude-noncode-lines", - "--exclude-throw-branches", - "--exclude-unreachable-branches", - "--verbose", # TODO: remove verbose once working for macOS - "--xml-pretty", - "-o=#{testpath}/coverage.xml" + if OS.linux? + gcc_path = Formula[GCC_FORMULA] + gcov_executable = "#{gcc_path.opt_bin}/gcov-#{GCC_VERSION}" + + system "gcovr", ".", + "-r", "../src", + "--gcov-executable", gcov_executable, + "--exclude-noncode-lines", + "--exclude-throw-branches", + "--exclude-unreachable-branches", + "--xml-pretty", + "-o=#{testpath}/coverage.xml" + + assert_path_exists File.join(testpath, "coverage.xml") + end end - assert_path_exists File.join(testpath, "coverage.xml") end end end From 52629c6b395bf0869018a3807e2fab4dd6e35986 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 30 Nov 2025 20:17:02 -0500 Subject: [PATCH 3/3] Enable selective coverage upload in CI matrix Adds a 'coverage' flag to each job in the CI matrix and updates the upload step to only run when coverage is enabled for that job. This allows more granular control over which environments generate and upload coverage reports. --- .github/workflows/ci.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 329428b3e67..ee665f03f00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -152,20 +152,28 @@ jobs: matrix: include: - name: FreeBSD-14.3-amd64 + coverage: true pr: true - name: FreeBSD-14.3-aarch64 + coverage: true pr: false - name: Linux-AppImage + coverage: true pr: true - name: Homebrew-macos-14 + coverage: false pr: true - name: Homebrew-macos-15 + coverage: false pr: true - name: Homebrew-macos-26 + coverage: false pr: true - name: Homebrew-ubuntu-latest + coverage: true pr: true - name: Windows-AMD64 + coverage: true pr: true steps: - name: Should run @@ -200,7 +208,9 @@ jobs: verbose: true - name: Upload coverage - if: steps.should_run.outputs.SHOULD_RUN == 'true' + if: | + steps.should_run.outputs.SHOULD_RUN == 'true' && + matrix.coverage != false uses: codecov/codecov-action@v5 with: disable_search: true