Skip to content

Commit

Permalink
Run clang-tidy in CUDA 9.2 container
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Feb 5, 2019
1 parent b643f11 commit 8e8287e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 21 deletions.
19 changes: 4 additions & 15 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,12 @@ def buildClangTidyJob() {
node(nodeReq) {
unstash name: 'srcs'
echo "Running clang-tidy job..."
// Invoke command inside docker
// Install Google Test and Python yaml
dockerTarget = "gpu"
dockerArgs = "--build-arg CUDA_VERSION=9.2"
sh """
pip3 install pyyaml
rm -rf gtest googletest-release-1.7.0
wget -nc https://github.com/google/googletest/archive/release-1.7.0.zip
jar -xf release-1.7.0.zip
mv googletest-release-1.7.0 gtest && cd gtest
cmake . && make
mkdir lib && mv libgtest.a lib
cd ..
rm -rf release-1.7.0.zip*
"""
// Run clang-tidy job
sh """#!/bin/bash
source tests/ci_build/setup_cuda_path.sh
python3 tests/ci_build/tidy.py --gtest-path=${WORKSPACE}/gtest
${dockerRun} ${dockerTarget} ${dockerArgs} tests/ci_build/clang_tidy.sh
"""
}
}
Expand Down
45 changes: 45 additions & 0 deletions tests/ci_build/Dockerfile.clang_tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ARG CUDA_VERSION
FROM nvidia/cuda:$CUDA_VERSION-devel-ubuntu18.04

# Environment
ENV DEBIAN_FRONTEND noninteractive

# Install all basic requirements
RUN \
apt-get update && \
apt-get install -y tar unzip wget git build-essential cmake python3 python3-pip llvm-7 clang-tidy-7 clang-7

# Set default clang-tidy version
RUN \
update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-7 100 && \
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-7 100

# NCCL2 (License: https://docs.nvidia.com/deeplearning/sdk/nccl-sla/index.html)
RUN \
export CUDA_SHORT=`echo $CUDA_VERSION | egrep -o '[0-9]+\.[0-9]'` && \
if [ "${CUDA_SHORT}" != "10.0" ]; then \
wget https://developer.download.nvidia.com/compute/redist/nccl/v2.2/nccl_2.2.13-1%2Bcuda${CUDA_SHORT}_x86_64.txz && \
tar xf "nccl_2.2.13-1+cuda${CUDA_SHORT}_x86_64.txz" && \
cp nccl_2.2.13-1+cuda${CUDA_SHORT}_x86_64/include/nccl.h /usr/include && \
cp nccl_2.2.13-1+cuda${CUDA_SHORT}_x86_64/lib/* /usr/lib && \
rm -f nccl_2.2.13-1+cuda${CUDA_SHORT}_x86_64.txz && \
rm -r nccl_2.2.13-1+cuda${CUDA_SHORT}_x86_64; fi

# Install Python packages
RUN \
pip3 install pyyaml

ENV GOSU_VERSION 1.10

# Install lightweight sudo (not bound to TTY)
RUN set -ex; \
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64" && \
chmod +x /usr/local/bin/gosu && \
gosu nobody true

# Default entry-point to use if running locally
# It will preserve attributes of created files
COPY entrypoint.sh /scripts/

WORKDIR /workspace
ENTRYPOINT ["/scripts/entrypoint.sh"]
12 changes: 12 additions & 0 deletions tests/ci_build/clang_tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

rm -rf gtest googletest-release-1.7.0
wget -nc https://github.com/google/googletest/archive/release-1.7.0.zip
unzip -n release-1.7.0.zip
mv googletest-release-1.7.0 gtest && cd gtest
cmake . && make
mkdir lib && mv libgtest.a lib
cd ..
rm -rf release-1.7.0.zip*

python3 tests/ci_build/tidy.py --gtest-path=${PWD}/gtest
4 changes: 0 additions & 4 deletions tests/ci_build/setup_cuda_path.sh

This file was deleted.

2 changes: 0 additions & 2 deletions tests/ci_build/tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def __init__(self, gtest_path, cpp_lint, cuda_lint):
raise ValueError('Both --cpp and --cuda are set to 0.')
self.root_path = os.path.abspath(os.path.curdir)
print('Project root:', self.root_path)
if 'xgboost' not in os.path.basename(self.root_path.rstrip('/')):
raise ValueError('Linter should be invoked in project root.')
self.cdb_path = os.path.join(self.root_path, 'cdb')

def __enter__(self):
Expand Down

0 comments on commit 8e8287e

Please sign in to comment.