Skip to content
Open
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
472 changes: 472 additions & 0 deletions .github/scripts/flatbuffers-on.py

Large diffs are not rendered by default.

362 changes: 362 additions & 0 deletions .github/scripts/test_flatbuffers_on.py

Large diffs are not rendered by default.

161 changes: 161 additions & 0 deletions .github/workflows/flatbuffers-on.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: FlatBuffers ON

on:
push:
branches: [master]
paths:
- 'src/brpc/flatbuffers/**'
- 'src/brpc/policy/flatbuffers_protocol.*'
- 'src/brpc/channel.*'
- 'src/brpc/controller.*'
- 'src/brpc/server.*'
- 'src/brpc/global.cpp'
- 'src/brpc/options.proto'
- 'src/brpc/details/*_private_accessor.h'
- 'test/*flatbuffers*'
- 'test/CMakeLists.txt'
- 'test/Makefile'
- 'test/BUILD.bazel'
- 'tools/flatbuffers/**'
- 'example/benchmark_fb/**'
- 'CMakeLists.txt'
- 'src/**/CMakeLists.txt'
- 'Makefile'
- 'config_brpc.sh'
- 'BUILD.bazel'
- 'MODULE.bazel'
- 'WORKSPACE'
- '.github/scripts/*flatbuffers*'
- '.github/workflows/flatbuffers-on.yml'
pull_request:
paths:
- 'src/brpc/flatbuffers/**'
- 'src/brpc/policy/flatbuffers_protocol.*'
- 'src/brpc/channel.*'
- 'src/brpc/controller.*'
- 'src/brpc/server.*'
- 'src/brpc/global.cpp'
- 'src/brpc/options.proto'
- 'src/brpc/details/*_private_accessor.h'
- 'test/*flatbuffers*'
- 'test/CMakeLists.txt'
- 'test/Makefile'
- 'test/BUILD.bazel'
- 'tools/flatbuffers/**'
- 'example/benchmark_fb/**'
- 'CMakeLists.txt'
- 'src/**/CMakeLists.txt'
- 'Makefile'
- 'config_brpc.sh'
- 'BUILD.bazel'
- 'MODULE.bazel'
- 'WORKSPACE'
- '.github/scripts/*flatbuffers*'
- '.github/workflows/flatbuffers-on.yml'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build-test:
name: FB ON (${{ matrix.os }}, ${{ matrix.system }}, ${{ matrix.compiler }})
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
max-parallel: 2
matrix:
include:
- {os: ubuntu-22.04, system: cmake, compiler: gcc, cc: gcc, cxx: g++, cache: ccache}
- {os: ubuntu-22.04, system: cmake, compiler: clang, cc: clang, cxx: clang++, cache: ccache}
- {os: ubuntu-22.04, system: make, compiler: gcc, cc: gcc, cxx: g++, cache: ccache}
- {os: ubuntu-22.04, system: make, compiler: clang, cc: clang, cxx: clang++, cache: ccache}
- {os: ubuntu-22.04, system: bazel, compiler: gcc, cc: gcc, cxx: g++, cache: bazel}
- {os: macos-latest, system: cmake, compiler: apple-clang, cc: clang, cxx: clang++, cache: ccache}
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
BUILD_SYSTEM: ${{ matrix.system }}
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false

# The runner context is unavailable in job-level env, so derive the work
# directory here for the remaining steps.
- name: Set the work directory
shell: bash
run: echo "FB_WORK=$RUNNER_TEMP/brpc-fb-${{ matrix.system }}-${{ matrix.compiler }}" >> "$GITHUB_ENV"

- name: Validate the gate's report checks
run: python3 .github/scripts/test_flatbuffers_on.py

- name: Install focused Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential cmake ninja-build clang ccache pkg-config python3 curl ca-certificates git \
libssl-dev libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler \
libleveldb-dev zlib1g-dev

# libgoogle-perftools-dev cannot be installed on the runner image (unmet
# libunwind-dev), so build gperftools as ci-linux.yml does. Bazel uses
# its own gperftools module.
- name: Build isolated Gperftools
if: runner.os == 'Linux' && matrix.system != 'bazel'
shell: bash
run: |
archive="$RUNNER_TEMP/gperftools-2.16.tar.gz"
curl --fail --location --retry 3 \
https://github.com/gperftools/gperftools/releases/download/gperftools-2.16/gperftools-2.16.tar.gz \
--output "$archive"
printf '%s %s\n' f12624af5c5987f2cc830ee534f754c3c5961eec08004c26a8b80de015cf056f "$archive" | sha256sum --check
tar -xzf "$archive" -C "$RUNNER_TEMP"
cd "$RUNNER_TEMP/gperftools-2.16"
./configure --prefix="$RUNNER_TEMP/gperftools-install" \
--enable-frame-pointers --disable-libunwind
make -j2
make install
echo "FB_GPERFTOOLS=$RUNNER_TEMP/gperftools-install" >> "$GITHUB_ENV"

- name: Install focused macOS dependencies
if: runner.os == 'macOS'
run: brew install cmake ninja pkg-config openssl@3 gflags leveldb protobuf@29 abseil gperftools

- uses: ./.github/actions/setup-build-cache
with:
kind: ${{ matrix.cache }}
cache-key: fb-on-${{ matrix.system }}-${{ matrix.compiler }}

- name: Build and run the FB ON gates
shell: bash
run: |
args=(--build-system "$BUILD_SYSTEM" --work "$FB_WORK" --jobs 2)
if [[ "$RUNNER_OS" == macOS ]]; then
# Same layout as master's ci-macos.yml: the keg-only protobuf@29
# first, then the shared Homebrew prefix for everything else.
# Per-formula Cellar prefixes would leave abseil, which
# protobuf@29 headers include, off the include path.
args+=(--dependency-prefix "$(brew --prefix protobuf@29)")
args+=(--dependency-prefix "$(brew --prefix)")
args+=(--protoc "$(brew --prefix protobuf@29)/bin/protoc")
fi
if [[ -n "${FB_GPERFTOOLS:-}" ]]; then
args+=(--dependency-prefix "$FB_GPERFTOOLS")
fi
python3 .github/scripts/flatbuffers-on.py "${args[@]}"

- name: Upload commands, logs and test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: flatbuffers-on-${{ matrix.os }}-${{ matrix.system }}-${{ matrix.compiler }}
path: ${{ env.FB_WORK }}/evidence/
if-no-files-found: warn
retention-days: 14
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
/test/output
build/

# Ignore hidden files
# Ignore hidden files, but keep GitHub workflows and helpers discoverable.
.*
!/.github/
/.github/scripts/__pycache__/
*.swp

# Ignore auto-generated files
Expand Down
5 changes: 4 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,10 @@ brpc_proto_library(
visibility = ["//visibility:public"],
)

FLATBUFFERS_SRC_PATTERNS = ["src/brpc/flatbuffers/*.cpp"]
FLATBUFFERS_SRC_PATTERNS = [
"src/brpc/flatbuffers/*.cpp",
"src/brpc/policy/flatbuffers_protocol.cpp",
]

URMA_SRC_PATTERNS = [
"src/brpc/urma/*.cpp",
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ option(WITH_MESALINK "With MesaLink" OFF)
option(WITH_BORINGSSL "With BoringSSL" OFF)
option(WITH_DEBUG_SYMBOLS "With debug symbols" ON)
option(WITH_THRIFT "With thrift framed protocol supported" OFF)
option(WITH_FLATBUFFERS "With FlatBuffers message support (headers only)" OFF)
option(WITH_FLATBUFFERS "With FlatBuffers message and RPC support (headers only)" OFF)
option(WITH_BTHREAD_TRACER "With bthread tracer supported" OFF)
option(WITH_SNAPPY "With snappy" OFF)
option(WITH_RDMA "With RDMA" OFF)
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ BRPC_SOURCES_ALL = $(foreach d,$(BRPC_DIRS),$(wildcard $(addprefix $(d)/*,$(SRCE
ifeq ($(URMA_USE_MOCK),0)
BRPC_SOURCES_ALL := $(filter-out src/brpc/urma/mock_urma.cpp,$(BRPC_SOURCES_ALL))
endif
ifneq ($(WITH_FLATBUFFERS),1)
BRPC_SOURCES_ALL := $(filter-out src/brpc/policy/flatbuffers_protocol.cpp,$(BRPC_SOURCES_ALL))
endif
BRPC_SOURCES = $(filter-out $(THRIFT_SOURCES) $(EXCLUDE_SOURCES), $(BRPC_SOURCES_ALL))
BRPC_PROTOS = $(filter %.proto,$(BRPC_SOURCES))
BRPC_CFAMILIES = $(filter-out %.proto %.pb.cc,$(BRPC_SOURCES))
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ You can use it to:
* Read [overview](docs/en/overview.md) to know where bRPC can be used and its advantages.
* Read [getting started](docs/en/getting_started.md) for building steps and play with [examples](https://github.com/apache/brpc/tree/master/example/).
* Docs:
* [Enable FlatBuffers RPC and verify the example](docs/en/flatbuffers.md)
* [Performance benchmark](docs/en/benchmark.md)
* [bvar](docs/en/bvar.md)
* [bvar_c++](docs/en/bvar_c++.md)
Expand Down
1 change: 1 addition & 0 deletions README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* 通过[概述](docs/cn/overview.md)了解哪里可以用bRPC及其优势。
* 阅读[编译步骤](docs/cn/getting_started.md)了解如何开始使用, 之后可以运行一下[示例程序](https://github.com/apache/brpc/tree/master/example/).
* 文档:
* [启用 FlatBuffers RPC 并通过 example 验证](docs/cn/flatbuffers.md)
* [性能测试](docs/cn/benchmark.md)
* [bvar](docs/cn/bvar.md)
* [bvar_c++](docs/cn/bvar_c++.md)
Expand Down
Loading
Loading