Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#874: add docker to run custom clang-tidy version #1875

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/run-clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: PR tests (clang-tidy)

on:
push:
branches:
- develop
- 1.*
pull_request:

jobs:
build:
runs-on: ubuntu-latest

env:
CMAKE_BUILD_TYPE: release
VT_LB_ENABLED: 1
VT_TRACE_ENABLED: 1
VT_USE_OPENMP: 0
VT_USE_STD_THREAD: 0

steps:
- uses: actions/checkout@v2
- name: Run clang-tidy docker
shell: bash
run: docker build -f ci/docker/vt-clang-tidy.dockerfile -t vt-clang-tidy .
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ compile_commands.json
.dir-locals.el

.idea/

# Autogenerated file
src/vt/configs/generated/vt_git_revision.cc
135 changes: 135 additions & 0 deletions ci/clang_tidy_cpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/usr/bin/env bash

set -ex

source_dir=${1}
build_dir=${2}

# Dependency versions, when fetched via git.
detector_rev=master
checkpoint_rev=develop

if [ -z ${4} ]; then
dashj=""
else
dashj="-j ${4}"
fi

mkdir -p "${build_dir}"
pushd "${build_dir}"

if test -d "detector"
then
rm -Rf detector
fi

if test -d "checkpoint"
then
rm -Rf checkpoint
fi

if test -d "${source_dir}/lib/detector"
then
{ echo "Detector already in lib... not downloading, building, and installing"; } 2>/dev/null
else
if test "${VT_DOXYGEN_ENABLED:-0}" -eq 1
then
cd "${source_dir}/lib"
git clone -b "${detector_rev}" --depth 1 https://github.com/DARMA-tasking/detector.git
cd -
else
git clone -b "${detector_rev}" --depth 1 https://github.com/DARMA-tasking/detector.git
export DETECTOR=$PWD/detector
export DETECTOR_BUILD=${build_dir}/detector
mkdir -p "$DETECTOR_BUILD"
cd "$DETECTOR_BUILD"
mkdir build
cd build
cmake -G "${CMAKE_GENERATOR:-Ninja}" \
-DCMAKE_INSTALL_PREFIX="$DETECTOR_BUILD/install" \
"$DETECTOR"
cmake --build . ${dashj} --target install
fi
fi

if test -d "${source_dir}/lib/checkpoint"
then
{ echo "Checkpoint already in lib... not downloading, building, and installing"; } 2>/dev/null
else
if test "${VT_DOXYGEN_ENABLED:-0}" -eq 1
then
cd "${source_dir}/lib"
git clone -b "${checkpoint_rev}" --depth 1 https://github.com/DARMA-tasking/checkpoint.git
cd -
else
git clone -b "${checkpoint_rev}" --depth 1 https://github.com/DARMA-tasking/checkpoint.git
export CHECKPOINT=$PWD/checkpoint
export CHECKPOINT_BUILD=${build_dir}/checkpoint
mkdir -p "$CHECKPOINT_BUILD"
cd "$CHECKPOINT_BUILD"
mkdir build
cd build
cmake -G "${CMAKE_GENERATOR:-Ninja}" \
-DCMAKE_INSTALL_PREFIX="$CHECKPOINT_BUILD/install" \
-Ddetector_DIR="$DETECTOR_BUILD/install" \
"$CHECKPOINT"
cmake --build . ${dashj} --target install
fi
fi

if test "${VT_ZOLTAN_ENABLED:-0}" -eq 1
then
export Zoltan_DIR=${ZOLTAN_DIR:-""}
fi

export VT=${source_dir}
export VT_BUILD=${build_dir}/vt
mkdir -p "$VT_BUILD"
cd "$VT_BUILD"
rm -Rf ./*
cmake -G "${CMAKE_GENERATOR:-Ninja}" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-Dvt_test_trace_runtime_enabled="${VT_TRACE_RUNTIME_ENABLED:-0}" \
-Dvt_lb_enabled="${VT_LB_ENABLED:-1}" \
-Dvt_trace_enabled="${VT_TRACE_ENABLED:-0}" \
-Dvt_trace_only="${VT_BUILD_TRACE_ONLY:-0}" \
-Dvt_doxygen_enabled="${VT_DOXYGEN_ENABLED:-0}" \
-Dvt_mimalloc_enabled="${VT_MIMALLOC_ENABLED:-0}" \
-Dvt_asan_enabled="${VT_ASAN_ENABLED:-0}" \
-Dvt_ubsan_enabled="${VT_UBSAN_ENABLED:-0}" \
-Dvt_werror_enabled="${VT_WERROR_ENABLED:-0}" \
-Dvt_pool_enabled="${VT_POOL_ENABLED:-1}" \
-Dvt_build_extended_tests="${VT_EXTENDED_TESTS_ENABLED:-1}" \
-Dvt_zoltan_enabled="${VT_ZOLTAN_ENABLED:-0}" \
-Dvt_production_build_enabled="${VT_PRODUCTION_BUILD_ENABLED:-0}" \
-Dvt_unity_build_enabled="${VT_UNITY_BUILD_ENABLED:-0}" \
-Dvt_diagnostics_enabled="${VT_DIAGNOSTICS_ENABLED:-1}" \
-Dvt_diagnostics_runtime_enabled="${VT_DIAGNOSTICS_RUNTIME_ENABLED:-0}" \
-Dvt_fcontext_enabled="${VT_FCONTEXT_ENABLED:-0}" \
-Dvt_fcontext_build_tests_examples="${VT_FCONTEXT_BUILD_TESTS_EXAMPLES:-0}" \
-Dvt_rdma_tests_enabled="${VT_RDMA_TESTS_ENABLED:-1}" \
-DUSE_OPENMP="${VT_USE_OPENMP:-0}" \
-DUSE_STD_THREAD="${VT_USE_STD_THREAD:-0}" \
-DCODE_COVERAGE="${CODE_COVERAGE:-0}" \
-DMI_INTERPOSE:BOOL=ON \
-DMI_OVERRIDE:BOOL=ON \
-Dvt_mpi_guards="${VT_MPI_GUARD_ENABLED:-0}" \
-DMPI_EXTRA_FLAGS="${MPI_EXTRA_FLAGS:-}" \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" \
-DMPI_C_COMPILER="${MPICC:-mpicc}" \
-DMPI_CXX_COMPILER="${MPICXX:-mpicxx}" \
-DCMAKE_CXX_COMPILER="${CXX:-c++}" \
-DCMAKE_C_COMPILER="${CC:-cc}" \
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS:-}" \
-Ddetector_DIR="$DETECTOR_BUILD/install" \
-Dcheckpoint_DIR="$CHECKPOINT_BUILD/install" \
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH:-}" \
-DCMAKE_INSTALL_PREFIX="$VT_BUILD/install" \
-Dvt_ci_build="${VT_CI_BUILD:-0}" \
-Dvt_debug_verbose="${VT_DEBUG_VERBOSE:-}" \
-Dvt_tests_num_nodes="${VT_TESTS_NUM_NODES:-}" \
-Dvt_no_color_enabled="${VT_NO_COLOR_ENABLED:-0}" \
-DBUILD_SHARED_LIBS="${BUILD_SHARED_LIBS:-0}" \
"$VT"

run-clang-tidy -checks='-*, bugprone-*, misc-redundant-const-refs'
90 changes: 90 additions & 0 deletions ci/docker/vt-clang-tidy.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
FROM jstrz/vt-clang-tidy:pr-1-merge AS base

ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /

RUN apt-get remove cmake -y -q
RUN apt-get update -y -q
RUN apt-get install -y -q --no-install-recommends \
ca-certificates \
ccache \
curl \
git \
less \
libomp-dev \
libomp5 \
make-guile \
ninja-build \
python \
python3 \
valgrind \
wget \
zlib1g \
zlib1g-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV CC=clang \
CXX=clang++

COPY ./ci/deps/libunwind.sh libunwind.sh
RUN ./libunwind.sh 1.6.2

COPY ./ci/deps/cmake.sh cmake.sh
RUN ./cmake.sh 3.18.4

ENV PATH=/cmake/bin/:$PATH
ENV LESSCHARSET=utf-8

COPY ./ci/deps/mpich.sh mpich.sh
RUN ./mpich.sh 4.0.2 -j"$(nproc)"

ENV MPI_EXTRA_FLAGS="" \
CMAKE_PREFIX_PATH="/lib/x86_64-linux-gnu/" \
PATH=/usr/lib/ccache/:$PATH \
CMAKE_EXE_LINKER_FLAGS="-pthread"

FROM base AS build
COPY . /vt

ARG BUILD_SHARED_LIBS
ARG CMAKE_BUILD_TYPE
ARG VT_ASAN_ENABLED
ARG VT_DOXYGEN_ENABLED
ARG VT_EXTENDED_TESTS_ENABLED
ARG VT_FCONTEXT_ENABLED
ARG VT_LB_ENABLED
ARG VT_MIMALLOC_ENABLED
ARG VT_NO_COLOR_ENABLED
ARG VT_POOL_ENABLED
ARG VT_PRODUCTION_BUILD_ENABLED
ARG VT_TRACE_ENABLED
ARG VT_TRACE_RUNTIME_ENABLED
ARG VT_UBSAN_ENABLED
ARG VT_USE_OPENMP
ARG VT_USE_STD_THREAD
ARG VT_WERROR_ENABLED

ENV BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} \
CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \
VT_DIAGNOSTICS_ENABLED=${VT_DIAGNOSTICS_ENABLED} \
VT_DIAGNOSTICS_RUNTIME_ENABLED=${VT_DIAGNOSTICS_RUNTIME_ENABLED} \
VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \
VT_EXTENDED_TESTS_ENABLED=${VT_EXTENDED_TESTS_ENABLED} \
VT_FCONTEXT_ENABLED=${VT_FCONTEXT_ENABLED} \
VT_LB_ENABLED=${VT_LB_ENABLED} \
VT_MIMALLOC_ENABLED=${VT_MIMALLOC_ENABLED} \
VT_MPI_GUARD_ENABLED=${VT_MPI_GUARD_ENABLED} \
VT_NO_COLOR_ENABLED=${VT_NO_COLOR_ENABLED} \
VT_POOL_ENABLED=${VT_POOL_ENABLED} \
VT_PRODUCTION_BUILD_ENABLED=${VT_PRODUCTION_BUILD_ENABLED} \
VT_TRACE_ENABLED=${VT_TRACE_ENABLED} \
VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \
VT_UBSAN_ENABLED=${VT_UBSAN_ENABLED} \
VT_UNITY_BUILD_ENABLED=${VT_UNITY_BUILD_ENABLED} \
VT_USE_OPENMP=${VT_USE_OPENMP} \
VT_USE_STD_THREAD=${VT_USE_STD_THREAD} \
VT_WERROR_ENABLED=${VT_WERROR_ENABLED}

RUN /vt/ci/clang_tidy_cpp.sh /vt /build
2 changes: 1 addition & 1 deletion cmake/build_git_info.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ else()
endif()
endif()

set(VT_GIT_CONFIG_FILE "${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revision.cc")
set(VT_GIT_CONFIG_FILE "${CMAKE_SOURCE_DIR}/src/vt/configs/generated/vt_git_revision.cc")
add_custom_command(
OUTPUT ${VT_GIT_CONFIG_FILE}
COMMAND ${CMAKE_COMMAND}
Expand Down
64 changes: 64 additions & 0 deletions src/vt/configs/generated/vt_git_revision.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
//@HEADER
// *****************************************************************************
//
// vt_git_revision.cc
// DARMA/vt => Virtual Transport
//
// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC
// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
// Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact [email protected]
//
// *****************************************************************************
//@HEADER
*/

#include "vt/configs/generated/vt_git_revision.h"

#include <string>

#define VT_VERSION_MAJOR 1
#define VT_VERSION_MINOR 1
#define VT_VERSION_PATCH 0
#define VT_GIT_SHA1 "21f42e5abc76b8c3a6cccefa42d43e1b37d79c55"
#define VT_GIT_EXACT_TAG "heads/874-integrate-clang-tidy-docker"
#define VT_GIT_REFSPEC "refs/heads/874-integrate-clang-tidy-docker"
#define VT_GIT_DESCRIPTION "heads/874-integrate-clang-tidy-docker-0-g21f42e5abc"
#define VT_GIT_CLEAN_STATUS "DIRTY"

int const vt_version_major = VT_VERSION_MAJOR;
int const vt_version_minor = VT_VERSION_MINOR;
int const vt_version_patch = VT_VERSION_PATCH;
std::string const vt_git_sha1 = VT_GIT_SHA1;
std::string const vt_git_exact_tag = VT_GIT_EXACT_TAG;
std::string const vt_git_refspec = VT_GIT_REFSPEC;
std::string const vt_git_description = VT_GIT_DESCRIPTION;
std::string const vt_git_clean_status = VT_GIT_CLEAN_STATUS;
Loading