Repository navigation
fix: move CI workflow validation out of Worker (#472) - #493
Merged
Merged
Conversation
deployWorkflows() ran a 2.5 s sleep + GET /actions/workflows inside the Cloudflare Worker and retried once after another 5 s if anything was missing. That burned ~7.5 s of wall-clock budget per call and forced a --no-validate workaround for fleet deploys. Split the responsibilities: - backend: deployWorkflows() commits and returns immediately. New validateDeployedWorkflows() helper does one parseability probe with no sleep. New POST /admin/datasets/:id/ci/validate endpoint exposes it. POST /admin/datasets/:id/ci no longer accepts ?validate=false (silently ignored for old CLIs) and no longer surfaces validation_warnings in the response or audit log. - CLI: after addCi() returns, poll validateCi() with 2.5 s then 5 s backoff. Same surface area as before, sleep on the user's machine now. Added 'nemar admin ci validate <id>' for an explicit re-probe. --all fleet deploys skip the poll by default (the per-dataset wait was the original motivation for the --no-validate flag). - tests: tree-batched-commit.test.ts now asserts deployWorkflows() makes exactly 4 calls (no listing) and exercises the new validateDeployedWorkflows() helper independently. Closes #472
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR493Version: 🤖 Updated on each push. |
- admin.ts (fleet path): replace the misleading 'Pass --validate to override' comment. The --all path always skips the parseability poll; --no-validate is a no-op on that path. The help text and a new dim UI line make this explicit. - admin.ts (poll helper): rename loop var to use for...of; extract pollCiValidation into an exported function with an injected ValidationProbe so the polling state machine is unit-testable without a fake backend. Default probe wraps validateCi(); existing call site uses the default. - admin.ts (single-dataset path): distinguish the warn message between 'workflows missing' and 'GitHub API error' — they are independent conditions and the previous wording falsely implied missing when only errors were populated. - backend/services/github.ts: amend validateDeployedWorkflows JSDoc. 'No retries' was misleading — githubFetchWithRetry retries 5xx up to 3 times internally; only the outer indexing-lag retry is gone. - backend/routes/admin.ts: document the conscious POST verb choice on /ci/validate. Strict REST would favor GET but the rest of the ci/* family is POST (deploy, sync) and a mixed-verb family would surprise admin tooling that scripts these endpoints. - test/admin-restructure.test.ts: assert the new 'validate' subcommand appears in 'admin ci --help' so future refactors can't silently drop it. - test/poll-ci-validation.test.ts: 6 new unit tests covering early stop on all-clear, early stop on errors, retry on missing-only, loop exhaustion, network-throw → null, and backoff cadence. Uses a queued probe injected via the new optional parameter; no fake server. Review findings: #493
Contributor
Author
Review triage (from
|
| Severity | Finding | Action |
|---|---|---|
| Important | Misleading "Pass --validate to override" comment on fleet path; skipValidate was computed but never consulted |
Fixed in 4b60099 — comment rewritten; help text updated; --all path now prints a dim "poll skipped for --all" line so behavior is explicit |
| Important | POST /ci/validate should arguably be GET (read-only) | Decision: keep POST. Added route-level doc explaining the conscious choice — ci/* family is POST (deploy, sync) and a mixed-verb family would surprise admin tooling scripting these endpoints |
| Important | admin ci --help test doesn't assert validate subcommand |
Fixed in 4b60099 — admin-restructure.test.ts now also asserts sync and validate |
| Suggestion | validateSpinner.warn imprecise when only errors populated |
Fixed — distinguish "workflows missing" vs "GitHub API error" wording |
| Suggestion | pollCiValidation for-loop index i unused |
Fixed — switched to for...of |
| Suggestion | JSDoc on validateDeployedWorkflows says "no retries" but githubFetchWithRetry has internal 5xx retries | Fixed — JSDoc now distinguishes outer (gone) vs transport (internal) retries |
| Suggestion | pollCiValidation polling state machine untested | Added test/poll-ci-validation.test.ts — 6 tests covering early-stop on all-clear, early-stop on errors, retry on missing-only, loop exhaustion, throw→null, backoff cadence. Uses injected probe (new exported ValidationProbe type) so no fake backend needed |
| Pre-existing | Old CLIs read validation_warnings from response; field is now absent |
Already analyzed in review: old CLI does r.validation_warnings && r.validation_warnings.length > 0 — undefined short-circuits, silent acceptable degradation. New CLIs hitting an old backend that lacks /ci/validate get 404 → pollCiValidation catches → returns null → "Could not verify" warning. Graceful both ways |
| Pre-existing | Audit-log validation_warnings dropped | No audit consumer reads it (best-effort annotation). Non-critical |
…poll-ci-validation
This was referenced May 14, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Move the post-deploy parseability check out of the Cloudflare Worker. The previous design slept 2.5 s inside
deployWorkflows()and retried once after another 5 s, burning ~7.5 s of wall-clock budget per call and requiring a--no-validateworkaround for fleet deploys.deployWorkflows()commits and returns immediately. Dropsvalidate/validateDelayMsoptions andvalidationErrorsfrom the return.validateDeployedWorkflows()helper does a single GET against/actions/workflows(no sleep).POST /admin/datasets/:id/ci/validateexposes the helper.POST /admin/datasets/:id/cino longer surfacesvalidation_warningsin its response or audit log; the legacy?validate=falsequery param is accepted but ignored for old-CLI compatibility.addCi()returns, pollvalidateCi()with[2.5 s, 5 s]backoff (the old worker timing, now client-side).nemar admin ci validate <id>subcommand for an explicit re-probe.--allfleet deploys skip the poll by default — the per-dataset wait was the original motivation for--no-validate.--no-validateflag stays for the single-dataset path (no-ops when set).tree-batched-commit.test.tsnow assertsdeployWorkflows()makes exactly 4 GitHub calls (no listing). The three former in-Worker validation tests moved to a newdescribe('validateDeployedWorkflows', ...)block that exercises the helper directly (all-listed, partial listing, 500 error path).Closes #472. (Follow-up from PR #469.)
Test plan
bun test test/tree-batched-commit.test.ts— 24/24 passbun test test/tree-batched-commit.test.ts test/config-migrate-api-url.test.ts test/publish-progress.test.ts— 37/37 passcd backend && bun test— 74/74 passbun run build— greentsc --noEmitfor CLI and backend — greenbun dist/index.js admin ci --helpshows the newvalidatesubcommand