From 14c9c82dabf2459887a2f1d80e56ac46a98ae5fc Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Sun, 12 Feb 2023 00:01:36 +0800 Subject: [PATCH] test: enhance ci (#62) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: enhance ci Signed-off-by: YdrMaster * typo: README.md Signed-off-by: YdrMaster * fix: typo in workflow files Signed-off-by: YdrMaster * test: ci 安装 protobuf Signed-off-by: YdrMaster * test: cache protobuf Signed-off-by: YdrMaster * docs: update README.md Signed-off-by: YdrMaster * test: ci 调试完成,恢复只在代码更新时执行 Signed-off-by: YdrMaster * test: ci 执行 cpu 上测试 Signed-off-by: YdrMaster * fix: action paths Signed-off-by: YdrMaster * build: 4 个 submodule 规范到发布版本号 > > 这个项目无法使用最新版因为每个次级版本号 api 都有变化,目前使用的是最接近原来版本的 v3.10.5 Signed-off-by: YdrMaster * typo: README.md Signed-off-by: YdrMaster * test: 扩大测试执行范围方便后续扩充检查范围 Signed-off-by: YdrMaster * docs: update README.md Signed-off-by: YdrMaster --------- Signed-off-by: YdrMaster --- .github/workflows/build.yml | 57 ++++++++++++++++++++++ .github/workflows/clang-format-check.yml | 9 +++- 3rd-party/backward-cpp | 2 +- 3rd-party/googletest | 2 +- 3rd-party/nlohmann_json_cmake_fetchcontent | 2 +- 3rd-party/pybind11 | 2 +- README.md | 27 ++++++++-- 7 files changed, 90 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..7117b1fa --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: Build and test cpu +on: + pull_request: + paths-ignore: + - '**.md' + - 'LICENSE' + +env: + protobuf_download: https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protobuf-cpp-3.21.12.tar.gz + protobuf_version: 3.21.12 + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Install libdw + run: sudo apt-get update && sudo apt-get install libdw-dev + + - name: Cache protobuf + id: cache-protobuf + uses: actions/cache@v3 + with: + path: protobuf-${{ env.protobuf_version }} + key: protobuf-${{ env.protobuf_version }} + + - name: Download and compile protobuf + if: steps.cache-protobuf.outputs.cache-hit != 'true' + run: | + wget ${{ env.protobuf_download }} + tar xf protobuf-cpp-${{ env.protobuf_version }}.tar.gz + cd protobuf-${{ env.protobuf_version }} + ./autogen.sh + ./configure CFLAGS="-fPIC" CXXFLAGS="-fPIC" + make -j2 + + - name: Install protobuf + run: | + cd protobuf-${{ env.protobuf_version }} + sudo make install + sudo ldconfig + + - name: Build + run: | + mkdir build + cd build + cmake .. + make -j2 + + - name: Test cpu + run: | + cd build + make test diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml index 24ba1a27..536c74b7 100644 --- a/.github/workflows/clang-format-check.yml +++ b/.github/workflows/clang-format-check.yml @@ -1,5 +1,10 @@ name: clang-format Check -on: [pull_request] +on: + pull_request: + paths-ignore: + - '**.md' + - 'LICENSE' + jobs: formatting-check: name: Formatting Check @@ -11,7 +16,7 @@ jobs: - 'src' - 'test' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run clang-format style check for C/C++/Protobuf programs. uses: jidicula/clang-format-action@v4.8.0 with: diff --git a/3rd-party/backward-cpp b/3rd-party/backward-cpp index f30744bc..3bb9240c 160000 --- a/3rd-party/backward-cpp +++ b/3rd-party/backward-cpp @@ -1 +1 @@ -Subproject commit f30744bcf726ea3735df7ecf9e9de9ddac540283 +Subproject commit 3bb9240cb15459768adb3e7d963a20e1523a6294 diff --git a/3rd-party/googletest b/3rd-party/googletest index e2239ee6..b796f7d4 160000 --- a/3rd-party/googletest +++ b/3rd-party/googletest @@ -1 +1 @@ -Subproject commit e2239ee6043f73722e7aa812a459f54a28552929 +Subproject commit b796f7d44681514f58a683a3a71ff17c94edb0c1 diff --git a/3rd-party/nlohmann_json_cmake_fetchcontent b/3rd-party/nlohmann_json_cmake_fetchcontent index 6aebf092..13132dd3 160000 --- a/3rd-party/nlohmann_json_cmake_fetchcontent +++ b/3rd-party/nlohmann_json_cmake_fetchcontent @@ -1 +1 @@ -Subproject commit 6aebf09233951e4ce30a63919186a70b2b195756 +Subproject commit 13132dd361c8c5b5753983d5186cf54f689d90f9 diff --git a/3rd-party/pybind11 b/3rd-party/pybind11 index 1e3400b6..0bd8896a 160000 --- a/3rd-party/pybind11 +++ b/3rd-party/pybind11 @@ -1 +1 @@ -Subproject commit 1e3400b6742288429f2069aaf5febf92d0662dae +Subproject commit 0bd8896a4010f2d91b2340570c24fa08606ec406 diff --git a/README.md b/README.md index 160b0b6e..8e109331 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,34 @@ # InfiniTensor ## Compilation on Lotus + ``` bash # Enter the root of InfiniTensor -source test/script/env_lotus.sh +source test/script/env_lotus.sh mkdir build && cd build cmake -DUSE_CUDA=ON .. && make -j 12 ``` +### CMake Options + +There are several configurable CMake options, see the [CMakeLists.txt file](/CMakeLists.txt#L5). + +- If `USE_BACKTRACE` is `ON`, `libdw-dev` have to be installed. See the README of [backward-cpp](https://github.com/bombela/backward-cpp) for details. +- If `USE_PROTOBUF` is `ON`, `protobuf` have to be installed. See the README of [protobuf](https://github.com/protocolbuffers/protobuf) for details. + ## Contributor Guide + InfiniTensor development is based on the pull request on Github. Before requesting for merging, a PR should satisfy the following requirements -1. Pass all tests. - 1. Currently, CI on Github only checks code format. Script `test/script/clang_format_inplace.sh` is for formatting all code. - 2. Contributors should run `ctest` manually and copy its output to the PR. Use fenced code blocks (triple backquotes, i.e., `` ``` ``) to avoid referencing in Github. Otherwise, `#` in the output is interpreted as a Github reference. Do not directly paste the ctest output in commit messages either for the same reason. -2. Receive at least one approval from reviewers. + +1. Pass all tests. + 1. Now CI on Github will test everything that can be tested in the ci environment, including code format. So, script `test/script/clang_format_inplace.sh` is for formatting all code. + 2. Contributors should run `ctest` manually and copy its output to the PR. Use fenced code blocks (triple backquotes, i.e., `` ``` ``) to avoid referencing in Github. Otherwise, `#` in the output is interpreted as a Github reference. Do not directly paste the ctest output in commit messages either for the same reason. +2. Receive at least one approval from reviewers. 3. PR title should be concise since it is going to be the commit message in the main branch after merging and squashing. + +## Dependencies + +- [backward-cpp](https://github.com/bombela/backward-cpp): [v1.6](https://github.com/bombela/backward-cpp/releases/tag/v1.6) +- [googletest](https://github.com/google/googletest): [v1.13.0](https://github.com/google/googletest/releases/tag/v1.13.0) +- [nlohmann_json_cmake_fetchcontent](https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent): [v3.10.5](https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent/releases/tag/v3.10.5) +- [pybind11](https://github.com/pybind/pybind11): [v2.10.3](https://github.com/pybind/pybind11/releases/tag/v2.10.3)