Skip to content
Open
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
23 changes: 19 additions & 4 deletions .github/actions/cpp-bazel/pre-merge/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ description: C++ pre-merge testing github iggy actions

inputs:
task:
description: "Task to run (lint, build, test)"
description: "Task to run (lint, build, test, e2e)"
required: true

runs:
Expand Down Expand Up @@ -70,11 +70,26 @@ runs:
shell: bash
run: |
cd foreign/cpp
bazel test --config=ci //:iggy-cpp-test
bazel test --config=ci //:unit

- name: Setup server for e2e tests
if: inputs.task == 'e2e'
uses: ./.github/actions/utils/server-start

- name: Run e2e tests
if: inputs.task == 'e2e'
shell: bash
run: |
cd foreign/cpp
bazel test --config=ci //:low-level-e2e

- name: Stop server after e2e tests
if: always() && inputs.task == 'e2e'
uses: ./.github/actions/utils/server-stop

- name: Validate task
if: inputs.task != 'lint' && inputs.task != 'build' && inputs.task != 'test'
if: inputs.task != 'lint' && inputs.task != 'build' && inputs.task != 'test' && inputs.task != 'e2e'
shell: bash
run: |
echo "::error::Unsupported task '${{ inputs.task }}'. Expected one of: lint, build, test."
echo "::error::Unsupported task '${{ inputs.task }}'. Expected one of: lint, build, test, e2e."
exit 1
2 changes: 1 addition & 1 deletion .github/config/components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ components:
- "ci-infrastructure"
paths:
- "foreign/cpp/**"
tasks: ["lint", "build", "test"]
tasks: ["lint", "build", "test", "e2e"]

# Individual BDD tests per SDK - only run when specific SDK changes
bdd-rust:
Expand Down
35 changes: 32 additions & 3 deletions foreign/cpp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ genrule(
"libiggy_cpp.a",
"include/lib.rs.h",
"cxxbridge/rust/cxx.h",
"cxxbridge/sources/lib.rs.cc",
],
cmd = """
set -euo pipefail
Expand All @@ -38,6 +39,7 @@ genrule(
OUT_LIB="$$EXECROOT/$(location libiggy_cpp.a)"
OUT_RS="$$EXECROOT/$(location include/lib.rs.h)"
OUT_CXX="$$EXECROOT/$(location cxxbridge/rust/cxx.h)"
OUT_CC="$$EXECROOT/$(location cxxbridge/sources/lib.rs.cc)"

PROJECT_ROOT="$$(dirname $$(readlink -f $(location Cargo.toml)))"
cd "$$PROJECT_ROOT"
Expand Down Expand Up @@ -67,6 +69,13 @@ genrule(
exit 1
fi
cp "$$CXX_HDR" "$$OUT_CXX"

CC_SRC="$$(find "$$CARGO_TARGET_DIR/$$PROFILE/build" -path '*/out/cxxbridge/sources/*/src/lib.rs.cc' -print -quit)"
if [ -z "$$CC_SRC" ]; then
echo "ERROR: Failed to locate generated lib.rs.cc under $$CARGO_TARGET_DIR/$$PROFILE/build" >&2
exit 1
fi
cp "$$CC_SRC" "$$OUT_CC"
""",
local = 1,
)
Expand All @@ -80,7 +89,9 @@ cc_library(
name = "iggy-cpp",
srcs = glob([
"src/*.cpp",
], allow_empty = True),
], allow_empty = True) + [
":cxxbridge/sources/lib.rs.cc",
],
hdrs = [
"include/iggy.hpp",
":include/lib.rs.h",
Expand All @@ -106,8 +117,26 @@ cc_library(
)

cc_test(
name = "iggy-cpp-test",
srcs = ["tests/test.cpp"],
name = "unit",
srcs = [
"tests/unit_tests.cpp",
],
deps = [
":iggy-cpp",
"@googletest//:gtest_main",
],
)

cc_test(
name = "low-level-e2e",
srcs = glob([
"tests/**/low_level_e2e.cpp",
]) + [
"tests/common/test_helpers.hpp",
],
tags = [
"e2e",
],
deps = [
":iggy-cpp",
"@googletest//:gtest_main",
Expand Down
Loading
Loading