ci: agent integration tests in their own job with mongo
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Failing after 7m45s
CI / Check (pull_request) Successful in 14m32s

As the last step of the long check job, the mongo service had gone by
the time the tests ran (server selection timeout; at cleanup the
container was already removed), so 17 of 21 failed on connect. The
nightly, with the same service, keeps it. A job of its own starts mongo
with it, waits until mongo:27017 answers (and says so if it does not),
and builds only the agent's tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-10-30 08:34:24 +01:00
1 parent 5424074d26
commit 3ef5c28a97
1 file changed
+73 -12
+73 -12
View File
@@ -62,14 +62,6 @@ jobs:
runs-on: docker
container:
image: rust:1.94-bookworm
# The agent's integration tests run against a real MongoDB (as the nightly
# does); without one they had rotted unnoticed since the M7.2 tenant split.
services:
mongo:
image: mongo:7
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
steps:
- name: Checkout
run: |
@@ -150,10 +142,6 @@ jobs:
# compliance-core's integration tests need no services.
- name: Tests (core integration)
run: cargo test -p compliance-core --tests
- name: Tests (agent integration)
run: cargo test -p compliance-agent --test '*'
env:
TEST_MONGODB_URI: mongodb://root:example@mongo:27017/?authSource=admin
- name: Tests (dashboard server)
run: cargo test -p compliance-dashboard --features server --no-default-features
- name: Tests (dashboard web)
@@ -163,6 +151,79 @@ jobs:
run: sccache --show-stats
if: always()
# The agent's integration tests against a real MongoDB (as the nightly). Its
# own job: as the last step of the long check job the mongo service had
# gone by the time the tests ran (server selection timeout, container
# already removed). Without one in CI they had rotted unnoticed since the
# M7.2 tenant split.
agent-integration:
name: Agent integration
if: github.event_name == 'pull_request'
runs-on: docker
container:
image: rust:1.94-bookworm
services:
mongo:
image: mongo:7
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
steps:
- name: Checkout
run: |
git init
git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
git fetch --depth=1 origin "${GITHUB_SHA}"
git checkout FETCH_HEAD
# Resolve crates.io deps through the self-hosted Kellnr mirror (cached,
# crates.io-independent). Git deps (firmwerk-core) are unaffected — source
# replacement only applies to crates.io-sourced crates.
- name: Use Kellnr crates.io mirror
run: |
: "${CARGO_HOME:=/usr/local/cargo}"
mkdir -p "$CARGO_HOME"
{
echo '[source.crates-io]'
echo 'replace-with = "kellnr"'
echo '[registries.kellnr]'
echo 'index = "sparse+https://crates.breakpilot.com/api/v1/cratesio/"'
} >> "$CARGO_HOME/config.toml"
env:
RUSTC_WRAPPER: ""
- name: Install sccache
run: |
curl -fsSL https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz \
| tar xz --strip-components=1 -C /usr/local/bin/ sccache-v0.10.0-x86_64-unknown-linux-musl/sccache
chmod +x /usr/local/bin/sccache
env:
RUSTC_WRAPPER: ""
# compliance-agent has a git dependency on firmwerk-core (a private repo on
# this Gitea instance). Rewrite its SSH URL to HTTPS + a PAT so the runner
# can fetch it. Uses the org secret PLATFORM_CI_TOKEN (bot `platform-ci`,
# read-only member of the platform org).
# (Honored on fetch because CARGO_NET_GIT_FETCH_WITH_CLI=true uses system git.)
- name: Configure git auth for the private firmwerk dependency
run: |
git config --global \
url."https://platform-ci:${{ secrets.PLATFORM_CI_TOKEN }}@git.breakpilot.com/".insteadOf \
"ssh://git@git.breakpilot.com:22222/"
env:
RUSTC_WRAPPER: ""
- name: Wait for MongoDB
run: |
for i in $(seq 1 60); do
if (exec 3<>/dev/tcp/mongo/27017) 2>/dev/null; then echo "mongo:27017 is up"; exit 0; fi
sleep 2
done
echo "::error::mongo:27017 not reachable after 120 s"; getent hosts mongo || echo "mongo does not resolve"; exit 1
shell: bash
- name: Tests (agent integration)
run: cargo test -p compliance-agent --test '*'
env:
TEST_MONGODB_URI: mongodb://root:example@mongo:27017/?authSource=admin
# ---------------------------------------------------------------------------
# Stage 2: Deploy (only on main, after checks pass)
# Each service only deploys when its relevant files changed.