@caddis/cli 0.4.85 → 0.4.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/antigravity-plugin/plugin.json +1 -1
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_exit.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_file_lock.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_frontmatter.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_redact.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_roadmap.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_rows.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_tidy.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_todo.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_workstreams.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/caddis_prod_check.py +59 -11
- package/bundles/manifest.json +2 -2
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc
CHANGED
|
Binary file
|
|
@@ -5,6 +5,10 @@ succeeded (with --docs-only: the deploy job was skipped); (3) the version endpoi
|
|
|
5
5
|
it; (4) the health endpoint JSON has every value `true`, not only HTTP 200; (5) optional: named background jobs were
|
|
6
6
|
attempted after the deploy with zero failures. A repo with no profile gets items 1 and 2 only.
|
|
7
7
|
|
|
8
|
+
Push run (item 1): `[ci] workflow = "<name>"` names the workflow to check. Without it, when several workflows ran on
|
|
9
|
+
the merge SHA (a CI workflow and a Pages one), the run whose jobs hold the deploy job or a required job is used. A job
|
|
10
|
+
of a reusable workflow, listed as `<caller job> / <job>`, counts as `<job>`.
|
|
11
|
+
|
|
8
12
|
Prints one PASS or FAIL line per item and a RESULT line. Exit 0 only when every item passes; 1 when one fails; 3 when
|
|
9
13
|
the profile cannot be read; 4 when the SHA is ambiguous or not found. Read-only: it never writes to GitHub or prod.
|
|
10
14
|
|
|
@@ -69,6 +73,7 @@ def real_runner(cwd: Path) -> Runner:
|
|
|
69
73
|
class Profile:
|
|
70
74
|
found: bool = False
|
|
71
75
|
branch: str = "main"
|
|
76
|
+
workflow: str | None = None # the push workflow to check, when the repo has more than one (e.g. a Pages one)
|
|
72
77
|
required_jobs: list[str] = field(default_factory=list)
|
|
73
78
|
deploy_job: str = "deploy_prod"
|
|
74
79
|
push_run_wait_minutes: float = 10
|
|
@@ -82,7 +87,7 @@ class Profile:
|
|
|
82
87
|
|
|
83
88
|
|
|
84
89
|
_KEY_TYPES: dict[str, type | tuple[type, ...]] = {
|
|
85
|
-
"branch": str, "required_jobs": list, "deploy_job": str, "push_run_wait_minutes": (int, float),
|
|
90
|
+
"branch": str, "workflow": str, "required_jobs": list, "deploy_job": str, "push_run_wait_minutes": (int, float),
|
|
86
91
|
"run_wait_minutes": (int, float), "version_url": str, "version_field": str, "health_url": str, "auth": str,
|
|
87
92
|
"timeout_seconds": int,
|
|
88
93
|
}
|
|
@@ -111,6 +116,9 @@ def load_profile(repo: Path, path: Path | None = None) -> Profile:
|
|
|
111
116
|
if key == "required_jobs" and not all(isinstance(job, str) for job in value):
|
|
112
117
|
raise ValueError(f"{path}: required_jobs must be a list of job names")
|
|
113
118
|
setattr(profile, key, value)
|
|
119
|
+
if profile.workflow is not None and (not profile.workflow.strip()
|
|
120
|
+
or profile.workflow.lower().endswith((".yml", ".yaml"))):
|
|
121
|
+
raise ValueError(f"{path}: workflow must be the workflow's name (its `name:` line), not a file name")
|
|
114
122
|
if profile.auth not in ("none", "ntlm"):
|
|
115
123
|
raise ValueError(f"{path}: auth must be 'none' or 'ntlm'")
|
|
116
124
|
if background is not None:
|
|
@@ -167,16 +175,42 @@ def resolve_sha(ctx: Context, sha: str) -> tuple[int, str]:
|
|
|
167
175
|
|
|
168
176
|
|
|
169
177
|
def push_runs(ctx: Context, limit: int = 20) -> list[dict]:
|
|
170
|
-
|
|
171
|
-
|
|
178
|
+
args = ["run", "list", "--branch", ctx.profile.branch, "--event", "push", "--limit", str(limit),
|
|
179
|
+
"--json", "databaseId,headSha,status,conclusion,workflowName"]
|
|
180
|
+
if ctx.profile.workflow:
|
|
181
|
+
args[2:2] = ["--workflow", ctx.profile.workflow]
|
|
182
|
+
runs = ctx.gh_json(*args)
|
|
183
|
+
if ctx.profile.workflow: # also filter here: the list must never hold another workflow's run
|
|
184
|
+
runs = [r for r in runs if r.get("workflowName") == ctx.profile.workflow] # type: ignore[union-attr]
|
|
185
|
+
return runs # type: ignore[return-value]
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _pick_run(ctx: Context, candidates: list[dict]) -> tuple[dict | None, str]:
|
|
189
|
+
"""(run, state): state is "sure", "wait" (no run lists the jobs yet: they are queued) or "guess" (nothing can
|
|
190
|
+
tell the runs apart). Several workflows can run on one push (serve-sight: `CI and Deploy` and `roadmap-pages`).
|
|
191
|
+
With no `workflow` in the profile, take the run whose jobs hold the deploy job or a required job."""
|
|
192
|
+
if len(candidates) <= 1:
|
|
193
|
+
return (candidates[0] if candidates else None), ("sure" if candidates else "wait")
|
|
194
|
+
wanted = [j for j in (ctx.profile.deploy_job, *ctx.profile.required_jobs) if j]
|
|
195
|
+
if not wanted: # no deploy job and no required jobs: waiting cannot help
|
|
196
|
+
return candidates[0], "guess"
|
|
197
|
+
for run in candidates:
|
|
198
|
+
view = ctx.gh_json("run", "view", str(run["databaseId"]), "--json", "jobs")
|
|
199
|
+
jobs = _jobs(view if isinstance(view, dict) else {})
|
|
200
|
+
if any(_job(jobs, name) is not None for name in wanted):
|
|
201
|
+
return run, "sure"
|
|
202
|
+
return candidates[0], "wait"
|
|
172
203
|
|
|
173
204
|
|
|
174
205
|
def find_push_run(ctx: Context, sha: str) -> dict | None:
|
|
175
206
|
"""Wait up to the profile's minutes for a push run of `sha` to appear."""
|
|
176
207
|
deadline = ctx.clock.now() + ctx.profile.push_run_wait_minutes * 60
|
|
177
208
|
while True:
|
|
178
|
-
run =
|
|
179
|
-
if
|
|
209
|
+
run, state = _pick_run(ctx, [r for r in push_runs(ctx) if r.get("headSha") == sha])
|
|
210
|
+
if state != "wait" or ctx.dry_run or ctx.clock.now() >= deadline:
|
|
211
|
+
if run and state != "sure":
|
|
212
|
+
ctx.out(f"INFO 1 {sha[:12]} has several push runs and none lists {ctx.profile.deploy_job or 'the jobs'}"
|
|
213
|
+
f"; using run {run['databaseId']}. Set `workflow` in .caddis/prod-check.toml")
|
|
180
214
|
return run
|
|
181
215
|
ctx.clock.sleep(15)
|
|
182
216
|
|
|
@@ -197,9 +231,23 @@ def _jobs(view: dict) -> dict[str, str]:
|
|
|
197
231
|
return {j.get("name", ""): (j.get("conclusion") or j.get("status") or "") for j in view.get("jobs", [])}
|
|
198
232
|
|
|
199
233
|
|
|
234
|
+
def _same_job(actual: str, name: str) -> bool:
|
|
235
|
+
"""A job of a reusable workflow is listed as "<caller job> / <job>" (serve-sight: `ci / deploy_prod`)."""
|
|
236
|
+
return actual == name or actual.endswith(" / " + name)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def _job(jobs: dict[str, str], name: str) -> str | None:
|
|
240
|
+
"""The state of job `name`, or None when the run has no such job. When several reusable workflows each have a
|
|
241
|
+
job of that name, a state that is not success wins, so one success never hides a failure."""
|
|
242
|
+
states = [state for actual, state in jobs.items() if _same_job(actual, name)]
|
|
243
|
+
if not states:
|
|
244
|
+
return None
|
|
245
|
+
return next((s for s in states if s != "success"), "success")
|
|
246
|
+
|
|
247
|
+
|
|
200
248
|
def _deploy_done(view: dict, deploy_job: str) -> datetime | None:
|
|
201
249
|
for job in view.get("jobs", []):
|
|
202
|
-
if job.get("name")
|
|
250
|
+
if _same_job(job.get("name", ""), deploy_job) and job.get("completedAt"):
|
|
203
251
|
return _utc(job["completedAt"])
|
|
204
252
|
return None
|
|
205
253
|
|
|
@@ -232,13 +280,13 @@ def check_ci(ctx: Context, sha: str, docs_only: bool) -> tuple[list[str], dict |
|
|
|
232
280
|
ctx.out("jobs: " + ", ".join(f"{name}={state}" for name, state in jobs.items()))
|
|
233
281
|
deploy = ctx.profile.deploy_job
|
|
234
282
|
if docs_only:
|
|
235
|
-
if jobs
|
|
283
|
+
if _job(jobs, deploy) == "skipped" and conclusion == "success":
|
|
236
284
|
ctx.out(f"PASS 2 docs-only: {deploy} skipped, run conclusion success")
|
|
237
285
|
return [], view
|
|
238
286
|
if conclusion != "success":
|
|
239
287
|
ctx.out(f"FAIL 2 docs-only merge, but the run concluded {conclusion}")
|
|
240
288
|
return ["2 jobs"], view
|
|
241
|
-
ctx.out(f"FAIL 2 docs-only merge, but {deploy} = {jobs
|
|
289
|
+
ctx.out(f"FAIL 2 docs-only merge, but {deploy} = {_job(jobs, deploy) or 'absent'}; run the full prod check")
|
|
242
290
|
return ["2 jobs"], view
|
|
243
291
|
if not ctx.profile.found:
|
|
244
292
|
if conclusion == "success":
|
|
@@ -246,11 +294,11 @@ def check_ci(ctx: Context, sha: str, docs_only: bool) -> tuple[list[str], dict |
|
|
|
246
294
|
return [], view
|
|
247
295
|
ctx.out(f"FAIL 2 run conclusion {conclusion}")
|
|
248
296
|
return ["2 jobs"], view
|
|
249
|
-
bad = {name: jobs
|
|
250
|
-
if deploy and jobs
|
|
297
|
+
bad = {name: _job(jobs, name) or "absent" for name in ctx.profile.required_jobs if _job(jobs, name) != "success"}
|
|
298
|
+
if deploy and _job(jobs, deploy) != "success":
|
|
251
299
|
# A code merge that did not deploy fails, also when the job is not listed as required.
|
|
252
300
|
# A repo with no deploy job sets `deploy_job = ""` in its profile.
|
|
253
|
-
bad[deploy] = jobs
|
|
301
|
+
bad[deploy] = _job(jobs, deploy) or "absent"
|
|
254
302
|
if bad:
|
|
255
303
|
skipped = " (skipped without --docs-only)" if bad.get(deploy) == "skipped" else ""
|
|
256
304
|
ctx.out("FAIL 2 " + ", ".join(f"{n}={c}" for n, c in bad.items()) + skipped)
|
package/bundles/manifest.json
CHANGED
package/package.json
CHANGED