Skip to content

Commit 2ea6d5b

Browse files
authored
feat(cpp): part of low-level bindings, their tests, and e2e CI config (#2852)
1 parent edf7ada commit 2ea6d5b

File tree

17 files changed

+5893
-147
lines changed

17 files changed

+5893
-147
lines changed

.github/actions/cpp-bazel/pre-merge/action.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ description: C++ pre-merge testing github iggy actions
2020

2121
inputs:
2222
task:
23-
description: "Task to run (lint, build, test)"
23+
description: "Task to run (lint, build, test, e2e)"
2424
required: true
2525

2626
runs:
@@ -70,11 +70,26 @@ runs:
7070
shell: bash
7171
run: |
7272
cd foreign/cpp
73-
bazel test --config=ci //:iggy-cpp-test
73+
bazel test --config=ci //:unit
74+
75+
- name: Setup server for e2e tests
76+
if: inputs.task == 'e2e'
77+
uses: ./.github/actions/utils/server-start
78+
79+
- name: Run e2e tests
80+
if: inputs.task == 'e2e'
81+
shell: bash
82+
run: |
83+
cd foreign/cpp
84+
bazel test --config=ci //:low-level-e2e
85+
86+
- name: Stop server after e2e tests
87+
if: always() && inputs.task == 'e2e'
88+
uses: ./.github/actions/utils/server-stop
7489

7590
- name: Validate task
76-
if: inputs.task != 'lint' && inputs.task != 'build' && inputs.task != 'test'
91+
if: inputs.task != 'lint' && inputs.task != 'build' && inputs.task != 'test' && inputs.task != 'e2e'
7792
shell: bash
7893
run: |
79-
echo "::error::Unsupported task '${{ inputs.task }}'. Expected one of: lint, build, test."
94+
echo "::error::Unsupported task '${{ inputs.task }}'. Expected one of: lint, build, test, e2e."
8095
exit 1

.github/config/components.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ components:
214214
- "ci-infrastructure"
215215
paths:
216216
- "foreign/cpp/**"
217-
tasks: ["lint", "build", "test"]
217+
tasks: ["lint", "build", "test", "e2e"]
218218

219219
# Individual BDD tests per SDK - only run when specific SDK changes
220220
bdd-rust:

foreign/cpp/BUILD.bazel

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ genrule(
2828
"libiggy_cpp.a",
2929
"include/lib.rs.h",
3030
"cxxbridge/rust/cxx.h",
31+
"cxxbridge/sources/lib.rs.cc",
3132
],
3233
cmd = """
3334
set -euo pipefail
@@ -38,6 +39,7 @@ genrule(
3839
OUT_LIB="$$EXECROOT/$(location libiggy_cpp.a)"
3940
OUT_RS="$$EXECROOT/$(location include/lib.rs.h)"
4041
OUT_CXX="$$EXECROOT/$(location cxxbridge/rust/cxx.h)"
42+
OUT_CC="$$EXECROOT/$(location cxxbridge/sources/lib.rs.cc)"
4143
4244
PROJECT_ROOT="$$(dirname $$(readlink -f $(location Cargo.toml)))"
4345
cd "$$PROJECT_ROOT"
@@ -67,6 +69,13 @@ genrule(
6769
exit 1
6870
fi
6971
cp "$$CXX_HDR" "$$OUT_CXX"
72+
73+
CC_SRC="$$(find "$$CARGO_TARGET_DIR/$$PROFILE/build" -path '*/out/cxxbridge/sources/*/src/lib.rs.cc' -print -quit)"
74+
if [ -z "$$CC_SRC" ]; then
75+
echo "ERROR: Failed to locate generated lib.rs.cc under $$CARGO_TARGET_DIR/$$PROFILE/build" >&2
76+
exit 1
77+
fi
78+
cp "$$CC_SRC" "$$OUT_CC"
7079
""",
7180
local = 1,
7281
)
@@ -80,7 +89,9 @@ cc_library(
8089
name = "iggy-cpp",
8190
srcs = glob([
8291
"src/*.cpp",
83-
], allow_empty = True),
92+
], allow_empty = True) + [
93+
":cxxbridge/sources/lib.rs.cc",
94+
],
8495
hdrs = [
8596
"include/iggy.hpp",
8697
":include/lib.rs.h",
@@ -106,8 +117,26 @@ cc_library(
106117
)
107118

108119
cc_test(
109-
name = "iggy-cpp-test",
110-
srcs = ["tests/test.cpp"],
120+
name = "unit",
121+
srcs = [
122+
"tests/unit_tests.cpp",
123+
],
124+
deps = [
125+
":iggy-cpp",
126+
"@googletest//:gtest_main",
127+
],
128+
)
129+
130+
cc_test(
131+
name = "low-level-e2e",
132+
srcs = glob([
133+
"tests/**/low_level_e2e.cpp",
134+
]) + [
135+
"tests/common/test_helpers.hpp",
136+
],
137+
tags = [
138+
"e2e",
139+
],
111140
deps = [
112141
":iggy-cpp",
113142
"@googletest//:gtest_main",

0 commit comments

Comments
 (0)