From 19c6ec709926195148af180db4f0c8372c5f39c9 Mon Sep 17 00:00:00 2001 From: Bogdan Vaneev Date: Thu, 14 Sep 2017 21:54:04 +0300 Subject: [PATCH] Fix bugs in CI, add housekeeping script, add sonar --- .circleci/config.yml | 29 ++- CMakeLists.txt | 1 + docker/develop/Dockerfile | 234 +++++++++++------- .../upsource-webhook.py | 2 +- housekeeping/xml-reports.sh | 46 ++++ sonar-project.properties | 25 ++ 6 files changed, 241 insertions(+), 96 deletions(-) rename {.circleci => housekeeping}/upsource-webhook.py (98%) create mode 100755 housekeeping/xml-reports.sh create mode 100644 sonar-project.properties diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d48dc1e90..0357c6c329 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: - image: hyperledger/iroha-docker-develop environment: IROHA_HOME: /opt/iroha - IROHA_BUILD: /tmp/build + IROHA_BUILD: /opt/iroha/build - image: postgres:9.5 - image: redis:3.2.8 steps: @@ -16,7 +16,7 @@ jobs: - run: name: notify upsource about current build command: | - python3 .circleci/upsource-webhook.py --in-progress + python3 .circleci/upsource-webhook.py --in-progress || true - run: name: ensure, required folders created command: | @@ -40,19 +40,34 @@ jobs: command: cmake -DCOVERAGE=ON -H$IROHA_HOME -B$IROHA_BUILD - run: name: make - command: cmake --build $IROHA_BUILD -- -j4 + command: cmake --build $IROHA_BUILD -- -j2 - run: name: code coverage pre command: cmake --build $IROHA_BUILD --target coverage.init.info - run: - name: run tests - command: cmake --build $IROHA_BUILD --target test + name: unit tests, generate xunit-*.xml + command: | + GTEST_DIR=$IROHA_BUILD/test_bin + for test in $(ls $GTEST_DIR); do + XUTEST=$IROHA_BUILD/xunit-$test.xml + # generates build/xunit-*.xml files with reports + $GTEST_DIR/$test --gtest_output=xml:$XUTEST + done - run: - name: code coverage post + name: post code coverage command: | cmake --build $IROHA_BUILD --target coverage.info lcov --list $IROHA_BUILD/coverage.info bash <(curl -s https://codecov.io/bash) -X fix -f $IROHA_BUILD/coverage.info || echo "Codecov did not collect coverage reports" + - run: + name: run analyzers and generate xml reports + command: | + # generate reports. they all will be in build directory + housekeeping/xml-reports.sh + - run: + name: execute sonar-scanner + command: sonar-scanner -Dsonar.login=${SONAR_TOKEN} -Dsonar.projectVersion="${CIRCLE_BRANCH}" + - run: name: ccache teardown command: | @@ -69,4 +84,4 @@ jobs: notify: webhooks: - - url: https://upsource.soramitsu.co.jp/webhook/circleci + - url: http://upsource.soramitsu.co.jp:1112 diff --git a/CMakeLists.txt b/CMakeLists.txt index 794cf8620b..07c1cb984f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wextra -Wno-unused-parameter -O0") SET(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1) if(COVERAGE) + set(CMAKE_EXPORT_COMPILE_COMMANDS "ON") find_program(LCOV_PROGRAM lcov) if(NOT LCOV_PROGRAM) message(FATAL_ERROR "lcov not found! Aborting...") diff --git a/docker/develop/Dockerfile b/docker/develop/Dockerfile index c91d771b6a..470cffe3be 100644 --- a/docker/develop/Dockerfile +++ b/docker/develop/Dockerfile @@ -1,5 +1,9 @@ FROM ubuntu:16.04 +# number of concurrent threads during build +# usage: docker build --build-arg PARALLELISM=8 -t name/name . +ARG PARALLELISM=1 + RUN apt-get update; \ apt-get -y upgrade; \ apt-get -y --no-install-recommends install apt-utils; \ @@ -8,144 +12,198 @@ RUN apt-get update; \ RUN apt-get -y --no-install-recommends install build-essential python-software-properties \ automake libtool \ # dev dependencies - libssl-dev libc-ares-dev \ + libssl-dev libc-ares-dev libboost-all-dev libc6-dbg \ # CircleCI dependencies git ssh tar gzip ca-certificates python3 python3-pip python3-setuptools \ # code coverage lcov \ # other - wget curl cmake file unzip gdb iputils-ping vim ccache; \ + wget curl cmake file unzip gdb iputils-ping vim ccache gcovr vera++ cppcheck; \ apt-get -y clean +RUN pip3 install --upgrade pip RUN pip3 install flask requests # install protobuf 3.3.0 -RUN git clone https://github.com/google/protobuf /tmp/protobuf-3.3.0; \ - (cd /tmp/protobuf-3.3.0 ; git checkout a6189acd18b00611c1dc7042299ad75486f08a1a); \ - (cd /tmp/protobuf-3.3.0/ ; /tmp/protobuf-3.3.0/autogen.sh); \ - (cd /tmp/protobuf-3.3.0/ ; /tmp/protobuf-3.3.0/configure); \ - make -C /tmp/protobuf-3.3.0; \ - make -C /tmp/protobuf-3.3.0 install; \ +ENV PROTOBUF_VERSION=3.3.0 +RUN git clone https://github.com/google/protobuf /tmp/protobuf-${PROTOBUF_VERSION}; \ + (cd /tmp/protobuf-${PROTOBUF_VERSION} ; git checkout a6189acd18b00611c1dc7042299ad75486f08a1a); \ + (cd /tmp/protobuf-${PROTOBUF_VERSION}/ ; /tmp/protobuf-${PROTOBUF_VERSION}/autogen.sh); \ + (cd /tmp/protobuf-${PROTOBUF_VERSION}/ ; /tmp/protobuf-${PROTOBUF_VERSION}/configure); \ + make -j${PARALLELISM} -C /tmp/protobuf-${PROTOBUF_VERSION}; \ + make -j${PARALLELISM} -C /tmp/protobuf-${PROTOBUF_VERSION} install; \ ldconfig; \ - rm -rf /tmp/protobuf-3.3.0 + rm -rf /tmp/protobuf-${PROTOBUF_VERSION} # install grpc 1.3.2 -RUN git clone https://github.com/grpc/grpc /tmp/grpc-1.3.2; \ - (cd /tmp/grpc-1.3.2 ; git checkout c80d3321d0f77bef8cfff8b32490a07c1e90a5ad); \ - make -C /tmp/grpc-1.3.2; \ - make -C /tmp/grpc-1.3.2 install; \ +ENV GRPC_VERSION=1.3.2 +RUN git clone https://github.com/grpc/grpc /tmp/grpc-${GRPC_VERSION}; \ + (cd /tmp/grpc-${GRPC_VERSION} ; git checkout c80d3321d0f77bef8cfff8b32490a07c1e90a5ad); \ + make -j${PARALLELISM} -C /tmp/grpc-${GRPC_VERSION}; \ + make -j${PARALLELISM} -C /tmp/grpc-${GRPC_VERSION} install; \ ldconfig; \ - rm -rf /tmp/grpc-1.3.2 + rm -rf /tmp/grpc-${GRPC_VERSION} # install gtest 1.8.0 -RUN git clone https://github.com/google/googletest /tmp/googletest-release-1.8.0; \ - (cd /tmp/googletest-release-1.8.0 ; git checkout ec44c6c1675c25b9827aacd08c02433cccde7780); \ - cmake -H/tmp/googletest-release-1.8.0 -B/tmp/googletest-release-1.8.0/build; \ - cmake --build /tmp/googletest-release-1.8.0/build --target install; \ - rm -rf /tmp/googletest-release-1.8.0 +ENV GTEST_VERSION=1.8.0 +RUN git clone https://github.com/google/googletest /tmp/googletest-release-${GTEST_VERSION}; \ + (cd /tmp/googletest-release-${GTEST_VERSION} ; git checkout ec44c6c1675c25b9827aacd08c02433cccde7780); \ + cmake -H/tmp/googletest-release-${GTEST_VERSION} -B/tmp/googletest-release-${GTEST_VERSION}/build; \ + cd /tmp/googletest-release-${GTEST_VERSION}/build; \ + make -j${PARALLELISM} install; \ + cd -; \ + rm -rf /tmp/googletest-release-${GTEST_VERSION} # install gflags 2.2.0 -RUN git clone https://github.com/gflags/gflags /tmp/gflags-2.2.0; \ - (cd /tmp/gflags-2.2.0 ; git checkout f8a0efe03aa69b3336d8e228b37d4ccb17324b88); \ - cmake -H/tmp/gflags-2.2.0 -B/tmp/gflags-2.2.0/build; \ - cmake --build /tmp/gflags-2.2.0/build --target install; \ - rm -rf /tmp/gflags-2.2.0 +ENV CFLAGS_VERSION=2.2.0 +RUN git clone https://github.com/gflags/gflags /tmp/gflags-${GFLAGS_VERSION}; \ + (cd /tmp/gflags-${GFLAGS_VERSION} ; git checkout f8a0efe03aa69b3336d8e228b37d4ccb17324b88); \ + cmake -H/tmp/gflags-${GFLAGS_VERSION} -B/tmp/gflags-${GFLAGS_VERSION}/build; \ + cd /tmp/gflags-${GFLAGS_VERSION}/build; \ + make -j${PARALLELISM} install; \ + cd -; \ + rm -rf /tmp/gflags-${GFLAGS_VERSION} # install spdlog 0.13.0 -RUN git clone https://github.com/gabime/spdlog /tmp/spdlog-0.13.0; \ - (cd /tmp/spdlog-0.13.0 ; git checkout f85a08622e20b74bff34381cafcb8ef8167b29d0); \ - cmake -DSPDLOG_BUILD_TESTING=OFF -H/tmp/spdlog-0.13.0 -B/tmp/spdlog-0.13.0/build; \ - cmake --build /tmp/spdlog-0.13.0/build --target install; \ - rm -rf /tmp/spdlog-0.13.0 +ENV SPDLOG_VERSION=0.13.0 +RUN git clone https://github.com/gabime/spdlog /tmp/spdlog-${SPDLOG_VERSION}; \ + (cd /tmp/spdlog-${SPDLOG_VERSION} ; git checkout f85a08622e20b74bff34381cafcb8ef8167b29d0); \ + cmake -DSPDLOG_BUILD_TESTING=OFF -H/tmp/spdlog-${SPDLOG_VERSION} -B/tmp/spdlog-${SPDLOG_VERSION}/build; \ + cd /tmp/spdlog-${SPDLOG_VERSION}/build; \ + make -j${PARALLELISM} install; \ + cd -; \ + rm -rf /tmp/spdlog-${SPDLOG_VERSION} # install rxcpp 4.0.0, apply patch for include path -RUN git clone https://github.com/Reactive-Extensions/RxCpp /tmp/RxCpp-4.0.0; \ - (cd /tmp/RxCpp-4.0.0 ; git checkout 08c47e42930168cedf76037f8c76d47565251599); \ - (cd /tmp/RxCpp-4.0.0 ; git cherry-pick -n 5b7b2a5519f712a7831053865a4ae6082dac4ed5); \ - cmake -H/tmp/RxCpp-4.0.0 -B/tmp/RxCpp-4.0.0/build; \ - cmake --build /tmp/RxCpp-4.0.0/build --target install; \ - rm -rf /tmp/RxCpp-4.0.0 +ENV RXCPP_VERSION=4.0.0 +RUN git clone https://github.com/Reactive-Extensions/RxCpp /tmp/RxCpp-${RXCPP_VERSION}; \ + (cd /tmp/RxCpp-${RXCPP_VERSION} ; git checkout 08c47e42930168cedf76037f8c76d47565251599); \ + (cd /tmp/RxCpp-${RXCPP_VERSION} ; git cherry-pick -n 5b7b2a5519f712a7831053865a4ae6082dac4ed5); \ + cmake -H/tmp/RxCpp-${RXCPP_VERSION} -B/tmp/RxCpp-${RXCPP_VERSION}/build; \ + cd /tmp/RxCpp-${RXCPP_VERSION}/build; \ + make -j${PARALLELISM} install; \ + cd -; \ + rm -rf /tmp/RxCpp-${RXCPP_VERSION} # install ed25519 and sha3 RUN git clone https://github.com/MizukiSonoko/ed25519 /tmp/ed25519; \ (cd /tmp/ed25519 ; git checkout 3a5c02cbd91f84983a1622ed6bc14de6264b8361); \ - make -C /tmp/ed25519; \ + make -j${PARALLELISM} -C /tmp/ed25519; \ cp /tmp/ed25519/lib/* /usr/local/lib; \ cp /tmp/ed25519/src/sha3.h /usr/local/include; \ cp /tmp/ed25519/src/ed25519.h /usr/local/include; \ rm -rf /tmp/ed25519 # install rapidjson 1.1.0 -RUN git clone https://github.com/miloyip/rapidjson /tmp/rapidjson-1.1.0; \ - (cd /tmp/rapidjson-1.1.0 ; git checkout f54b0e47a08782a6131cc3d60f94d038fa6e0a51); \ - cmake -DRAPIDJSON_BUILD_EXAMPLES=OFF -H/tmp/rapidjson-1.1.0 -B/tmp/rapidjson-1.1.0/build; \ - cmake --build /tmp/rapidjson-1.1.0/build --target install; \ - rm -rf /tmp/rapidjson-1.1.0 +ENV RAPIDJSON_VERSION=1.1.0 +RUN git clone https://github.com/miloyip/rapidjson /tmp/rapidjson-${RAPIDJSON_VERSION}; \ + (cd /tmp/rapidjson-${RAPIDJSON_VERSION} ; git checkout f54b0e47a08782a6131cc3d60f94d038fa6e0a51); \ + cmake -DRAPIDJSON_BUILD_EXAMPLES=OFF -H/tmp/rapidjson-${RAPIDJSON_VERSION} -B/tmp/rapidjson-${RAPIDJSON_VERSION}/build; \ + cd /tmp/rapidjson-${RAPIDJSON_VERSION}/build; \ + make -j${PARALLELISM} install; \ + cd -; \ + rm -rf /tmp/rapidjson-${RAPIDJSON_VERSION} # install optional 2.1.0 -RUN git clone https://github.com/martinmoene/optional-lite /tmp/optional-lite-2.1.0; \ - (cd /tmp/optional-lite-2.1.0 ; git checkout a0ddabb8b52e1eaaf0dd1515bb85698b747528e4); \ - cp -r /tmp/optional-lite-2.1.0/include/nonstd /usr/local/include; \ - rm -rf /tmp/optional-lite-2.1.0 +ENV OPTIONAL_VERSION=2.1.0 +RUN git clone https://github.com/martinmoene/optional-lite /tmp/optional-lite-${OPTIONAL_VERSION}; \ + (cd /tmp/optional-lite-${OPTIONAL_VERSION} ; git checkout a0ddabb8b52e1eaaf0dd1515bb85698b747528e4); \ + cp -r /tmp/optional-lite-${OPTIONAL_VERSION}/include/nonstd /usr/local/include; \ + rm -rf /tmp/optional-lite-${OPTIONAL_VERSION} # install libpq 9.5.8 -RUN git clone https://git.postgresql.org/git/postgresql.git /tmp/postgresql-9.5.8; \ - (cd /tmp/postgresql-9.5.8 ; git checkout 029386ccbddd0a33d481b94e511f5219b03e6636); \ - (cd /tmp/postgresql-9.5.8 ; /tmp/postgresql-9.5.8/configure --without-readline --prefix=/usr/local); \ - make -C /tmp/postgresql-9.5.8/src/bin/pg_config; \ - make -C /tmp/postgresql-9.5.8/src/interfaces/libpq; \ - make -C /tmp/postgresql-9.5.8/src/bin/pg_config install; \ - make -C /tmp/postgresql-9.5.8/src/interfaces/libpq install; \ - make -C /tmp/postgresql-9.5.8/src/include install; \ - rm -rf /tmp/postgresql-9.5.8 +ENV POSTGRESQL_VERSION=9.5.8 +RUN git clone https://git.postgresql.org/git/postgresql.git /tmp/postgresql-${POSTGRESQL_VERSION}; \ + (cd /tmp/postgresql-${POSTGRESQL_VERSION} ; git checkout 029386ccbddd0a33d481b94e511f5219b03e6636); \ + (cd /tmp/postgresql-${POSTGRESQL_VERSION} ; /tmp/postgresql-${POSTGRESQL_VERSION}/configure --without-readline --prefix=/usr/local); \ + make -C /tmp/postgresql-${POSTGRESQL_VERSION}/src/bin/pg_config; \ + make -C /tmp/postgresql-${POSTGRESQL_VERSION}/src/interfaces/libpq; \ + make -C /tmp/postgresql-${POSTGRESQL_VERSION}/src/bin/pg_config install; \ + make -C /tmp/postgresql-${POSTGRESQL_VERSION}/src/interfaces/libpq install; \ + make -C /tmp/postgresql-${POSTGRESQL_VERSION}/src/include install; \ + rm -rf /tmp/postgresql-${POSTGRESQL_VERSION} # install pqxx 5.1.0 -RUN git clone https://github.com/jtv/libpqxx /tmp/libpqxx-5.1.0; \ - (cd /tmp/libpqxx-5.1.0 ; git checkout 5b17abce5ac2b1a2f8278718405b7ade8bb30ae9); \ - (cd /tmp/libpqxx-5.1.0 ; /tmp/libpqxx-5.1.0/configure --disable-documentation --with-pic); \ - make -C /tmp/libpqxx-5.1.0; \ - make -C /tmp/libpqxx-5.1.0 install; \ - rm -rf /tmp/libpqxx-5.1.0 +ENV PQXX_VERSION=5.1.0 +RUN git clone https://github.com/jtv/libpqxx /tmp/libpqxx-${PQXX_VERSION}; \ + (cd /tmp/libpqxx-${PQXX_VERSION} ; git checkout 5b17abce5ac2b1a2f8278718405b7ade8bb30ae9); \ + (cd /tmp/libpqxx-${PQXX_VERSION} ; /tmp/libpqxx-${PQXX_VERSION}/configure --disable-documentation --with-pic); \ + make -j${PARALLELISM} -C /tmp/libpqxx-${PQXX_VERSION}; \ + make -j${PARALLELISM} -C /tmp/libpqxx-${PQXX_VERSION} install; \ + rm -rf /tmp/libpqxx-${PQXX_VERSION} # install cpp_redis 3.5.3 with tacopie 2.4.4 -RUN git clone https://github.com/Cylix/cpp_redis /tmp/cpp_redis-3.5.3; \ - (cd /tmp/cpp_redis-3.5.3 ; git checkout 727aa5f06c8ce498168cbab5a023cad5b9c00bc0); \ - git clone https://github.com/Cylix/tacopie /tmp/cpp_redis-3.5.3/tacopie; \ - (cd /tmp/cpp_redis-3.5.3/tacopie ; git checkout 290dc38681f346adae41d3cc8feabbe534424675); \ - cmake -H/tmp/cpp_redis-3.5.3 -B/tmp/cpp_redis-3.5.3/build; \ - cmake --build /tmp/cpp_redis-3.5.3/build --target install; \ - rm -rf /tmp/cpp_redis-3.5.3 +ENV CPP_REDIS_VERSION=3.5.3 +RUN git clone https://github.com/Cylix/cpp_redis /tmp/cpp_redis-${CPP_REDIS_VERSION}; \ + (cd /tmp/cpp_redis-${CPP_REDIS_VERSION} ; git checkout 727aa5f06c8ce498168cbab5a023cad5b9c00bc0); \ + git clone https://github.com/Cylix/tacopie /tmp/cpp_redis-${CPP_REDIS_VERSION}/tacopie; \ + (cd /tmp/cpp_redis-${CPP_REDIS_VERSION}/tacopie ; git checkout 290dc38681f346adae41d3cc8feabbe534424675); \ + cmake -H/tmp/cpp_redis-${CPP_REDIS_VERSION} -B/tmp/cpp_redis-${CPP_REDIS_VERSION}/build; \ + cd /tmp/cpp_redis-${CPP_REDIS_VERSION}/build; \ + make -j${PARALLELISM} install; \ + cd -; \ + rm -rf /tmp/cpp_redis-${CPP_REDIS_VERSION} # install libuv 1.13.1 -RUN git clone https://github.com/libuv/libuv /tmp/libuv-1.13.1; \ - (cd /tmp/libuv-1.13.1 ; git checkout 2bb4b68758f07cd8617838e68c44c125bc567ba6); \ - /tmp/libuv-1.13.1/autogen.sh; \ - (cd /tmp/libuv-1.13.1 ; /tmp/libuv-1.13.1/configure); \ - make -C /tmp/libuv-1.13.1; \ - make -C /tmp/libuv-1.13.1 install; \ - rm -rf /tmp/libuv-1.13.1 +ENV LIBUV_VERSION=1.13.1 +RUN git clone https://github.com/libuv/libuv /tmp/libuv-${LIBUV_VERSION}; \ + (cd /tmp/libuv-${LIBUV_VERSION} ; git checkout 2bb4b68758f07cd8617838e68c44c125bc567ba6); \ + /tmp/libuv-${LIBUV_VERSION}/autogen.sh; \ + (cd /tmp/libuv-${LIBUV_VERSION} ; /tmp/libuv-${LIBUV_VERSION}/configure); \ + make -j${PARALLELISM} -C /tmp/libuv-${LIBUV_VERSION}; \ + make -j${PARALLELISM} -C /tmp/libuv-${LIBUV_VERSION} install; \ + rm -rf /tmp/libuv-${LIBUV_VERSION} # install uvw 1.1.0 -RUN git clone https://github.com/skypjack/uvw /tmp/uvw-1.1.0_libuv-v1.13; \ - (cd /tmp/uvw-1.1.0_libuv-v1.13 ; git checkout 00de1f1110ce4a9803a85a214af5326529f11312); \ - cp -r /tmp/uvw-1.1.0_libuv-v1.13/src/* /usr/local/include; \ - rm -rf /tmp/uvw-1.1.0_libuv-v1.13 +ENV UVW_VERSION=1.1.0_libuv-v1.13 +RUN git clone https://github.com/skypjack/uvw /tmp/uvw-${UVW_VERSION}; \ + (cd /tmp/uvw-${UVW_VERSION} ; git checkout 00de1f1110ce4a9803a85a214af5326529f11312); \ + cp -r /tmp/uvw-${UVW_VERSION}/src/* /usr/local/include; \ + rm -rf /tmp/uvw-${UVW_VERSION} # install tbb -RUN git clone https://github.com/01org/tbb /tmp/tbb-2017_U7; \ - (cd /tmp/tbb-2017_U7 ; git checkout eb6336ad29450f2a64af5123ca1b9429ff6bc11d); \ - make -C /tmp/tbb-2017_U7 tbb_build_prefix=build; \ - cp /tmp/tbb-2017_U7/build/build_debug/*.so* /usr/local/lib; \ - cp /tmp/tbb-2017_U7/build/build_release/*.so* /usr/local/lib; \ - cp -r /tmp/tbb-2017_U7/include/* /usr/local/include; \ +ENV TBB_VERSION=2017_U7 +RUN git clone https://github.com/01org/tbb /tmp/tbb-${TBB_VERSION}; \ + (cd /tmp/tbb-${TBB_VERSION} ; git checkout eb6336ad29450f2a64af5123ca1b9429ff6bc11d); \ + make -j${PARALLELISM} -C /tmp/tbb-${TBB_VERSION} tbb_build_prefix=build; \ + cp /tmp/tbb-${TBB_VERSION}/build/build_debug/*.so* /usr/local/lib; \ + cp /tmp/tbb-${TBB_VERSION}/build/build_release/*.so* /usr/local/lib; \ + cp -r /tmp/tbb-${TBB_VERSION}/include/* /usr/local/include; \ ldconfig; \ - rm -rf /tmp/tbb-2017_U7 + rm -rf /tmp/tbb-${TBB_VERSION} # install docker -RUN curl -L -o /tmp/docker-17.06.0-ce.tgz https://download.docker.com/linux/static/stable/x86_64/docker-17.06.0-ce.tgz; \ - tar -xz -C /tmp -f /tmp/docker-17.06.0-ce.tgz; \ +ENV DOCKER_VERSION=17.06.0-ce +RUN curl -L -o /tmp/docker-${DOCKER_VERSION}.tgz https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz; \ + tar -xz -C /tmp -f /tmp/docker-${DOCKER_VERSION}.tgz; \ mv /tmp/docker/* /usr/bin; \ - rm /tmp/docker-17.06.0-ce.tgz; \ + rm /tmp/docker-${DOCKER_VERSION}.tgz; \ rm -rf /tmp/docker +# install sonar cli +ENV SONAR_CLI_VERSION=3.0.3.778 +RUN mkdir -p /opt/sonar; \ + curl -L -o /tmp/sonar.zip https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_CLI_VERSION}-linux.zip; \ + unzip -o -d /tmp/sonar-scanner /tmp/sonar.zip; \ + mv /tmp/sonar-scanner/sonar-scanner-${SONAR_CLI_VERSION}-linux /opt/sonar/scanner; \ + cd /usr/local/bin; \ + ln -s -f /opt/sonar/scanner/bin/sonar-scanner sonar-scanner; \ + rm -rf /tmp/sonar* + +# install sonar build wrapper +RUN curl -L -o /tmp/sonar-build-wrapper.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip; \ + unzip -o -d /tmp/sonar-build-wrapper /tmp/sonar-build-wrapper.zip; \ + mv /tmp/sonar-build-wrapper/build-wrapper-linux-x86 /opt/sonar/build-wrapper; \ + cd /usr/local/bin; \ + ln -s -f /opt/sonar/build-wrapper/build-wrapper-linux-x86-64 sonar-build-wrapper; \ + rm -rf /tmp/sonar* + +# install latest valgrind +RUN cd /tmp; git clone git://sourceware.org/git/valgrind.git; \ + cd /tmp/valgrind; \ + ./autogen.sh; ./configure; make -j${PARALLELISM};\ + make install; \ + rm -rf /tmp/valgrind* + +WORKDIR /opt/iroha CMD ["/bin/bash"] diff --git a/.circleci/upsource-webhook.py b/housekeeping/upsource-webhook.py similarity index 98% rename from .circleci/upsource-webhook.py rename to housekeeping/upsource-webhook.py index ceb50b1566..e9412cbe39 100755 --- a/.circleci/upsource-webhook.py +++ b/housekeeping/upsource-webhook.py @@ -21,7 +21,7 @@ def submit_ci_status(key = "IROHA", name = "null", description = "null", revision = "null"): - upsource_url = "https://upsource.soramitsu.co.jp/~buildStatus" + upsource_url = "http://upsource.soramitsu.co.jp/~buildStatus" project = "iroha" post_body = { diff --git a/housekeeping/xml-reports.sh b/housekeeping/xml-reports.sh new file mode 100755 index 0000000000..cd7a2758ae --- /dev/null +++ b/housekeeping/xml-reports.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +BUILD_DIR=/opt/iroha/build +PARALLELISM=`nproc --all` +IROHA_HOME=$(dirname $(realpath $0))/.. + +cd $IROHA_HOME + +# all files with source code will be here +SOURCES=`find $PWD -type f | egrep "\.(hpp|cpp|h|c|cc)$" | egrep -v "external"` + +cd $BUILD_DIR + +# run vera++ +VERA_XML=${BUILD_DIR}/vera-report.xml +cat $SOURCES | vera++ - -s -c ${VERA_XML} + + +# run cppcheck +CPPCHECK_XML=${BUILD_DIR}/cppcheck-report.xml +cppcheck -j${PARALLELISM} -v \ + -Ilibs -Iirohad -Iiroha-cli \ + --enable=all \ + --xml --xml-version=2 ${SOURCES} 2> ${CPPCHECK_XML} + +# run clang-tidy +# currently sonar can not parse clang-tidy output +#run-clang-tidy-3.8.py -p $BUILD_DIR -j${PARALLELISM} -header-filter=^${BUILD_DIR}/.* 2> + +# run tests, valgrind +GTEST_DIR=${BUILD_DIR}/test_bin +for test in $(ls $GTEST_DIR); do + VGXML=${BUILD_DIR}/valgrind-$test.xml + XUXML=${BUILD_DIR}/xunit-$test.xml + + bin=$GTEST_DIR/$test + valgrind --xml=yes --xml-file=$VGXML \ + --leak-check=full --demangle=yes \ + $bin + # generate xunit files + # disabled here, but enabled in circleci + #--gtest_output=xml:$XUXML +done + +# collect the coverage data +gcovr -x -r ${IROHA_HOME} > ${BUILD_DIR}/gcovr-report.xml diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000000..ca995d95dc --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,25 @@ +sonar.sourceEncodinig=UTF-8 + +sonar.projectKey=hyperledger:iroha +sonar.projectName=Iroha +sonar.host.url=https://sonar.soramitsu.co.jp +sonar.language=c++ +sonar.cpp.std=c++14 +sonar.sources=irohad,iroha-cli,libs +sonar.exclusions=build,external +sonar.cxx.compiler.parser=GCC + +sonar.artifact.path=build +sonar.tests=test + +sonar.cxx.jsonCompilationDatabase=build/compile_commands.json + +sonar.cxx.coverage.reportPath=build/gcovr-report*.xml +sonar.cxx.coverage.itReportPath=build/gcovr-report*.xml +sonar.cxx.coverage.overallReportPath=build/gcovr-report*.xml +sonar.cxx.valgrind.reportPath=build/valgrind*.xml +sonar.cxx.cppcheck.reportPath=build/cppcheck*.xml +sonar.cxx.vera.reportPath=build/vera*.xml +sonar.cxx.xunit.reportPath=build/xunit*.xml + +#sonar.cxx.includeDirectories=/usr/include/c++/5,/usr/include/i386-linux-gnu/c++/5,/usr/include,/usr/include/c++/5/tr1,/usr/include/linux,irohad,iroha-cli,libs,/usr/include/x86_64-linux-gnu/c++/5