diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f3f1ffdc0..c5acc48915 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -735,32 +735,6 @@ jobs: - name: run tests run: ./ci/do_ci.sh bazel.test - bazel_no_bzlmod_test: - name: Bazel without bzlmod - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 - with: - egress-policy: audit - - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 - 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/INSTALL.md b/INSTALL.md index 94f558c4f1..08176f81a6 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -336,38 +336,10 @@ Bazel](https://docs.bazel.build/versions/3.7.0/install.html) guide. ### Incorporating into an existing Bazel Project -- WORKSPACE file: - -```console -http_archive( - name = "io_opentelemetry_cpp", - sha256 = "", - strip_prefix = "opentelemetry-cpp-1.0.1", - urls = [ - "https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.0.1.tar.gz" - ], -) - -# Load OpenTelemetry dependencies after load. -load("@io_opentelemetry_cpp//bazel:repository.bzl", "opentelemetry_cpp_deps") - -opentelemetry_cpp_deps() - -# (required after v1.8.0) Load extra dependencies required for OpenTelemetry -load("@io_opentelemetry_cpp//bazel:extra_deps.bzl", "opentelemetry_extra_deps") - -opentelemetry_extra_deps() - -# Load gRPC dependencies after load. -load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") - -grpc_deps() - -# Load extra gRPC dependencies due to https://github.com/grpc/grpc/issues/20511 -load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") - -grpc_extra_deps() +- MODULE.bazel file: +```bzl +bazel_dep(name = "opentelemetry-cpp", version = "", repo_name = "io_opentelemetry_cpp") ``` - Component level BUILD file: diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index a52788ece2..0000000000 --- a/WORKSPACE +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -workspace(name = "io_opentelemetry_cpp") - -# Load our direct dependencies. -load("//bazel:repository.bzl", "opentelemetry_cpp_deps") - -opentelemetry_cpp_deps() - -load("//bazel:extra_deps.bzl", "opentelemetry_extra_deps") - -opentelemetry_extra_deps() - -# Load gRPC dependencies after load. -load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") - -grpc_deps() - -# Load extra gRPC dependencies due to https://github.com/grpc/grpc/issues/20511 -load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") - -grpc_extra_deps() diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod deleted file mode 100644 index 0db1b04622..0000000000 --- a/WORKSPACE.bzlmod +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -# Disables the default WORKSPACE when using bzlmod diff --git a/bazel/extra_deps.bzl b/bazel/extra_deps.bzl deleted file mode 100644 index 3a0148b87b..0000000000 --- a/bazel/extra_deps.bzl +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -# Load prometheus C++ dependencies. - -load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") -load("@com_github_jupp0r_prometheus_cpp//bazel:repositories.bzl", "prometheus_cpp_repositories") - -def opentelemetry_extra_deps(): - prometheus_cpp_repositories() - bazel_skylib_workspace() diff --git a/bazel/repository.bzl b/bazel/repository.bzl deleted file mode 100644 index 0c4b15e091..0000000000 --- a/bazel/repository.bzl +++ /dev/null @@ -1,177 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") - -# -# MAINTAINER -# -# This file is used for the Bazel build. -# -# When changing (add, upgrade, remove) dependencies -# please update: -# - the CMake build, see file -# /third_party_release -# - git submodule, see command -# git submodule status -# - -def opentelemetry_cpp_deps(): - """Loads dependencies need to compile the opentelemetry-cpp library.""" - - # Google Benchmark library. - # Only needed for benchmarks, not to build the OpenTelemetry library. - maybe( - http_archive, - name = "com_github_google_benchmark", - sha256 = "6bc180a57d23d4d9515519f92b0c83d61b05b5bab188961f36ac7b06b0d9e9ce", - strip_prefix = "benchmark-1.8.3", - urls = [ - "https://github.com/google/benchmark/archive/v1.8.3.tar.gz", - ], - ) - - # GoogleTest framework. - # Only needed for tests, not to build the OpenTelemetry library. - maybe( - http_archive, - name = "com_google_googletest", - sha256 = "8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7", - strip_prefix = "googletest-1.14.0", - urls = [ - "https://github.com/google/googletest/archive/v1.14.0.tar.gz", - ], - ) - - # Load abseil dependency(optional) - maybe( - http_archive, - name = "com_google_absl", - sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc", - strip_prefix = "abseil-cpp-20240116.2", - urls = [ - "https://github.com/abseil/abseil-cpp/archive/refs/tags/20240116.2.tar.gz", - ], - ) - - # gRPC transitively depends on apple_support and rules_apple at older - # versions. Bazel 7.x requires newer versions of these rules. By loading - # them before grpc, these newer versions are preferrred. - maybe( - http_archive, - name = "build_bazel_apple_support", - sha256 = "c4bb2b7367c484382300aee75be598b92f847896fb31bbd22f3a2346adf66a80", - url = "https://github.com/bazelbuild/apple_support/releases/download/1.15.1/apple_support.1.15.1.tar.gz", - ) - - maybe( - http_archive, - name = "build_bazel_rules_apple", - sha256 = "b4df908ec14868369021182ab191dbd1f40830c9b300650d5dc389e0b9266c8d", - url = "https://github.com/bazelbuild/rules_apple/releases/download/3.5.1/rules_apple.3.5.1.tar.gz", - ) - - # Load gRPC dependency - maybe( - http_archive, - name = "com_github_grpc_grpc", - sha256 = "f40bde4ce2f31760f65dc49a2f50876f59077026494e67dccf23992548b1b04f", - strip_prefix = "grpc-1.62.0", - urls = [ - "https://github.com/grpc/grpc/archive/refs/tags/v1.62.0.tar.gz", - ], - ) - - # OTLP Protocol definition - maybe( - http_archive, - name = "com_github_opentelemetry_proto", - build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD", - sha256 = "11330d850f5e24d34c4246bc8cb21fcd311e7565d219195713455a576bb11bed", - strip_prefix = "opentelemetry-proto-1.7.0", - urls = [ - "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.7.0.tar.gz", - ], - ) - - # JSON library - maybe( - http_archive, - name = "github_nlohmann_json", - build_file = "@io_opentelemetry_cpp//bazel:nlohmann_json.BUILD", - sha256 = "b8cb0ef2dd7f57f18933997c9934bb1fa962594f701cd5a8d3c2c80541559372", - urls = [ - "https://github.com/nlohmann/json/releases/download/v3.12.0/include.zip", - ], - ) - - # C++ Prometheus Client library. - maybe( - http_archive, - name = "com_github_jupp0r_prometheus_cpp", - sha256 = "ac6e958405a29fbbea9db70b00fa3c420e16ad32e1baf941ab233ba031dd72ee", - strip_prefix = "prometheus-cpp-1.3.0", - urls = [ - "https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v1.3.0.tar.gz", - ], - ) - - # bazel platforms - maybe( - http_archive, - name = "platforms", - sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", - ], - ) - - # libcurl (optional) - maybe( - http_archive, - name = "curl", - build_file = "@io_opentelemetry_cpp//bazel:curl.BUILD", - sha256 = "816e41809c043ff285e8c0f06a75a1fa250211bbfb2dc0a037eeef39f1a9e427", - strip_prefix = "curl-8.4.0", - urls = [ - "https://curl.haxx.se/download/curl-8.4.0.tar.gz", - "https://github.com/curl/curl/releases/download/curl-8_4_0/curl-8.4.0.tar.gz", - ], - ) - - # bazel skylib - maybe( - http_archive, - name = "bazel_skylib", - sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d", - urls = [ - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz", - ], - ) - - # Opentracing - maybe( - http_archive, - name = "com_github_opentracing", - sha256 = "5b170042da4d1c4c231df6594da120875429d5231e9baa5179822ee8d1054ac3", - strip_prefix = "opentracing-cpp-1.6.0", - urls = [ - "https://github.com/opentracing/opentracing-cpp/archive/refs/tags/v1.6.0.tar.gz", - ], - ) - - # Zlib (optional) - maybe( - http_archive, - name = "zlib", - build_file = "@io_opentelemetry_cpp//bazel:zlib.BUILD", - sha256 = "d14c38e313afc35a9a8760dadf26042f51ea0f5d154b0630a31da0540107fb98", - strip_prefix = "zlib-1.2.13", - urls = [ - "https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.xz", - "https://zlib.net/zlib-1.2.13.tar.xz", - ], - ) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 603d6012b4..9022ef301b 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -545,13 +545,6 @@ 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 - # Rapidyaml 0.9.0 as is does not support bazel, - # modules in bazel central repository required - # to build configuration. - bazel $BAZEL_STARTUP_OPTIONS build --enable_bzlmod=false $BAZEL_OPTIONS -- //... -//examples/configuration/... -//sdk/src/configuration/... -//sdk/test/configuration/... - bazel $BAZEL_STARTUP_OPTIONS test --enable_bzlmod=false $BAZEL_TEST_OPTIONS -- //... -//examples/configuration/... -//sdk/src/configuration/... -//sdk/test/configuration/... - exit 0 elif [[ "$1" == "bazel.test" ]]; then bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS $BAZEL_WITH_PREVIEW //... bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_TEST_OPTIONS $BAZEL_WITH_PREVIEW //... diff --git a/docs/maintaining-dependencies.md b/docs/maintaining-dependencies.md index be8e503a69..428ba3aaa3 100644 --- a/docs/maintaining-dependencies.md +++ b/docs/maintaining-dependencies.md @@ -86,11 +86,6 @@ index 0bbf67f3..7362473f 100644 vcpkg=2024.02.14 ``` -#### file bazel/repository.bzl - -Please follow the guide [Upgrade a bazel dependency](#upgrade-a-bazel-dependency) -for more details. - #### file cmake/opentelemetry-proto.cmake Update the tag in the CMake logic: @@ -141,16 +136,6 @@ In this case, it is better to: When the C++ code requires a newer minimum version of opentelemetry-proto, make sure to document this, including in the release notes. -### Known issues (opentelemetry-proto) - -For bazel, two different methods to build exists. - -First, the code can build using file `bazel/repository.bzl`. -This option does not depend on bazel central. - -Secondly, there is also a build using modules, with file `MODULE.bazel`. -This option does depend on bazel central, and CI depends on it. - ## semantic-conventions and weaver ### Comments (semantic-conventions) @@ -378,50 +363,13 @@ index abc1234..def5678 100644 +prometheus-cpp=v1.2.4 ``` -In file bazel/repository.bzl locate the entry for prometheus-cpp: - -```shell -# C++ Prometheus Client library. -maybe( - http_archive, - name = "com_github_jupp0r_prometheus_cpp", - sha256 = "ac6e958405a29fbbea9db70b00fa3c420e16ad32e1baf941ab233ba031dd72ee", - strip_prefix = "prometheus-cpp-1.2.3", - urls = [ - "https://github.com/jupp0r/prometheus-cpp/archive/refs/tags/v1.2.3.tar.gz", - ], -) -``` - -Update the URL to the new tag: - -```shell -urls = [ - "https://github.com/jupp0r/prometheus-cpp/archive/v1.2.4.tar.gz", -], -``` - -Update strip_prefix to match the new version: - -```shell -strip_prefix = "prometheus-cpp-1.2.4", -``` - -Download the new URL: - -```shell -wget https://github.com/jupp0r/prometheus-cpp/archive/v1.2.4.tar.gz -``` - -Calculate the checksum: +In file `MODULE.bazel` locate the entry for prometheus-cpp and update it +to the new version: -```shell -sha256sum v1.2.4.tar.gz -abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234 v1.2.4.tar.gz +```bzl +bazel_dep(name = "prometheus-cpp", version = "1.3.0", repo_name = "com_github_jupp0r_prometheus_cpp") ``` -Update the `sha256`. - ## Upgrade a git submodule All the git submodule are under the folder `third_party`. @@ -502,89 +450,7 @@ git add third_party/opentelemetry-proto ## Upgrade a bazel dependency -Same as git submodule, we will continue use `opentelemetry-proto` as example. - -All the bazel dependencies are defined in [repository.bzl](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/bazel/repository.bzl) -and [MODULE.bazel](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/MODULE.bazel). - -### Update the dependency in repository.bzl - -Locate the entry for opentelemetry-proto: - -```text - # OTLP Protocol definition - maybe( - http_archive, - name = "com_github_opentelemetry_proto", - build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD", - sha256 = "bed250ceec8e4a83aa5604d7d5595a61945059dc662edd058a9da082283f7a00", - strip_prefix = "opentelemetry-proto-1.3.1", - urls = [ - "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.1.tar.gz", - ], - ) -``` - -Update the URL to the new tag: - -```text - urls = [ - "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz", - ], -``` - -Update strip_prefix to the new tag: - -```text - strip_prefix = "opentelemetry-proto-1.3.2", -``` - -Download the new URL: - -```shell -wget https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz -``` - -Run a checksum on the new file: - -```shell -sha256sum v1.3.2.tar.gz -``` - -```shell -c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7 v1.3.2.tar.gz -``` - -Update the checksum in file bazel/repository.bzl: - -```text - sha256 = "c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7", -``` - -Typical change: - -```shell -[malff@malff-desktop opentelemetry-cpp]$ git diff bazel/repository.bzl -diff --git a/bazel/repository.bzl b/bazel/repository.bzl -index bac1e45b..508b95a3 100644 ---- a/bazel/repository.bzl -+++ b/bazel/repository.bzl -@@ -88,10 +88,10 @@ def opentelemetry_cpp_deps(): - http_archive, - name = "com_github_opentelemetry_proto", - build_file = "@io_opentelemetry_cpp//bazel:opentelemetry_proto.BUILD", -- sha256 = "bed250ceec8e4a83aa5604d7d5595a61945059dc662edd058a9da082283f7a00", -- strip_prefix = "opentelemetry-proto-1.3.1", -+ sha256 = "c069c0d96137cf005d34411fa67dd3b6f1f8c64af1e7fb2fe0089a41c425acd7", -+ strip_prefix = "opentelemetry-proto-1.3.2", - urls = [ -- "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.1.tar.gz", -+ "https://github.com/open-telemetry/opentelemetry-proto/archive/v1.3.2.tar.gz", - ], - ) -``` - -#### Update MODULE.bazel +### Update MODULE.bazel > Remember, the link is different in your case. Replace `opentelemetry-proto` to correct target. diff --git a/third_party_release b/third_party_release index 5e38ddce18..2bc8ef139c 100644 --- a/third_party_release +++ b/third_party_release @@ -12,7 +12,6 @@ # - update the matching git submodule to the new tag. # - update the Bazel build files # - opentelemetry-cpp/MODULE.bazel -# - opentelemetry-cpp/bazel/repository.bzl abseil=20250127.0 zlib=v1.3.1