ci(homebrew): enable test coverage on Linux (#3842)
This commit is contained in:
parent
a0a97138e0
commit
4d2391c9a0
3 changed files with 48 additions and 58 deletions
56
.github/workflows/ci-homebrew.yml
vendored
56
.github/workflows/ci-homebrew.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
|
@ -170,7 +170,7 @@ jobs:
|
|||
coverage: false
|
||||
pr: true
|
||||
- name: Homebrew-ubuntu-latest
|
||||
coverage: false
|
||||
coverage: true
|
||||
pr: true
|
||||
- name: Windows-AMD64
|
||||
coverage: true
|
||||
|
|
@ -208,7 +208,9 @@ 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' &&
|
||||
matrix.coverage != false
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
disable_search: true
|
||||
|
|
|
|||
|
|
@ -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@"
|
||||
|
|
@ -31,6 +34,7 @@ class Sunshine < Formula
|
|||
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,7 +42,12 @@ 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 GCC_FORMULA => [:build, :test]
|
||||
depends_on "avahi"
|
||||
depends_on "gnu-which"
|
||||
depends_on "libayatana-appindicator"
|
||||
|
|
@ -76,6 +85,13 @@ class Sunshine < Formula
|
|||
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
|
||||
ENV["COMMIT"] = "@GITHUB_COMMIT@"
|
||||
|
||||
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
|
||||
-DCMAKE_CXX_STANDARD=23
|
||||
|
|
@ -169,7 +185,31 @@ class Sunshine < Formula
|
|||
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
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue