@@ -53,23 +53,43 @@ jobs:
5353 uses : actions/download-artifact@v4
5454 with :
5555 path : .
56- - name : List coverage files
56+ - name : Combine coverage files
5757 run : |
58- echo "Looking for coverage files in downloaded artifacts..."
59- find . -name "*.info" -type f | head -20
60- echo "---"
61- ls -la coverage-lcov-*/ || echo "No coverage directories found"
62- - name : Show coverage files content
63- run : |
64- for dir in coverage-lcov-*/; do
65- if [ -d "$dir" ]; then
66- echo "==== Contents of $dir ===="
67- ls -la "$dir"
68- for f in "$dir"*.info; do
69- if [ -f "$f" ]; then
70- echo "==== $f ==== "
71- cat "$f"
58+ combineCoverage() {
59+ local artifact_dir=$1
60+ local repo_dir=$2
61+ local package_name=$(basename "$artifact_dir")
62+ escapedPath="$(echo $package_name | sed 's/\//\\\//g')"
63+
64+ if [[ -d "$artifact_dir" ]]; then
65+ # Find the lcov.info file in the artifact directory
66+ for lcov_file in "$artifact_dir"/*.info; do
67+ if [[ -f "$lcov_file" ]]; then
68+ echo "Combining coverage from $package_name"
69+ # combine line coverage info from package tests to a common file
70+ sed "s/^SF:lib/SF:$escapedPath\/lib/g" "$lcov_file" >> "$repo_dir/lcov.info "
71+ break
7272 fi
7373 done
7474 fi
75- done || echo "No coverage files to show"
75+ }
76+
77+ # Initialize the combined coverage file
78+ touch lcov.info
79+
80+ # Combine coverage from all downloaded artifacts
81+ for artifact_dir in coverage-lcov-*/; do
82+ if [[ -d "$artifact_dir" ]]; then
83+ combineCoverage "$artifact_dir" "."
84+ fi
85+ done
86+
87+ echo "Combined coverage file created:"
88+
89+ - name : Upload coverage to Codecov
90+ uses : codecov/codecov-action@v5
91+ with :
92+ files : ./lcov.info
93+ disable_search : true
94+ env :
95+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
0 commit comments