From 86d20c43e886619012a316d375ada23ac51b6f10 Mon Sep 17 00:00:00 2001 From: Qianxi Chen <53324229+qianxichen233@users.noreply.github.com> Date: Thu, 19 Sep 2024 07:03:43 +0800 Subject: [PATCH 1/3] Setup circleCI and clang-tidy --- .circleci/config.yml | 55 ++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 8 +++++++ 2 files changed, 63 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..fffc79d517 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,55 @@ +version: 2.1 + +executors: + docker-executor: + docker: + - image: cimg/base:stable + +jobs: + build: + executor: docker-executor + steps: + - checkout + - run: + name: Install Dependencies + command: | + sudo apt-get update + sudo apt-get install -y clang-tidy + sudo apt-get install -y python3 + [ -x "$(command -v python)" ] || ln -s $(command -v python3) /usr/bin/python + - run: + name: Build Project + command: | + cmake -Bbuild-cmake + cmake --build build-cmake + - persist_to_workspace: + root: . + paths: + - build-cmake + + test: + executor: docker-executor + steps: + - checkout + - attach_workspace: + at: . + - run: + name: Run Tests + command: | + ./build-cmake/ninja_test + ./build-cmake/build_log_perftest + ./build-cmake/canon_perftest + ./build-cmake/clparser_perftest + ./build-cmake/depfile_parser_perftest + ./build-cmake/elide_middle_perftest + ./build-cmake/hash_collision_bench + ./build-cmake/manifest_parser_perftest + +workflows: + version: 2 + build_and_test: + jobs: + - build + - test: + requires: + - build diff --git a/CMakeLists.txt b/CMakeLists.txt index 47b1f9c117..6e35449692 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,14 @@ cmake_minimum_required(VERSION 3.15) include(CheckSymbolExists) include(CheckIPOSupported) +# Config clang-tidy +find_program(CLANG_TIDY_EXE NAMES clang-tidy) +if(CLANG_TIDY_EXE) + set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}") +else() + message(WARNING "clang-tidy not found!") +endif() + option(NINJA_BUILD_BINARY "Build ninja binary" ON) option(NINJA_FORCE_PSELECT "Use pselect() even on platforms that provide ppoll()" OFF) From e2c4180a2018857d0da7113aeb10210b745e7172 Mon Sep 17 00:00:00 2001 From: Shihui Huang Date: Fri, 8 Nov 2024 23:54:25 -0500 Subject: [PATCH 2/3] create docker image & test parallelism Use ctest and clang-format Remove add_executable and add_test Add other tests to ctest Fix failed tests Fix test dir Adjust tests: depfile_parser, manifest_parser Set up docker image, use ctest, clang-tidy and parallel testing --- .circleci/config.yml | 26 +++++++++----------------- CMakeLists.txt | 8 ++++++++ Dockerfile | 10 ++++++++++ 3 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml index fffc79d517..68a03e73b9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,47 +3,39 @@ version: 2.1 executors: docker-executor: docker: - - image: cimg/base:stable + - image: cloudcomputing321/ninja-image:latest jobs: build: executor: docker-executor steps: - checkout - - run: - name: Install Dependencies - command: | - sudo apt-get update - sudo apt-get install -y clang-tidy - sudo apt-get install -y python3 - [ -x "$(command -v python)" ] || ln -s $(command -v python3) /usr/bin/python - run: name: Build Project command: | cmake -Bbuild-cmake cmake --build build-cmake + - run: + name: Run clang-format + command: | + find . -iname '*.cpp' -o -iname '*.h' | xargs clang-format --dry-run - persist_to_workspace: root: . paths: - build-cmake test: + parallelism: 4 executor: docker-executor steps: - checkout - attach_workspace: at: . - run: - name: Run Tests + name: Run Tests In Parallelism with CTests command: | - ./build-cmake/ninja_test - ./build-cmake/build_log_perftest - ./build-cmake/canon_perftest - ./build-cmake/clparser_perftest - ./build-cmake/depfile_parser_perftest - ./build-cmake/elide_middle_perftest - ./build-cmake/hash_collision_bench - ./build-cmake/manifest_parser_perftest + cd build-cmake + ctest --verbose -j4 workflows: version: 2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e35449692..dca3926a03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 3.15) include(CheckSymbolExists) include(CheckIPOSupported) +# Enable testing +enable_testing() + # Config clang-tidy find_program(CLANG_TIDY_EXE NAMES clang-tidy) if(CLANG_TIDY_EXE) @@ -320,6 +323,11 @@ if(BUILD_TESTING) endif() add_test(NAME NinjaTest COMMAND ninja_test) + add_test(NAME build_log_perftest COMMAND build_log_perftest) + add_test(NAME canon_perftest COMMAND canon_perftest) + add_test(NAME clparser_perftest COMMAND clparser_perftest) + add_test(NAME elide_middle_perftest COMMAND elide_middle_perftest) + add_test(NAME hash_collision_bench COMMAND hash_collision_bench) endif() if(NINJA_BUILD_BINARY) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..2b82ed15bb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +# Use a base image +FROM cimg/base:stable + +USER root + +# Install clang-tidy and python3 +RUN apt-get update && \ + apt-get install -y clang-tidy clang-format python3 && \ + apt-get clean && rm -rf /var/lib/apt/lists/* +RUN [ -x "$(command -v python)" ] || ln -s $(command -v python3) /usr/bin/python \ No newline at end of file From a9cfdec2239137d46542009cac4f72c2fa6f8bfe Mon Sep 17 00:00:00 2001 From: Shihui Huang Date: Mon, 18 Nov 2024 13:40:15 -0500 Subject: [PATCH 3/3] Add store_test_results to integrate with circleci Fix no test result found fix test results dir Try output test results to circleci test write to test-results debug test results directory debug results.xml path Adjust docker image and use `store_test_results` in circleCI debug cmake version issue check cmake version Use new base image for new cmake version to output test results to ui Rerun with new docker image Use `store_test_results` to upload and store test results in circleCI --- .circleci/config.yml | 8 +++++--- Dockerfile | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 68a03e73b9..0b06da20a2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 executors: docker-executor: docker: - - image: cloudcomputing321/ninja-image:latest + - image: cloudcomputing321/shadowdash:latest jobs: build: @@ -35,7 +35,9 @@ jobs: name: Run Tests In Parallelism with CTests command: | cd build-cmake - ctest --verbose -j4 + ctest --output-junit results.xml --verbose -j4 + - store_test_results: + path: build-cmake workflows: version: 2 @@ -44,4 +46,4 @@ workflows: - build - test: requires: - - build + - build \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2b82ed15bb..17810e1e32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use a base image -FROM cimg/base:stable +FROM cimg/base:current USER root