-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable coverage test for github action
Signed-off-by: LHT129 <[email protected]>
- Loading branch information
Showing
5 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Coverage | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
coverage: | ||
name: Test Coverage | ||
runs-on: ubuntu-latest | ||
container: | ||
image: vsaglib/vsag:ubuntu | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.10' | ||
- name: Install | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install lcov_cobertura | ||
apt install -y curl jq | ||
- name: Load Cache | ||
uses: actions/[email protected] | ||
with: | ||
path: ./build/ | ||
key: build-${{ hashFiles('./CMakeLists.txt') }}-${{ hashFiles('./.circleci/fresh_ci_cache.commit') }} | ||
- name: Compile | ||
run: make cov | ||
- name: Run Test | ||
run: | | ||
./build/mockimpl/tests_mockimpl -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD} | ||
- name: Collect Coverage Info | ||
run: bash scripts/collect_cpp_coverage.sh | ||
- name: Generate XML | ||
run: lcov_cobertura coverage.info --output coverage.xml | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v5 | ||
with: | ||
fail_ci_if_error: true | ||
files: coverage.xml | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
verbose: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
line_coverage=`lcov --summary coverage/coverage.info | grep "lines......" | awk '/lines/ { print $2 }' | cut -d '%' -f 1` | ||
line_coverage=$(printf "%.0f" $line_coverage) | ||
if [ "$line_coverage" -gt 84 ]; then | ||
echo "line coverage is ${line_coverage}, more than 84" | ||
exit 0; | ||
else | ||
echo "line coverage is ${line_coverage}, less than 84" | ||
exit 1; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
ROOT_DIR="${SCRIPTS_DIR}/../" | ||
|
||
COVERAGE_DIR="${ROOT_DIR}/coverage" | ||
if [ -d "${COVERAGE_DIR}" ]; then | ||
rm -rf "${COVERAGE_DIR:?}"/* | ||
else | ||
mkdir -p "${COVERAGE_DIR}" | ||
fi | ||
|
||
lcov --gcov-tool ${SCRIPTS_DIR}/gcov_for_clang.sh \ | ||
--rc branch_coverage=1 \ | ||
--rc geninfo_unexecuted_blocks=1 \ | ||
--include "*/vsag/include/*" \ | ||
--include "*/vsag/src/*" \ | ||
--exclude "*/vsag/include/vsag/expected.hpp*" \ | ||
--exclude "*_test.cpp" \ | ||
--capture \ | ||
--directory . \ | ||
--output-file "${COVERAGE_DIR}/coverage_ut.info" | ||
|
||
pushd "${COVERAGE_DIR}" | ||
coverages=$(ls coverage_*.info) | ||
if [ ! "$coverages" ];then | ||
echo "no coverage file" | ||
exit 0 | ||
fi | ||
lcov_command="lcov" | ||
for coverage in $coverages; do | ||
echo "$coverage" | ||
lcov_command="$lcov_command -a $coverage" | ||
done | ||
$lcov_command -o coverage.info \ | ||
--rc branch_coverage=1 \ | ||
--ignore-errors inconsistent,inconsistent \ | ||
--ignore-errors corrupt,corrupt | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
exec gcov "$@" | ||
|