Log/Tooling/

Why skip is never a pass in a backend's CI gates

Splitting an AI backend's test suite into four gates, removing hardcoded paths, and making skipped tests exit 2 instead of silently passing.

The compliance backend for a financial-education AI assistant had grown a test suite that was starting to lie. 49 suites, one hand-written runner, inline comments explaining why things were skipped. A missing Redis connection would show up as a green run. A hardcoded path on my laptop meant another contributor’s run started with “cannot find file” and still exited zero.

Before pushing to the client’s remote I rebuilt the gate. The core rule turned out to be the shortest one in the whole file.

Skip is never a pass

Missing dependencies now exit 2. Not 0 with a warning line that nobody reads. If a suite needs Mongo and Mongo is not reachable, the gate fails and I have to decide: start Mongo, or move the suite to a lower tier where it does not require Mongo. Either way, the lie is gone.

This sounds obvious. It is not how test runners usually behave in a repo that has been evolving for months with agents writing some of the code.

Four gates, not one script

The old deploy-full-green.sh tried to run everything. I replaced it with scripts/gate-phases.sh and split what it runs into four gates by what each gate actually tests:

  • Gate 1, Server A standalone. 31 suites, 0 failed, 0 skipped.
  • Gate 2, the seam between my server and the second server the client’s main dev team runs. jwtClaimMatrix.ts at 21/21, revocationContract.ts at 12/12. Plus serverBConformance.ts at 15/15, which runs without Server A at all so the other team can prove their side of the contract on their own machine.
  • Gate 3, adversarial. 6 suites tagged, all disabled until wired in one at a time.
  • Gate 4, scale. k6 load/soak is in, three more suites to write.

Full push tier: 35 passed, 0 failed, 0 skipped.

Suites are now data. A manifest tags every one with its tier, its owner (A, B, seam, joint), the server mode it expects, and the capabilities it needs. The runner filters that list. Adding a suite, moving one to the other server, or demoting one to a lower tier is a one-line edit.

Fourteen hardcoded paths

The suite had 14 absolute paths pointing at my own machine. Each one was a quiet “this will not run anywhere else.” Removed, replaced with helpers under tests/helpers/: paths.ts, env.ts, ports.ts, mintToken.ts, capabilities.ts. Port numbers now come from the OS, not a hand-rolled registry.

Six suites were coupled to Server A’s own auth routes, which were about to change under me. They now mint their own JWTs with mintToken.ts and talk to the endpoint under test directly. The k6 script got a token pool so load generation does not touch the auth path.

A real bug the restructure caught

While wiring the runner I found dailyChallenge.ts reading a lesson.quiz field that did not exist on the model. The actual quiz lived in a separate collection, joined by topic. The old suite was somehow passing. Fixed to use the real join. concurrency-p1 is now 4 of 4.

Also found that one test getting admin access was happening by naming coincidence: a user_id string contained “admin”. That became an explicit mintAdminToken().

What I would steal for the next backend

Three things.

First, write “skip exits 2” into the runner on day one. Later it is a politics problem, not a code problem, because people will be relying on the green.

Second, make the suite a data file. Not a shell script. A table of what runs where, filtered at runtime. The moment the test set is more than ten suites, the hand-written runner becomes the slowest part of your gate.

Third, no absolute paths. The grep for /home/ and /Users/ in tests/ takes two minutes and tells you whether anyone else on the team can actually run your tests.

All entries · Book a call · Discuss on X