Skip to content

Deploy only after the tests pass

Run each check on the exact commit, then a secret scan and an optional review, then deploy, as one queued job. Nothing ships if a step fails.

On this page

An agent finishes a change, says the tests pass, and deploys. Later you find out the tests passed on an earlier commit, or on a working tree with edits that were never committed, or not at all. The deploy shipped code nobody checked.

In CI this is a solved problem: the deploy job depends on the test job. On a developer machine, where agents run the deploy script themselves, nothing ties the two together unless you build it.

Why unchecked code gets shipped

  • The check ran on other code. Tests passed, then the agent made one more edit and deployed.
  • The tree was dirty. Uncommitted files made the tests pass locally, and the deployed commit does not have them.
  • The check was skipped or cut short. A slow suite hit a timeout, and the agent read the partial output as a pass.
  • Two releases raced. One agent's deploy went out on top of another's.
  • No way back. The deploy failed halfway and there was no tested rollback.

A release gate without any extra tool

You can get most of the way with a script that every deploy must go through:

  1. Refuse to start unless git status --porcelain prints nothing.
  2. Record the commit with git rev-parse HEAD.
  3. Run every check. Stop at the first non-zero exit.
  4. Run a secret scan, for example gitleaks, and a dependency audit such as npm audit.
  5. Build.
  6. Check again that the tree is clean and the commit has not moved.
  7. Deploy, then run a health check a few times. If it fails, run the rollback and check again.
  8. Write what happened to a log: commit, checks, outcome.
  9. Take a lock so two of these scripts never run at once.

Writing and maintaining that script is the work. Getting every agent to use it, and only it, is the rest.

How dotime-queue release does it

dotime-queue release is that sequence as one queued job. The steps live in dotime.release.json at the top of the repository. The file must be committed, so a change to it shows in review like any code. Each command is a list of words, started without a shell. Only deploy is required.

dotime.release.json
{ "checks": [{ "label": "tests", "command": ["npm", "test"] }],  "build": ["npm", "run", "build"],  "deploy": ["npm", "run", "deploy"],  "verify": { "command": ["node", "scripts/health.mjs"], "tries": 5, "everySec": 10 },  "rollback": ["npm", "run", "deploy:previous"],  "security": { "failOn": "high" } }

Try it first. The dry run prints each step, and for each check whether it would be skipped as already passed on this commit. It runs, writes and queues nothing:

Shell
dotime-queue release --dry-rundotime-queue releasedotime-queue releases

In order, a release:

  1. Checks the start. A git repository, a commit, a clean tree, and the config file as the commit has it. No other release of the same repository may be running.
  2. Waits in line for a slot, like any heavy job, then checks that HEAD has not moved and the tree is still clean.
  3. Runs each check on that commit. A check is skipped only when the same command already passed on this exact clean commit. Any non-zero exit refuses the release.
  4. Runs the security check, fresh: gitleaks for leaked keys, and npm audit or osv-scanner for known vulnerable packages. Findings at or above the limit refuse the release. A scan that could not run refuses it too; not checked is never a pass.
  5. Runs your review command, when one is set. The queue brings no reviewer; it reads the verdict your command writes.
  6. Builds, when set, and checks the tree is still clean.
  7. Deploys, with the commit in DOTIME_RELEASE_COMMIT, then verifies, and rolls back to the last good release if the deploy or verify failed.

The exit code says what happened: 0 released, 5 refused with nothing deployed, 6 rolled back, 7 not restored or unknown. dotime-queue releases lists past releases with their commit, checks and reason.

A deployment queue on your own machine

On hosting platforms, a "deployment queue" is their server lining up deploys. Here the line is on your computer. A release is one job in the same waiting line as the test runs and builds your agents start, so it never starts while the machine is short of memory or disk, and only one release per repository runs at a time. Agents can start it as a shell command or through the MCP tool queue_release.

What it does not do

  • It does not host your app or deploy to any cloud by itself. It runs the deploy command you write.
  • It does not judge your code. The checks are your tests, the review is your command, and the queue does not check that a review took place.
  • gitleaks must be installed. Without it on PATH, every release is refused.
  • The dependency part of the security check sends your lockfile's package list to the npm registry or to OSV.
  • It is no wall against an agent that edits dotime.release.json or holds the deploy credentials and deploys without the queue. It stops honest mistakes.
  • A staged rollout, such as a canary, belongs in your deploy command.