build(homebrew): Run test_sunshine and coverage only for main repo (#4491)

This commit is contained in:
David Lane 2025-12-09 19:05:19 -05:00 • committed by GitHub
commit eb3afd43df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,7 @@ require "language/node"
class Sunshine < Formula class Sunshine < Formula
GCC_VERSION = "14".freeze GCC_VERSION = "14".freeze
GCC_FORMULA = "gcc@#{GCC_VERSION}".freeze GCC_FORMULA = "gcc@#{GCC_VERSION}".freeze
IS_UPSTREAM_REPO = ENV.fetch("GITHUB_REPOSITORY", "") == "LizardByte/Sunshine"
# conflicts_with "sunshine", because: "sunshine and sunshine-beta cannot be installed at the same time" # conflicts_with "sunshine", because: "sunshine and sunshine-beta cannot be installed at the same time"
desc "@PROJECT_DESCRIPTION@" desc "@PROJECT_DESCRIPTION@"
@ -105,6 +106,14 @@ class Sunshine < Formula
-DSUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support' -DSUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support'
] ]
if IS_UPSTREAM_REPO
args << "-DBUILD_TESTS=ON"
ohai "Building tests: enabled"
else
args << "-DBUILD_TESTS=OFF"
ohai "Building tests: disabled"
end
if build.with? "docs" if build.with? "docs"
ohai "Building docs: enabled" ohai "Building docs: enabled"
args << "-DBUILD_DOCS=ON" args << "-DBUILD_DOCS=ON"
@ -141,7 +150,8 @@ class Sunshine < Formula
system "make", "-C", "build" system "make", "-C", "build"
system "make", "-C", "build", "install" system "make", "-C", "build", "install"
bin.install "build/tests/test_sunshine"
bin.install "build/tests/test_sunshine" if IS_UPSTREAM_REPO
# codesign the binary on intel macs # codesign the binary on intel macs
system "codesign", "-s", "-", "--force", "--deep", bin/"sunshine" if OS.mac? && Hardware::CPU.intel? system "codesign", "-s", "-", "--force", "--deep", bin/"sunshine" if OS.mac? && Hardware::CPU.intel?
@ -184,6 +194,7 @@ class Sunshine < Formula
# test that the binary runs at all # test that the binary runs at all
system bin/"sunshine", "--version" system bin/"sunshine", "--version"
if IS_UPSTREAM_REPO
# run the test suite # run the test suite
system bin/"test_sunshine", "--gtest_color=yes", "--gtest_output=xml:tests/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") assert_path_exists File.join(testpath, "tests", "test_results.xml")
@ -213,3 +224,4 @@ class Sunshine < Formula
end end
end end
end end
end