Skip to content

Make Fleet integration tests skip cleanly when the private test source is not staged #180

Done

Description

@w4ffl35

Problem

On a fresh public clone, npm test fail-fast dies at src/campaigncontrol/__tests__/repository-budget-v2.integration.test.ts:

Error: Required Fleet test source is missing; run the CI source staging step
    at requiredFleetTestRoot (src/campaigncontrol/__tests__/fleet-test-source.ts:7)

scripts/run-tests.mjs stops at the first failure, so none of the remaining ~325 test files run locally. The Fleet source is private and staged only in private CI (.github/workflows/ci.yml: scripts/stage-fleet-test-source.mjs + FLEET_SECURITY_WATCH_TEST_ROOT). A contributor cannot get a green local run.

Architecture (independent solution)

Do not make the private source public and do not delete the integration test. Make absence explicit and skippable at the test boundary:

  1. In fleet-test-source.ts, replace the hard throw on missing env with a typed FleetTestSourceUnavailable result / isFleetTestSourceAvailable() probe. Keep the second check (bridge file missing under a set root) as a hard error — that is a misconfiguration, not absence.
  2. At the top of every Fleet-dependent integration entry point, if unavailable: print one line skip: Fleet integration source not staged (set FLEET_SECURITY_WATCH_TEST_ROOT) and exit 0. Mirror the repo's existing skip idiom if one exists; do not invent a framework.
  3. scripts/run-tests.mjs needs no change if the test file itself exits 0 on skip. Verify the runner counts it as passed and continues.
  4. When the env var is set, behavior is byte-identical to today (private CI unchanged).

Scope / non-goals

  • No change to scripts/stage-fleet-test-source.mjs, CI, or any Fleet logic.
  • No stub/fake Fleet source committed to satisfy the test.

Acceptance

  • Fresh clone without FLEET_SECURITY_WATCH_TEST_ROOT: npm test runs past the Fleet integration file and reports the skip line once.
  • With the env var set to a bogus path: hard failure naming the missing bridge file.
  • With a correctly staged source (CI): integration test still executes (not skipped).

Tests (happy / sad / bad)

  • Happy: env unset → skip line, exit 0, runner continues to next file.
  • Sad: env set, bridge missing → non-zero, message names expected path.
  • Bad: env set to a file (not a dir) → non-zero, no stack-only crash.

Contributor notes

Small, self-contained, no private data needed. Start from src/campaigncontrol/__tests__/fleet-test-source.ts and its callers (grep -rn requiredFleetTestRoot src).

Activity

  1. added
    bug
    good first issue
    help wanted
    on Nov 29, 2026
  2. w4ffl35 commented on Dec 5, 2026

    @w4ffl35
    MemberAuthor

    Issue 180 — Closing Report

    Files changed

    • src/campaigncontrol/tests/fleet-test-source.ts (bridge-missing error now names the full bridge path .../operations/campaign_budget_bridge.py, not just the root)
    • src/campaigncontrol/tests/fleet-test-source.test.ts (new: 4 regression tests for the probe itself)
    • src/rsi/tests/fleet-budget-integration.test.ts (migrated off its homebrew sibling-checkout probe onto the shared shouldSkipFleetTest/requiredFleetTestRoot; deleted isPrivateFleetSource, fixed an 81-char import)

    Baseline (before)

    • SKIP repository-budget-v2 integration: Fleet source not staged, exit 0 (already landed in f3a36ff/51354a6b).
    • Bogus env var failed with Required Fleet test bridge is unavailable at /tmp/hcl-bogus-fleet-xyz (named the root, not the bridge file).

    Baseline (after)

    • Env unset: SKIP repository-budget-v2 integration: Fleet source not staged, exit 0; runner continues (run-tests: all 341 file(s) passed).
    • Env set to bogus path: hard error Required Fleet test bridge is unavailable at /tmp/hcl-bogus-fleet-xyz/operations/campaign_budget_bridge.py, non-zero.
    • Env set to a file: same hard error naming the bridge, non-zero, no stack-only crash.
    • New probe tests: All 4 fleet-test-source tests passed (happy/sad/bad covered).
    • Staged-source path unchanged: requiredFleetTestRoot() still returns the resolved root when the bridge exists (covered by staged source never skips test); private CI behavior byte-identical.

    Boot check

    Full npm test: run-tests: all 341 file(s) passed. npx tsc --noEmit clean. New test files add zero standards violations; remaining check-standards/check-architecture deltas are pre-existing baseline lines untouched by this change.

    Residual risk / notes

    src/rsi/__tests__/fleet-budget-integration.test.ts previously searched ../fleet-security-watch sibling checkouts and verified the git remote; it now uses only the staged FLEET_SECURITY_WATCH_TEST_ROOT. If any private workflow relied on the sibling-checkout fallback instead of the staging step, that workflow must set the env var (CI already does via scripts/stage-fleet-test-source.mjs).

    PR: #204

  3. added a commit that references this issue on Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions