Skip to content
Merged
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
20 changes: 15 additions & 5 deletions .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 All @@ -18,17 +31,14 @@ coverage --build_tests_only
build:coverage --config=clang
build:coverage --action_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=1
build:coverage --action_env=GCOV=llvm-profdata
build:coverage --action_env=LLVM_COV=llvm-cov
build:coverage --combined_report=lcov
build:coverage --experimental_use_llvm_covmap
build:coverage --experimental_generate_llvm_lcov
build:coverage --collect_code_coverage
build:coverage --instrumentation_filter="//source[/:],//cpp2sky[/:]"
build:coverage --coverage_support=@cpp2sky//bazel/coverage:coverage_support
build:coverage --test_env=CC_CODE_COVERAGE_SCRIPT=external/cpp2sky/bazel/coverage/collect_cc_coverage.sh
build:coverage --strategy=TestRunner=local
build:coverage --strategy=CoverageReport=local
build:coverage --experimental_use_llvm_covmap
build:coverage --collect_code_coverage
build:coverage --test_tag_filters=-nocoverage

try-import %workspace%/user.bazelrc
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
148 changes: 113 additions & 35 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,140 @@ on:
pull_request:
branches: [ main ]

permissions:
contents: read

env:
GRPC_VERSION: v1.74.1
SKYWALKING_PROTOCOL_REF: a9ee9b1b2b9b3e74a152ebb8b61aac50934ac9ed

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 //...
- 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 //...
- name: Run bazel test with CLANG c++17
- run: echo "/opt/llvm/bin" >> $GITHUB_PATH

- 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
run: bazel test --config=ci --test_output=all //...

- name: Run bazel test with CLANG
run: bazel test --config=ci --test_output=all -c opt --config=clang //...

# TODO: enable when fixed
# - name: Install lcov and genhtml and link llvm
# run: |
# sudo apt-get update
# sudo apt-get install -y lcov lld
# sudo ln -s /usr/bin/llvm-profdata-16 /usr/bin/llvm-profdata
# sudo ln -s /usr/bin/llvm-cov-16 /usr/bin/llvm-cov

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

cmake-build:
runs-on: ubuntu-22.04
steps:
- run: echo "/opt/llvm/bin" >> $GITHUB_PATH

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

- name: Generate dependencies hash
id: deps-hash
run: |
bazel test --test_output=all -c opt --config=clang --cxxopt=-std=c++17 //...
# Create a hash from dependency names and versions
DEPS_STRING="grpc:${{ env.GRPC_VERSION }}|skywalking:${{ env.SKYWALKING_PROTOCOL_REF }}"
DEPS_HASH=$(echo -n "$DEPS_STRING" | sha256sum | cut -c1-8)
echo "hash=$DEPS_HASH" >> $GITHUB_OUTPUT
echo "Dependencies hash (first 8 chars): $DEPS_HASH"

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

# Cache gRPC build
- name: Cache gRPC build
uses: actions/cache@v3
with:
path: |
grpc/build
/usr/local/lib/libgrpc*
/usr/local/lib/libprotobuf*
/usr/local/lib/cmake/grpc
/usr/local/lib/cmake/protobuf
/usr/local/include/grpc*
/usr/local/include/google/protobuf
/usr/local/bin/grpc_*
/usr/local/bin/protoc
key: grpc-cmake-${{ runner.os }}-${{ steps.deps-hash.outputs.hash }}-${{ hashFiles('CMakeLists.txt', 'cmake/grpc.cmake') }}
restore-keys: |
grpc-cmake-${{ runner.os }}-${{ steps.deps-hash.outputs.hash }}-
grpc-cmake-${{ runner.os }}-

- name: Checkout grpc
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: grpc/grpc
ref: ${{ env.GRPC_VERSION }}
path: grpc
submodules: true

- name: Install cmake dependencies and run cmake compile
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 apt-get update
sudo apt-get install -y cmake build-essential
sudo cmake -S ./grpc -B ./grpc/build
sudo cmake --build ./grpc/build --parallel 8 --target install
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
15 changes: 8 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 @@ -48,11 +46,14 @@ compile_commands.json

coverage_report

# CMake build directories and dependencies
build/
3rdparty/
grpc/

### 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
4 changes: 2 additions & 2 deletions 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 All @@ -19,7 +19,7 @@ option(GENERATE_CPP2SKY_PKGCONFIG "Generate and install pkg-config files for UN


if(OVERRIDE_CXX_STANDARD_FLAGS)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()

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")
6 changes: 0 additions & 6 deletions bazel/coverage/BUILD

This file was deleted.

Loading
Loading