Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
15 changes: 14 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
common --enable_bzlmod

# CI-specific configuration
build:ci --loading_phase_threads=1
build:ci --jobs=2
build:ci --verbose_failures
build:ci --experimental_repository_cache_hardlinks
build:ci --repository_cache=~/.cache/bazel/_bazel_runner/cache/repos/v1
build:ci --disk_cache=~/.cache/bazel/_bazel_runner/cache/cas

build --enable_platform_specific_config
build --features=-supports_dynamic_linker
build --copt="-Wall"
build --copt="-Werror"
build --cxxopt="-std=c++17"
build --host_cxxopt="-std=c++17"
build:windows --copt=/wd4716
build:windows --cxxopt="/std:c++17"
build:windows --host_cxxopt="/std:c++17"

# Pass PATH variable from the environment
build --action_env=PATH
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
7.6.1
90 changes: 68 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,108 @@ on:
pull_request:
branches: [ main ]

permissions:
contents: read

jobs:
format:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Setup clang-format
run: |
git clone https://github.com/Sarcasm/run-clang-format.git
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Checkout clang-format
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: Sarcasm/run-clang-format
path: run-clang-format

- name: Run clang-format
run: find ./ -iname "*.h" -o -iname "*.cc" | xargs ./run-clang-format/run-clang-format.py

unit-test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- run: |
echo "/opt/llvm/bin" >> $GITHUB_PATH
- uses: actions/checkout@v3
- name: Run bazel test with GCC c++11
run: |
bazel test --test_output=all --cxxopt=-std=c++0x //...

- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

# Cache Bazel repository cache
- name: Cache Bazel repository cache
uses: actions/cache@v3
with:
path: ~/.cache/bazel/_bazel_runner/cache/repos/v1
key: bazel-repo-cache-${{ runner.os }}-${{ hashFiles('MODULE.bazel', 'WORKSPACE', 'WORKSPACE.bzlmod') }}
restore-keys: |
bazel-repo-cache-${{ runner.os }}-

# Cache Bazel build outputs
- name: Cache Bazel build cache
uses: actions/cache@v3
with:
path: ~/.cache/bazel
key: bazel-build-cache-${{ runner.os }}-${{ github.sha }}
restore-keys: |
bazel-build-cache-${{ runner.os }}-${{ github.base_ref }}
bazel-build-cache-${{ runner.os }}-

- name: Run bazel test with GCC c++17
run: |
bazel test --test_output=all --cxxopt=-std=c++17 //...
- name: Run bazel test with CLANG c++11
run: |
bazel test --test_output=all -c dbg --config=clang --cxxopt=-std=c++0x //...
bazel test --config=ci --test_output=all //...

- name: Run bazel test with CLANG c++17
run: |
bazel test --test_output=all -c opt --config=clang --cxxopt=-std=c++17 //...
- name: Install cmake dependencies and run cmake compile
bazel test --config=ci --test_output=all -c opt --config=clang //...

- name: Checkout skywalking-data-collect-protocol
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: apache/skywalking-data-collect-protocol
ref: a9ee9b1b2b9b3e74a152ebb8b61aac50934ac9ed
path: 3rdparty/skywalking-data-collect-protocol

- name: Checkout grpc
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: grpc/grpc
ref: v1.74.1
path: grpc
submodules: true

- name: Install cmake
run: |
sudo apt update && sudo apt -y install cmake build-essential

- name: Build grpc
run: |
sudo apt update
sudo apt -y install cmake
sudo git clone -b v9.1.0 https://github.com/apache/skywalking-data-collect-protocol.git ./3rdparty/skywalking-data-collect-protocol
sudo git clone -b v1.46.6 https://github.com/grpc/grpc.git --recursive
sudo cmake -S ./grpc -B ./grpc/build
sudo cmake --build ./grpc/build --parallel 8 --target install

- name: Build main project
run: |
sudo cmake -S . -B ./build
sudo cmake --build ./build

- name: Install lcov and genhtml and link llvm
run: |
sudo apt update
sudo apt -y install lcov
sudo ln -s /usr/bin/llvm-profdata-11 /usr/bin/llvm-profdata
sudo ln -s /usr/bin/llvm-cov-11 /usr/bin/llvm-cov

- name: Run coverage test
run: |
./coverage.sh

e2e-test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Prepare service container
run: |
docker compose -f test/e2e/docker/docker-compose.yml up -d

- name: Run e2e
run: |
sleep 10
Expand Down
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@
# user's bazel configuration files
user.bazelrc

# bazel artifacts
/bazel-bin
/bazel-out
/bazel-cpp2sky
/bazel-testlogs
# Ignore links to Bazel's output. The pattern needs the `*` because people can change the name of the directory into which your repository is cloned (changing the `bazel-<workspace_name>` symlink), and must not end with a trailing `/` because it's a symlink on macOS/Linux.
/bazel-*
MODULE.bazel.lock

# editor settings
.vscode/
Expand All @@ -51,8 +49,6 @@ coverage_report
### Automatically added by Hedron's Bazel Compile Commands Extractor: https://github.com/hedronvision/bazel-compile-commands-extractor
# Ignore the `external` link (that is added by `bazel-compile-commands-extractor`). The link differs between macOS/Linux and Windows, so it shouldn't be checked in. The pattern must not end with a trailing `/` because it's a symlink on macOS/Linux.
/external
# Ignore links to Bazel's output. The pattern needs the `*` because people can change the name of the directory into which your repository is cloned (changing the `bazel-<workspace_name>` symlink), and must not end with a trailing `/` because it's a symlink on macOS/Linux.
/bazel-*
# Ignore generated output. Although valuable (after all, the primary purpose of `bazel-compile-commands-extractor` is to produce `compile_commands.json`!), it should not be checked in.
/compile_commands.json
# Ignore the directory in which `clangd` stores its local index.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(POLICY CMP0091)
endif()

project(cpp2sky
VERSION 0.5.1
VERSION 0.6.1
DESCRIPTION "Distributed tracing and monitor SDK in CPP for Apache SkyWalking APM"
HOMEPAGE_URL "https://github.com/SkyAPM/cpp2sky"
)
Expand Down
27 changes: 27 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module(
name = "cpp2sky",
version = "0.6.1-dev",
)

bazel_dep(name = "abseil-cpp", version = "20250512.1", repo_name = "com_google_absl")
bazel_dep(name = "fmt", version = "8.1.1", repo_name = "com_github_fmtlib_fmt")
bazel_dep(name = "grpc", version = "1.74.1", repo_name = "com_github_grpc_grpc")
bazel_dep(name = "cpp-httplib", version = "0.22.0", repo_name = "com_github_httplib")
bazel_dep(name = "protobuf", version = "32.0", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_cc", version = "0.2.2")
bazel_dep(name = "skywalking-data-collect-protocol", repo_name = "skywalking_data_collect_protocol")
git_override(
module_name = "skywalking-data-collect-protocol",
commit = "a9ee9b1b2b9b3e74a152ebb8b61aac50934ac9ed",
remote = "https://github.com/apache/skywalking-data-collect-protocol.git",
)

bazel_dep(name = "spdlog", version = "1.10.0", repo_name = "com_github_gabime_spdlog")

bazel_dep(name = "googletest", version = "1.17.0", dev_dependency = True, repo_name = "com_google_googletest")
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
commit = "abb61a688167623088f8768cc9264798df6a9d10",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
)
10 changes: 4 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ load("//bazel:repositories.bzl", "cpp2sky_dependencies")

cpp2sky_dependencies()

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

grpc_deps()
Expand All @@ -18,6 +12,10 @@ load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

grpc_extra_deps()

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")

hedron_compile_commands_setup()
1 change: 1 addition & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspace(name = "cpp2sky")
2 changes: 1 addition & 1 deletion bazel/fmtlib.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@rules_cc//cc:defs.bzl", "cc_library")
licenses(["notice"]) # Apache 2

cc_library(
name = "fmtlib",
name = "fmt",
hdrs = glob([
"include/fmt/*.h",
]),
Expand Down
53 changes: 21 additions & 32 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def cpp2sky_dependencies():
rules_proto()
skywalking_data_collect_protocol()
com_github_grpc_grpc()
com_google_googletest()
Expand All @@ -15,54 +14,44 @@ def cpp2sky_dependencies():
def skywalking_data_collect_protocol():
http_archive(
name = "skywalking_data_collect_protocol",
sha256 = "4cf7cf84a9478a09429a7fbc6ad1e1b10c70eb54999438a36eacaf539a39d343",
sha256 = "50f760006df9d3dec4426a190b9d5c1dfe2c723728d19a63393e6a0f63e7d824",
urls = [
"https://github.com/apache/skywalking-data-collect-protocol/archive/v9.1.0.tar.gz",
"https://github.com/apache/skywalking-data-collect-protocol/archive/a9ee9b1b2b9b3e74a152ebb8b61aac50934ac9ed.tar.gz",
],
strip_prefix = "skywalking-data-collect-protocol-9.1.0",
strip_prefix = "skywalking-data-collect-protocol-a9ee9b1b2b9b3e74a152ebb8b61aac50934ac9ed",
)

def com_github_grpc_grpc():
http_archive(
name = "com_github_grpc_grpc",
sha256 = "1ccc2056b68b81ada8df61310e03dfa0541c34821fd711654d0590a7321db9c8",
urls = ["https://github.com/grpc/grpc/archive/a3ae8e00a2c5553c806e83fae83e33f0198913f0.tar.gz"],
strip_prefix = "grpc-a3ae8e00a2c5553c806e83fae83e33f0198913f0",
)

def rules_proto():
http_archive(
name = "rules_proto",
sha256 = "66bfdf8782796239d3875d37e7de19b1d94301e8972b3cbd2446b332429b4df1",
strip_prefix = "rules_proto-4.0.0",
urls = [
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz",
],
sha256 = "7bf97c11cf3808d650a3a025bbf9c5f922c844a590826285067765dfd055d228",
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.74.1.tar.gz"],
strip_prefix = "grpc-1.74.1",
)

def com_google_googletest():
http_archive(
name = "com_google_googletest",
sha256 = "7897bfaa5ad39a479177cfb5c3ce010184dbaee22a7c3727b212282871918751",
strip_prefix = "googletest-a4ab0abb93620ce26efad9de9296b73b16e88588",
urls = ["https://github.com/google/googletest/archive/a4ab0abb93620ce26efad9de9296b73b16e88588.tar.gz"],
sha256 = "65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c",
strip_prefix = "googletest-1.17.0",
urls = ["https://github.com/google/googletest/releases/download/v1.17.0/googletest-1.17.0.tar.gz"],
)

def com_google_protobuf():
http_archive(
name = "com_google_protobuf",
sha256 = "89ac31a93832e204db6d73b1e80f39f142d5747b290f17340adce5be5b122f94",
strip_prefix = "protobuf-3.19.4",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protobuf-cpp-3.19.4.tar.gz"],
sha256 = "3ad017543e502ffaa9cd1f4bd4fe96cf117ce7175970f191705fa0518aff80cd",
strip_prefix = "protobuf-32.0",
urls = ["https://github.com/google/protobuf/archive/refs/tags/v32.0.tar.gz"],
)

def com_github_httplib():
http_archive(
name = "com_github_httplib",
sha256 = "0e424f92b607fc9245c144dada85c2e97bc6cc5938c0c69a598a5b2a5c1ab98a",
strip_prefix = "cpp-httplib-0.7.15",
sha256 = "fcfea48c8f2c386e7085ef8545c8a4875efa30fa6d5cf9dd31f03c6ad038da9d",
strip_prefix = "cpp-httplib-0.22.0",
build_file = "//bazel:httplib.BUILD",
urls = ["https://github.com/yhirose/cpp-httplib/archive/v0.7.15.tar.gz"],
urls = ["https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.22.0.tar.gz"],
)

def com_github_fmtlib_fmt():
Expand All @@ -77,18 +66,18 @@ def com_github_fmtlib_fmt():
def com_github_gabime_spdlog():
http_archive(
name = "com_github_gabime_spdlog",
sha256 = "6fff9215f5cb81760be4cc16d033526d1080427d236e86d70bb02994f85e3d38",
strip_prefix = "spdlog-1.9.2",
sha256 = "697f91700237dbae2326b90469be32b876b2b44888302afbc7aceb68bcfe8224",
strip_prefix = "spdlog-1.10.0",
build_file = "//bazel:spdlog.BUILD",
urls = ["https://github.com/gabime/spdlog/archive/v1.9.2.tar.gz"],
urls = ["https://github.com/gabime/spdlog/archive/refs/tags/v1.10.0.tar.gz"],
)

def com_google_abseil():
http_archive(
name = "com_google_absl",
sha256 = "5ca73792af71ab962ee81cdf575f79480704b8fb87e16ca8f1dc1e9b6822611e",
strip_prefix = "abseil-cpp-6f43f5bb398b6685575b36874e36cf1695734df1",
urls = ["https://github.com/abseil/abseil-cpp/archive/6f43f5bb398b6685575b36874e36cf1695734df1.tar.gz"],
sha256 = "9b7a064305e9fd94d124ffa6cc358592eb42b5da588fb4e07d09254aa40086db",
strip_prefix = "abseil-cpp-20250512.1",
urls = ["https://github.com/abseil/abseil-cpp/releases/download/20250512.1/abseil-cpp-20250512.1.tar.gz"],
)

def hedron_compile_commands():
Expand Down
2 changes: 1 addition & 1 deletion bazel/spdlog.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ cc_library(
defines = ["SPDLOG_FMT_EXTERNAL"],
includes = ["include"],
visibility = ["//visibility:public"],
deps = ["@com_github_fmtlib_fmt//:fmtlib"],
deps = ["@com_github_fmtlib_fmt//:fmt"],
)
4 changes: 2 additions & 2 deletions cmake/grpc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ elseif(GRPC_FETCHCONTENT)
include(FetchContent)
FetchContent_Declare(
grpc
URL https://github.com/grpc/grpc/archive/a3ae8e00a2c5553c806e83fae83e33f0198913f0.tar.gz
URL_HASH SHA256=1ccc2056b68b81ada8df61310e03dfa0541c34821fd711654d0590a7321db9c8
URL https://github.com/grpc/grpc/archive/refs/tags/v1.74.1.tar.gz
URL_HASH SHA256=7bf97c11cf3808d650a3a025bbf9c5f922c844a590826285067765dfd055d228
)
FetchContent_MakeAvailable(grpc)

Expand Down
2 changes: 1 addition & 1 deletion cmake/httplib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ elseif(HTTPLIB_FETCHCONTENT)
include(add_FetchContent_MakeAvailable.cmake)
endif()

set(HTTPLIB_GIT_TAG v0.7.15)
set(HTTPLIB_GIT_TAG v0.22.0)
set(HTTPLIB_GIT_URL https://github.com/yhirose/cpp-httplib.git)

FetchContent_Declare(
Expand Down
2 changes: 1 addition & 1 deletion cmake/spdlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ elseif(SPDLOG_FETCHCONTENT)
include(add_FetchContent_MakeAvailable.cmake)
endif()

set(SPDLOG_GIT_TAG v1.9.2)
set(SPDLOG_GIT_TAG v1.10.0)
set(SPDLOG_GIT_URL https://github.com/gabime/spdlog.git)

FetchContent_Declare(
Expand Down
Loading
Loading