Skip to content

Improve CI#1174

Merged
ccgsnet merged 2 commits into
masterfrom
ci-improvements
Jul 7, 2026
Merged

Improve CI#1174
ccgsnet merged 2 commits into
masterfrom
ci-improvements

Conversation

@ccgsnet

@ccgsnet ccgsnet commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Speeds up and stabilizes the self-hosted unit-test CI pipeline by running Bazel natively on the runner (instead of inside das-builder Docker), failing fast on test regressions, and fixing MORK server orchestration for parallel test workloads.

  • Native Bazel in CIbazel_exec.sh on the host after setup_bazel.sh; drops bazel_build.sh + make run-tests-only (Docker round-trip) from the unit-test workflow.
  • //:ci_binaries meta-target — single Bazel target that forces all production binaries to compile/link; shared by CI and bazel_build.sh (publish workflow).
  • Fail-fast ordering — run //tests/cpp/... first, then //:ci_binaries (reuses Bazel cache from the test build).
  • Dual MORK servers — ports 40022 (morkdb) and 40032 (adapterdb / morkwrapper); fixed mork_server.sh to run detached with stable per-port container names.
  • Test scope — unit CI runs //tests/cpp/... only; integration tests stay tagged and excluded (they require /opt/das Docker layout).

CI workflow changes (run-unit-tests.yml)

Before After
bazel_build.sh (full packaging script) Removed from unit-test job
make run-tests-only → Docker das-builder ./scripts/bazel_exec.sh test //tests/cpp/... on host
Single MORK on 40022 MORK on 40022 + 40032
Binaries built before tests Tests first, then //:ci_binaries
Bazel setup before services Services first, Bazel setup just before compile/test

Other changes

  • src/BUILDci_binaries genrule listing all production cc_binary / shared-lib targets.
  • Makefilebuild-ci-binaries, run-tests-native, ci-unit-tests for local parity with CI.
  • src/.bazelrc--jobs=HOST_CPUS*0.85 (was 0.5) on dedicated baremetal runners.
  • mork_server.shdocker run -d, container name das-mork-server-${PORT}, remove stale container before start.
  • MorkDB.cc — retry on connection failures alongside transient HTTP 401/409.
  • Testsadapterdb_test / morkwrapper_test use MORK port 40032; reduce morkdb_test thread counts; bump adapterdb, morkwrapper, postgreswrapper test size to medium.
  • inference_integration_test — tagged integration.

Why native Bazel?

setup_bazel.sh already installs Bazelisk (/opt/bazel/bazelisk) and native deps (hiredis, mongocxx, libpqxx, httplib) on self-hosted runners — the same toolchain baked into das-builder. Running tests through Docker duplicated compilation and required /opt/das bind mounts that integration tests depended on. Unit tests only need the host toolchain + service fixtures (Redis, Mongo, MORK, Postgres).

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ccgsnet, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 33 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 86e5050b-4c0b-4662-b9f4-b39d33eea792

📥 Commits

Reviewing files that changed from the base of the PR and between f3e7ff2 and 497633e.

📒 Files selected for processing (2)
  • .github/workflows/run-unit-tests.yml
  • src/.bazelrc

Walkthrough

This PR consolidates CI binary builds under a single Bazel target //:ci_binaries, updates the unit-test workflow to restart the Attention Broker and start two MORK servers with polling, switches CI to Bazel-based build/test, refactors MorkDB retry handling, rewrites the MORK server script for deterministic container naming, and adjusts test ports, thread counts, and Bazel test metadata.

Changes

Bazel CI binary consolidation

Layer / File(s) Summary
ci_binaries genrule and job parallelism
src/BUILD, src/.bazelrc
Adds a public genrule ci_binaries depending on production binaries and outputting a stamp file; increases Bazel job parallelism factor from 0.5 to 0.85.
Build script, Makefile, and CI workflow wiring
.github/scripts/bazel_build.sh, Makefile, .github/workflows/run-unit-tests.yml
Updates BAZEL_BINARY_TARGETS to build only //:ci_binaries; adds Makefile targets build-ci-binaries, run-tests-native, ci-unit-tests; rewrites CI workflow to restart Attention Broker, start two MORK servers (40022, 40032) with polling/retry and failure diagnostics, then run Bazel setup, test, and build steps.
MORK server script determinism
src/scripts/mork_server.sh
Enables strict shell mode, computes deterministic container names from MORK_PORT, force-removes existing containers, and updates the docker run command accordingly.

Test port, concurrency, and metadata updates

Layer / File(s) Summary
MorkDB retry logic refactor
src/atomdb/morkdb/MorkDB.cc
Merges missing-result and transient-status retry branches in MorkClient::send_request, using a computed status_str for logging and error messages.
Test port alignment and thread reduction
src/tests/cpp/adapterdb_test.cc, src/tests/cpp/morkwrapper_test.cc, src/tests/cpp/morkdb_test.cc
Updates test MorkDB port references from 40022 to 40032 and reduces concurrency test thread counts (200→8, 100→8).
Bazel test size and tag metadata
src/tests/cpp/BUILD, src/tests/integration/cpp/BUILD
Changes size attribute from "small" to "medium" for three cc_test targets and adds an integration tag to inference_integration_test.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Workflow as run-unit-tests.yml
  participant CLI as das-cli
  participant MORK1 as MORK Server 40022
  participant MORK2 as MORK Server 40032
  participant Bazel as bazel_exec.sh

  Workflow->>CLI: restart Attention Broker
  Workflow->>MORK1: make run-mork-server
  Workflow->>MORK2: make run-mork-server
  Workflow->>MORK1: poll /status/-
  Workflow->>MORK2: poll /status/-
  Workflow->>Bazel: setup_bazel.sh
  Workflow->>Bazel: test //tests/cpp/...
  Workflow->>Bazel: build //:ci_binaries
Loading

Possibly related PRs

  • singnet/das#1161: Both PRs modify MorkClient::send_request HTTP retry/error-handling logic in src/atomdb/morkdb/MorkDB.cc.

Suggested reviewers: andre-senna, marcocapozzoli

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main CI pipeline changes, though it is fairly broad.
Description check ✅ Passed The description matches the Bazel-native CI, MORK orchestration, and test workflow updates in the diff.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Tests For Behavior Changes ✅ Passed PASS: The PR changes MorkDB/MORK behavior and updates C++ tests for the new 40032 server, concurrency, and test sizing; no test omission is justified in the description.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci-improvements

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
Makefile (1)

115-122: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Declare new targets .PHONY.

Static analysis flags ci-unit-tests as not declared PHONY; the same applies to build-ci-binaries and run-tests-native since none produce a file matching their name.

🔧 Proposed fix
+.PHONY: build-ci-binaries run-tests-native ci-unit-tests
+
 build-ci-binaries:
 	`@cd` src && ./scripts/bazel_exec.sh build --noshow_progress //:ci_binaries
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` around lines 115 - 122, The Makefile targets build-ci-binaries,
run-tests-native, and ci-unit-tests are being treated as real files, so declare
each of these as .PHONY to match their intent. Update the Makefile’s phony
target declaration section to include these names alongside the existing
targets, keeping the target names themselves unchanged.

Source: Linters/SAST tools

src/BUILD (1)

218-237: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider filegroup instead of genrule for this aggregation target.

The genrule with cmd = "touch $@" works to force these binaries to build, but Bazel's own docs describe exactly this use case for filegroup: gathering the outputs of a set of targets under a single label, without an extra local action or stamp-file artifact.

♻️ Proposed refactor
-genrule(
-    name = "ci_binaries",
-    srcs = [
-        ":word_query",
-        ":word_query_evolution",
-        ":attention_broker_service",
-        ":attention_broker_client",
-        ":das",
-        ":db_loader",
-        ":busnode",
-        ":busclient",
-        ":database_adapter",
-    ],
-    outs = ["ci_binaries.stamp"],
-    cmd = "touch $@",
-    visibility = ["//visibility:public"],
-)
+filegroup(
+    name = "ci_binaries",
+    srcs = [
+        ":word_query",
+        ":word_query_evolution",
+        ":attention_broker_service",
+        ":attention_broker_client",
+        ":das",
+        ":db_loader",
+        ":busnode",
+        ":busclient",
+        ":database_adapter",
+    ],
+    visibility = ["//visibility:public"],
+)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/BUILD` around lines 218 - 237, Replace the ci_binaries aggregation
genrule in src/BUILD with a filegroup that directly collects the binary targets
such as word_query, attention_broker_service, db_loader, and the rest. The
current ci_binaries target uses a touch stamp only to force builds, but this
should be expressed as a label-only aggregation target with filegroup so CI can
depend on it without creating an extra action or artifact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/run-unit-tests.yml:
- Around line 60-80: The MORK startup check in the workflow is too permissive
and can miss failed launches. Update the readiness probe in the “Starting MORK
Servers” step to use curl with fail behavior so HTTP 4xx/5xx does not count as
ready, and replace the bare wait after the two make run-mork-server background
jobs with explicit background job handling so a failed startup surfaces
immediately. Use the existing loop and the run-mork-server commands as the main
anchors when adjusting the readiness and failure handling.

In `@src/.bazelrc`:
- Around line 12-13: The comment above the jobs setting is stale because it says
“half” while common --jobs is set to HOST_CPUS*0.85. Update the comment in the
.bazelrc entry to match the current value, keeping it aligned with the jobs
configuration so the intent is clear when locating the common --jobs setting.

In `@src/atomdb/morkdb/MorkDB.cc`:
- Around line 82-104: The retry loop in MorkDB::request-style HTTP handling can
block startup for too long when the MORK endpoint is unreachable, especially
through MorkClient usage from MorkDB::mork_setup() and
MorkConnection::connect(). Update the retry behavior in this path to either fail
fast on connection errors or make the retry budget/backoff configurable, and
ensure the logic around the transient status handling and max_attempts check in
MorkDB.cc is adjusted so a dead endpoint cannot stall synchronous startup for
the full window by default.

---

Nitpick comments:
In `@Makefile`:
- Around line 115-122: The Makefile targets build-ci-binaries, run-tests-native,
and ci-unit-tests are being treated as real files, so declare each of these as
.PHONY to match their intent. Update the Makefile’s phony target declaration
section to include these names alongside the existing targets, keeping the
target names themselves unchanged.

In `@src/BUILD`:
- Around line 218-237: Replace the ci_binaries aggregation genrule in src/BUILD
with a filegroup that directly collects the binary targets such as word_query,
attention_broker_service, db_loader, and the rest. The current ci_binaries
target uses a touch stamp only to force builds, but this should be expressed as
a label-only aggregation target with filegroup so CI can depend on it without
creating an extra action or artifact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 20cb0ee2-5253-4269-b086-14c631944a2e

📥 Commits

Reviewing files that changed from the base of the PR and between 797c081 and f3e7ff2.

📒 Files selected for processing (12)
  • .github/scripts/bazel_build.sh
  • .github/workflows/run-unit-tests.yml
  • Makefile
  • src/.bazelrc
  • src/BUILD
  • src/atomdb/morkdb/MorkDB.cc
  • src/scripts/mork_server.sh
  • src/tests/cpp/BUILD
  • src/tests/cpp/adapterdb_test.cc
  • src/tests/cpp/morkdb_test.cc
  • src/tests/cpp/morkwrapper_test.cc
  • src/tests/integration/cpp/BUILD

Comment thread .github/workflows/run-unit-tests.yml
Comment thread src/.bazelrc Outdated
Comment thread src/atomdb/morkdb/MorkDB.cc
@ccgsnet ccgsnet merged commit 8751cc4 into master Jul 7, 2026
3 checks passed
@ccgsnet ccgsnet deleted the ci-improvements branch July 7, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants