fix #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: [push, pull_request] | |
permissions: | |
contents: read | |
jobs: | |
build-and-test: | |
name: >- | |
CI | |
${{ matrix.os }} | |
${{ matrix.compiler }} | |
${{ matrix.build_tool}} | |
unittest ${{ matrix.with_test }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
compiler: [clang, gcc] | |
os: [ubuntu-20.04] | |
build_tool: [cmake, bazel] | |
with_test: [true, false] | |
exclude: | |
# Not support test using bazel | |
- build_tool: bazel | |
with_test: true | |
- build_tool: cmake | |
with_test: false | |
include: | |
- compiler: clang | |
CC: clang | |
CXX: clang++ | |
- compiler: gcc | |
CC: gcc | |
CXX: g++ | |
env: | |
CMAKE_BUILD_DIR: ${{ github.workspace }}/bld | |
CC: ${{ matrix.CC }} | |
CXX: ${{ matrix.CXX }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: true | |
- name: Install dependencies on Linux | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -qq libgflags-dev \ | |
libprotobuf-dev libprotoc-dev protobuf-compiler \ | |
libleveldb-dev libgoogle-perftools-dev lcov | |
sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo env "PATH=$PATH" cmake . && sudo make && sudo mv ./lib/libgtest* /usr/lib/ | |
- name: Install bazel | |
if: ${{ matrix.build_tool == 'bazel' }} | |
run: | | |
sudo apt-get install python-dev | |
wget https://github.com/bazelbuild/bazel/releases/download/0.25.2/bazel-0.25.2-installer-linux-x86_64.sh | |
chmod a+x bazel-0.25.2-installer-linux-x86_64.sh | |
./bazel-0.25.2-installer-linux-x86_64.sh --user | |
export PATH="$PATH:$HOME/bin" | |
- name: Build with cmake | |
if: ${{ matrix.build_tool == 'cmake' }} | |
run: | | |
cmake -S "${{ github.workspace }}" -B "${{ env.CMAKE_BUILD_DIR }}" -DWITH_TESTS=ON -DWITH_COVERAGE=ON | |
cmake --build bld --parallel 16 -- brpc-static | |
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --parallel 16 | |
- name: Build with bazel | |
if: ${{ matrix.build_tool == 'bazel' }} | |
run: | | |
~/.bazel/bin/bazel build -c opt --copt -DHAVE_ZLIB=1 //... | |
- name: Run Tests | |
if: ${{ matrix.with_test }} | |
id: test-braft | |
working-directory: ${{ github.workspace }}/bld/test | |
run: | | |
ulimit -c unlimited -S | |
# sh ../../test/run_tests.sh | |
./test_ballot | |
- name: Coverage | |
if: ${{ matrix.with_test && matrix.compiler == 'gcc' }} | |
working-directory: ${{ github.workspace }} | |
run: | | |
# generate coverage report | |
lcov --capture --directory . --output-file coverage.info --no-external | |
# only keep braft/src files | |
lcov --extract coverage.info 'braft/src/*' --output-file coverage.info | |
# report | |
lcov --list coverage.info | |
- uses: actions/checkout@master | |
- uses: codecov/codecov-action@v4 | |
if: ${{ matrix.with_test && matrix.compiler == 'gcc' }} | |
with: | |
fail_ci_if_error: true # optional (default = false) | |
files: ./coverage.info # optional | |
name: codecov-umbrella # optional | |
token: ${{ secrets.CODECOV_TOKEN }} # required | |
verbose: true # optional (default = false) | |
- name: Collect failure info | |
if: ${{ steps.test-braft.conclusion == 'failure'}} | |
run: | | |
COREFILE=$(find . -maxdepth 1 -name "core*" | head -n 1) | |
gdb -c "$COREFILE" example -ex "thread apply all bt" -ex "set pagination 0" -batch |