From 66feb295da8f34df4b12b0d80e158f0afc1a6fd8 Mon Sep 17 00:00:00 2001 From: congqixia Date: Thu, 19 Jan 2023 13:43:44 +0800 Subject: [PATCH] Use AdressSantizer build when cpp files changed (#21809) Signed-off-by: Congqi Xia --- .github/workflows/main.yaml | 22 +++++++++++++++++++++- Makefile | 2 +- scripts/core_build.sh | 12 ++++++++---- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c748e6d86a..865e5180ac 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -46,6 +46,26 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: 'Check Changed files' + id: changed-files-cpp + uses: tj-actions/changed-files@v35 + with: + since_last_remote_commit: 'true' + files: | + **/*.cpp + **/*.cc + **/*.c + **/*.h + **/*.hpp + **/*.CMakeLists.txt + **/conanfiles.* + - name: 'Setup Use USE_ASAN' + if: steps.changed-files-cpp.outputs.any_changed == 'true' + run: | + echo "useasan=true" >> $GITHUB_ENV + echo "Setup USE_ASAN to true since cpp file(s) changed" - name: 'Generate CCache Hash' env: CORE_HASH: ${{ hashFiles( 'internal/core/**/*.cpp', 'internal/core/**/*.cc', 'internal/core/**/*.c', 'internal/core/**/*.h', 'internal/core/**/*.hpp', 'internal/core/**/CMakeLists.txt') }} @@ -76,7 +96,7 @@ jobs: docker-compose up -d pulsar etcd minio - name: Build and UnitTest run: | - ./build/builder.sh /bin/bash -c "make ci-ut" + ./build/builder.sh /bin/bash -c "make USE_ASAN={{env.useasan}} ci-ut" - name: Get the status & restart count for containers when ut failed if: ${{ failure() }} run: | diff --git a/Makefile b/Makefile index 682cf34976..c1dd1b87f9 100644 --- a/Makefile +++ b/Makefile @@ -150,7 +150,7 @@ build-cpp-with-unittest: download-milvus-proto build-cpp-with-coverage: download-milvus-proto @echo "Building Milvus cpp library with coverage and unittest ..." - @(env bash $(PWD)/scripts/core_build.sh -t ${mode} -u -a -c -f "$(CUSTOM_THIRDPARTY_PATH)" -n ${disk_index}) + @(env bash $(PWD)/scripts/core_build.sh -t ${mode} -u -a ${USE_ASAN} -c -f "$(CUSTOM_THIRDPARTY_PATH)" -n ${disk_index}) # Run the tests. diff --git a/scripts/core_build.sh b/scripts/core_build.sh index 74372caacd..092f5b57ce 100755 --- a/scripts/core_build.sh +++ b/scripts/core_build.sh @@ -59,7 +59,7 @@ EMBEDDED_MILVUS="OFF" BUILD_DISK_ANN="OFF" USE_ASAN="OFF" -while getopts "p:d:t:s:f:n:ulrcghzmeba" arg; do +while getopts "p:d:t:s:f:n:a:ulrcghzmeb" arg; do case $arg in f) CUSTOM_THIRDPARTY_PATH=$OPTARG @@ -107,8 +107,12 @@ while getopts "p:d:t:s:f:n:ulrcghzmeba" arg; do BUILD_DISK_ANN=$OPTARG ;; a) - USE_ASAN="ON" - BUILD_TYPE=Debug + ENV_VAL=$OPTARG + if [[ ${ENV_VAL} == 'true' ]]; then + echo "Set USE_ASAN to ON" + USE_ASAN="ON" + BUILD_TYPE=Debug + fi ;; h) # help echo " @@ -127,7 +131,7 @@ parameter: -e: build without prometheus(default: OFF) -s: build with CUDA arch(default:DEFAULT), for example '-gencode=compute_61,code=sm_61;-gencode=compute_75,code=sm_75' -b: build embedded milvus(default: OFF) --a: build milvus with AddressSanitizer +-a: build milvus with AddressSanitizer(default: false) -h: help usage: