Skip to content

Commit

Permalink
introduce github action for ci test asan
Browse files Browse the repository at this point in the history
- test asan on github action
- format check on github action
- other test on circleci

Signed-off-by: LHT129 <[email protected]>
  • Loading branch information
LHT129 committed Dec 5, 2024
1 parent 2895eea commit 3912bf6
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 9 deletions.
2 changes: 0 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
resource_class: medium+
steps:
- checkout
- run: ./scripts/check_format.sh
- restore_cache:
keys:
- fork-cache-{{ checksum "CMakeLists.txt" }}-{{ checksum ".circleci/fresh_ci_cache.commit" }}
Expand All @@ -40,7 +39,6 @@ jobs:
resource_class: medium+
steps:
- checkout
- run: ./scripts/check_format.sh
- restore_cache:
keys:
- main-ccache-{{ checksum "CMakeLists.txt" }}-{{ checksum ".circleci/fresh_ci_cache.commit" }}
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/asan_build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Asan Build & Test Parallel

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
clang-format-check:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Clang format
run: sudo apt-get install clang-format
- name: Run Clang format check
run: ./scripts/check_format.sh

build:
name: Asan Build
runs-on: ubuntu-latest
container:
image: vsaglib/vsag:ubuntu
steps:
- uses: actions/checkout@v4
- name: Load Cache
uses: actions/[email protected]
with:
path: ./build/
key: build-${{ hashFiles('./CMakeLists.txt') }}-${{ hashFiles('./.circleci/fresh_ci_cache.commit') }}
- name: Make Asan
run: make asan
- name: Save Cache
uses: actions/[email protected]
with:
path: ./build/
key: build-${{ hashFiles('./CMakeLists.txt') }}-${{ hashFiles('./.circleci/fresh_ci_cache.commit') }}
- name: Test Asan Parallel
run: make test_asan_parallel
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ test_cov: cov ## Build and run unit tests with code coverage enabled.
./build/tests/unittests -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}
./build/tests/functests -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}
./build/mockimpl/tests_mockimpl -d yes ${UT_FILTER} --allow-running-no-tests ${UT_SHARD}
bash scripts/aci/collect_cpp_coverage.sh
bash scripts/collect_cpp_coverage.sh
genhtml --output-directory testresult/coverage/html testresult/coverage/coverage.info --ignore-errors inconsistent,inconsistent

.PHONY: clean
Expand Down
46 changes: 46 additions & 0 deletions scripts/collect_cpp_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

set -e
set -x

SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR="${SCRIPTS_DIR}/../../"

COVERAGE_DIR="${ROOT_DIR}/testresult/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 \
--parallel 8 \
--include "*/vsag/include/*" \
--include "*/vsag/src/*" \
--exclude "*/vsag/include/vsag/expected.hpp*" \
--exclude "*_test.cpp" \
--capture \
--ignore-errors mismatch,mismatch \
--ignore-errors unused,unused \
--ignore-errors inconsistent,inconsistent \
--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
3 changes: 3 additions & 0 deletions scripts/gcov_for_clang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
exec llvm-cov gcov "$@"

12 changes: 7 additions & 5 deletions src/simd/simd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ GetInnerProductDistanceFunc(size_t dim) {

DistanceFunc
GetINT8InnerProductDistanceFunc(size_t dim) {
if (SimdStatus::SupportAVX512()) {
#ifdef ENABLE_AVX512
if (dim > 32) {
return vsag::INT8InnerProduct512ResidualsAVX512Distance;
} else if (dim > 16) {
return vsag::INT8InnerProduct256ResidualsAVX512Distance;
}
if (dim > 32) {
return vsag::INT8InnerProduct512ResidualsAVX512Distance;
} else if (dim > 16) {
return vsag::INT8InnerProduct256ResidualsAVX512Distance;
}
#endif
}
return vsag::INT8InnerProductDistance;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_hnsw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ TEST_CASE("hnsw serialize", "[ft][hnsw]") {
int ef_construction = 200;
int ef_search = 200;
auto metric_type = GENERATE("cosine", "l2");
auto use_static = GENERATE(true, false);
auto use_static = GENERATE(false);
// Initing index
nlohmann::json hnsw_parameters{{"max_degree", max_degree},
{"ef_construction", ef_construction},
Expand Down

0 comments on commit 3912bf6

Please sign in to comment.