Skip to content

Commit

Permalink
Fix CPP checks for CI (nv-morpheus#147)
Browse files Browse the repository at this point in the history
Fixes the determination of the changed files list.
Adds IWYU to CI.

Fixes nv-morpheus#148

Authors:
  - David Gardner (https://github.com/dagardner-nv)

Approvers:
  - Michael Demoret (https://github.com/mdemoret-nv)

URL: nv-morpheus#147
  • Loading branch information
dagardner-nv authored Jul 25, 2022
1 parent f4da153 commit e5dd099
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ci/conda/environments/clang_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ channels:
- conda-forge
dependencies:
- clang=12
- clang-tools=12
- clangdev=12
- clangxx=12
- libclang=12
- libclang-cpp=12
- llvmdev=12
1 change: 1 addition & 0 deletions ci/conda/environments/dev_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies:
- numactl-libs-cos7-x86_64
- numpy=1.21.2
- nvcc_linux-64=11.4
- pip
- pkg-config=0.29
- pybind11-stubgen=0.10
- python=3.8
Expand Down
4 changes: 2 additions & 2 deletions ci/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export PY_CFG="${PY_ROOT}/setup.cfg"
export PY_DIRS="${PY_ROOT} ci/scripts"

# Determine the commits to compare against. If running in CI, these will be set. Otherwise, diff with main
export BASE_SHA=${CI_MERGE_REQUEST_DIFF_BASE_SHA:-${BASE_SHA:-main}}
export COMMIT_SHA=${CI_COMMIT_SHA:-${COMMIT_SHA:-HEAD}}
export BASE_SHA=${CHANGE_TARGET:-${BASE_SHA:-main}}
export COMMIT_SHA=${GIT_COMMIT:-${COMMIT_SHA:-HEAD}}

export CPP_FILE_REGEX='^(\.\/)?(src|include|tests|benchmarks|python)\/.*\.(cc|cpp|h|hpp)$'
export PYTHON_FILE_REGEX='^(\.\/)?(?!\.|build).*\.(py|pyx|pxd)$'
Expand Down
2 changes: 1 addition & 1 deletion ci/scripts/cpp_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CLANG_TIDY_RETVAL=0
CLANG_FORMAT_RETVAL=0
IWYU_RETVAL=0

# Get the list of modified files inside the trtlab/srf folder
# Get the list of modified files inside the srf repo
get_modified_files ${CPP_FILE_REGEX} SRF_MODIFIED_FILES

# If there are any files, then run clang tidy
Expand Down
22 changes: 21 additions & 1 deletion ci/scripts/jenkins/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,38 @@
set -e

source ${WORKSPACE}/ci/scripts/jenkins/common.sh
export IWYU_DIR="${WORKSPACE_TMP}/iwyu"

rm -rf ${SRF_ROOT}/.cache/ ${SRF_ROOT}/build/
rm -rf ${SRF_ROOT}/.cache/ ${SRF_ROOT}/build/ ${IWYU_DIR}

fetch_base_branch

gpuci_logger "Creating conda env"
mamba env create -n srf -q --file ${CONDA_ENV_YML}

gpuci_logger "Installing Clang"
mamba env update -q -n srf --file ${SRF_ROOT}/ci/conda/environments/clang_env.yml

conda deactivate
conda activate srf

show_conda_info

gpuci_logger "Installing IWYU"
git clone https://github.com/include-what-you-use/include-what-you-use.git ${IWYU_DIR}
pushd ${IWYU_DIR}
git checkout clang_12
cmake -G Ninja \
-DCMAKE_PREFIX_PATH=$(llvm-config --cmakedir) \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX} \
.

cmake --build . --parallel ${PARALLEL_LEVEL} --target install

popd

gpuci_logger "Configuring CMake"
cmake -B build -G Ninja ${CMAKE_BUILD_ALL_FEATURES} .

Expand Down

0 comments on commit e5dd099

Please sign in to comment.