From 28c90ffb79e0c370c286dc53985693b105d41e9d Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Mon, 25 Mar 2024 10:32:15 -0700 Subject: [PATCH 1/5] Add support for bzlmod This adds support for bzlmod, which is bazel's new dependency resolution system. Theoretically we could now remove the previous dependency management configuration which required flattening all the dependencies, but I left it here for now for users using old versions of bazel. --- .bazelrc | 4 ++++ .gitignore | 1 + MODULE.bazel | 25 +++++++++++++++++++++++++ WORKSPACE.bzlmod | 4 ++++ 4 files changed, 34 insertions(+) create mode 100644 MODULE.bazel create mode 100644 WORKSPACE.bzlmod diff --git a/.bazelrc b/.bazelrc index fc170b0e8b..e067710ccc 100644 --- a/.bazelrc +++ b/.bazelrc @@ -16,6 +16,10 @@ build --copt -DGRPC_BAZEL_BUILD # Workaround abseil libraries missing symbols build:windows --dynamic_mode=off +# Avoid conflicting boringssl/protobuf system brew install +# https://github.com/bazelbuild/bazel/issues/10472 +build:macos --copt=-isystem/usr/local/include + # Set minimum supported C++ version build:macos --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 build:linux --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 diff --git a/.gitignore b/.gitignore index dc26aa2f82..cafefd636d 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ *.app # Bazel files +MODULE.bazel.lock /bazel-* # Mac diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000000..829ea0b0dc --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,25 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +module( + name = "opentelemetry-cpp", + version = "1.14.2", + compatibility_level = 0, + repo_name = "io_opentelemetry_cpp", +) + +bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "com_google_absl") +bazel_dep(name = "bazel_skylib", version = "1.5.0") +bazel_dep(name = "curl", version = "8.4.0") +bazel_dep(name = "grpc", version = "1.62.1", repo_name = "com_github_grpc_grpc") +bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json") +bazel_dep(name = "opentelemetry-proto", version = "1.1.0", repo_name = "com_github_opentelemetry_proto") +bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") +bazel_dep(name = "platforms", version = "0.0.8") +bazel_dep(name = "prometheus-cpp", version = "1.2.4", repo_name = "com_github_jupp0r_prometheus_cpp") +bazel_dep(name = "protobuf", version = "26.0", repo_name = "com_google_protobuf") +bazel_dep(name = "rules_proto", version = "5.3.0-21.7") +bazel_dep(name = "zlib", version = "1.3.1.bcr.1") + +bazel_dep(name = "google_benchmark", version = "1.8.3", dev_dependency = True, repo_name = "com_github_google_benchmark") +bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True, repo_name = "com_google_googletest") diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod new file mode 100644 index 0000000000..0db1b04622 --- /dev/null +++ b/WORKSPACE.bzlmod @@ -0,0 +1,4 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +# Disables the default WORKSPACE when using bzlmod From b842d167d5b9d3b4d3d05d126d671ba39db31818 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Wed, 12 Jun 2024 09:40:17 -0700 Subject: [PATCH 2/5] WORKSPACE CI --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ ci/do_ci.sh | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5834ca2fd4..af92fec742 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -537,6 +537,27 @@ jobs: - name: run tests run: ./ci/do_ci.sh bazel.test + bazel_no_bzlmod_test: + name: Bazel + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - name: Mount Bazel Cache + uses: actions/cache@v4 + env: + cache-name: bazel_cache + with: + path: /home/runner/.cache/bazel + key: bazel_test + - name: setup + run: | + sudo ./ci/setup_ci_environment.sh + sudo ./ci/install_bazelisk.sh + - name: run tests + run: ./ci/do_ci.sh bazel.no_bzlmod.test + bazel_test_async: name: Bazel with async export runs-on: ubuntu-latest diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 7855ed4175..efdac9e87e 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -459,6 +459,10 @@ EOF make load_plugin_example examples/plugin/load/load_plugin_example ${PLUGIN_DIR}/libexample_plugin.so /dev/null exit 0 +elif [[ "$1" == "bazel.no_bzlmod.test" ]]; then + bazel $BAZEL_STARTUP_OPTIONS build --enable_bzlmod=false $BAZEL_OPTIONS //... + bazel $BAZEL_STARTUP_OPTIONS test --enable_bzlmod=false $BAZEL_TEST_OPTIONS //... + exit 0 elif [[ "$1" == "bazel.test" ]]; then bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS //... bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_TEST_OPTIONS //... From 1e84d7f5fabb6f9a31ffdf535a5aaa15d69be4fd Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Wed, 12 Jun 2024 10:09:29 -0700 Subject: [PATCH 3/5] Discard changes to .bazelrc --- .bazelrc | 4 ---- .github/workflows/ci.yml | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.bazelrc b/.bazelrc index e067710ccc..fc170b0e8b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -16,10 +16,6 @@ build --copt -DGRPC_BAZEL_BUILD # Workaround abseil libraries missing symbols build:windows --dynamic_mode=off -# Avoid conflicting boringssl/protobuf system brew install -# https://github.com/bazelbuild/bazel/issues/10472 -build:macos --copt=-isystem/usr/local/include - # Set minimum supported C++ version build:macos --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 build:linux --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af92fec742..26c692953c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -538,7 +538,7 @@ jobs: run: ./ci/do_ci.sh bazel.test bazel_no_bzlmod_test: - name: Bazel + name: Bazel without bzlmod runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From a7bc08fabb8718e31a64dde8aeb4a8ad29430089 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Wed, 12 Jun 2024 16:12:54 -0700 Subject: [PATCH 4/5] 0 --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 829ea0b0dc..6974da66f9 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,7 +3,7 @@ module( name = "opentelemetry-cpp", - version = "1.14.2", + version = "0", compatibility_level = 0, repo_name = "io_opentelemetry_cpp", ) From 44f193bf702a3cd998dd958e8964325843ad38b6 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 13 Jun 2024 09:49:45 +0200 Subject: [PATCH 5/5] Update MODULE.bazel --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 6974da66f9..7b84c2b719 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -13,7 +13,7 @@ bazel_dep(name = "bazel_skylib", version = "1.5.0") bazel_dep(name = "curl", version = "8.4.0") bazel_dep(name = "grpc", version = "1.62.1", repo_name = "com_github_grpc_grpc") bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json") -bazel_dep(name = "opentelemetry-proto", version = "1.1.0", repo_name = "com_github_opentelemetry_proto") +bazel_dep(name = "opentelemetry-proto", version = "1.3.1", repo_name = "com_github_opentelemetry_proto") bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "prometheus-cpp", version = "1.2.4", repo_name = "com_github_jupp0r_prometheus_cpp")