seokjin0414 commented on code in PR #3554: URL: https://github.com/apache/iggy/pull/3554#discussion_r3488118458
########## bdd/cpp/BUILD.bazel: ########## @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +load("@rules_cc//cc:defs.bzl", "cc_binary") + +# BDD wire server: links the C++ step definitions with cucumber-cpp's main(), which starts a +# wire-protocol server on port 3902. A Ruby Cucumber runner drives the shared +# basic_messaging.feature over the wire (cucumber-cpp v0.8.0 is wire-only). main() comes from +# @cucumber-cpp//:cucumber-cpp via alwayslink, gtest provides the assertion macros, and +# @iggy_cpp//:iggy-cpp provides the SDK (built from the sibling foreign/cpp module). +cc_binary( + name = "bdd_wire_server", + srcs = glob([ + "features/step_definitions/*.cpp", + "features/step_definitions/*.hpp", + ]), + copts = select({ + "@platforms//os:windows": ["/utf-8"], + "//conditions:default": [ + "-finput-charset=UTF-8", + "-fexec-charset=UTF-8", + ], + }), + includes = [ + "features/step_definitions", + ], + testonly = True, + deps = [ + "@cucumber-cpp//:cucumber-cpp", + "@googletest//:gtest", + "@iggy_cpp//:iggy-cpp", + ], +) Review Comment: added all of those to the cc_binary copts, plus linkopts = ["-g"]. compiles clean under -Werror -Wpedantic. ########## bdd/cpp/Dockerfile: ########## @@ -0,0 +1,75 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# C++ BDD harness. bdd/cpp is a self-contained Bazel module: it builds the step definitions +# into a cucumber-cpp wire server and pulls in the Iggy C++ SDK (foreign/cpp) via +# local_path_override. A Ruby Cucumber runner reads the shared feature files and drives the +# wire server over the wire protocol (cucumber-cpp v0.8.0 is wire-only). The image therefore +# needs the Rust + Bazel + C++ toolchain (to build the wire server) and Ruby (to run cucumber). + +ARG RUST_VERSION=1.96 +FROM rust:${RUST_VERSION}-bookworm + +RUN apt-get update && apt-get install --yes --no-install-recommends \ + build-essential \ + ca-certificates \ + curl \ + git \ + ruby-full \ + && rm -rf /var/lib/apt/lists/* + +# Bazelisk resolves the Bazel version from bdd/cpp/.bazelversion. +RUN curl -fsSL "https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-$(dpkg --print-architecture)" \ + -o /usr/local/bin/bazel \ + && chmod +x /usr/local/bin/bazel + +WORKDIR /workspace +COPY . . + +# Build the cucumber-cpp wire server. bdd/cpp is its own Bazel module and links the Iggy C++ +# SDK pulled in from foreign/cpp via local_path_override. +RUN cd bdd/cpp \ + && bazel build //:bdd_wire_server \ + && cp bazel-bin/bdd_wire_server /usr/local/bin/bdd_wire_server + +# Install the Cucumber runner (wire-protocol driver). +RUN gem install bundler --no-document \ + && cd bdd/cpp \ + && bundle install + +RUN mkdir -p /workspace/bdd/cpp/features + +# Entrypoint: copy the mounted shared feature files, start the wire server, then run cucumber. +RUN printf '%s\n' \ + '#!/bin/bash' \ + 'set -euo pipefail' \ + 'if [ -d /app/features ]; then' \ + ' cp -f /app/features/*.feature /workspace/bdd/cpp/features/ 2>/dev/null || true' \ + 'fi' \ + 'bdd_wire_server &' \ + 'server_pid=$!' \ + 'sleep 2' \ + 'cd /workspace/bdd/cpp' \ + 'set +e' \ + 'bundle exec cucumber' \ + 'status=$?' \ + 'kill "$server_pid" 2>/dev/null || true' \ + 'exit $status' \ + > /entrypoint.sh \ + && chmod +x /entrypoint.sh Review Comment: done — it's now bdd/cpp/scripts/entrypoint.sh (COPY'd in, shellcheck-clean). ########## foreign/cpp/BUILD.bazel: ########## @@ -129,6 +129,7 @@ cc_library( deps = [ ":iggy_cpp_static", ], + visibility = ["//visibility:public"], ) Review Comment: set version = "0.1.0" on the iggy_cpp module, and matched it in the bdd/cpp/MODULE.bazel bazel_dep. ########## bdd/cpp/.bazelrc: ########## @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +common --enable_bzlmod + +# This harness resolves its module graph fresh in the build environment (Docker), so it does +# not commit a MODULE.bazel.lock. +common --lockfile_mode=off + +# cucumber-cpp and its transitive deps (asio, tclap, ...) are not clean under strict warnings. +# Silence warnings for external sources so they never fail the wire-server build. +build --per_file_copt=external/.*@-w Review Comment: right — removed it. the warning flags are on the target copts now, so external deps aren't affected. ########## bdd/cpp/.bazelrc: ########## @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +common --enable_bzlmod + +# This harness resolves its module graph fresh in the build environment (Docker), so it does +# not commit a MODULE.bazel.lock. +common --lockfile_mode=off Review Comment: removed lockfile_mode=off and committed MODULE.bazel.lock. ########## bdd/cpp/MODULE.bazel: ########## @@ -0,0 +1,34 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +module( + name = "iggy_cpp_bdd", +) + +bazel_dep(name = "rules_cc", version = "0.2.18") +bazel_dep(name = "platforms", version = "1.1.0") +bazel_dep(name = "googletest", version = "1.17.0.bcr.2") +bazel_dep(name = "cucumber-cpp", version = "0.8.0.bcr.1") Review Comment: no — it was only used by the windows copts select, and the wire server is linux-only, so i dropped both the select and the platforms dep. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
