From dd8af2dd59373c6b127fa09a0705de770c83633f Mon Sep 17 00:00:00 2001
From: Marius S <39998+winding-lines@users.noreply.github.com>
Date: Mon, 30 Nov 2026 17:25:16 -0800
Subject: [PATCH 1/3] Record what each repo's own CI said of its Mojo version
moves
A new daily pipeline, mojo_ci (09:00 UTC), asks GitHub for the workflow
runs on each commit that moved a repo to another Mojo version and keeps
the answer in mojo.migration_ci: passed, failed, running, none, gone or
blocked, with the counts of the repo's own workflows. Runs GitHub starts
itself (paths under dynamic/) are left out.
It asks about commits of the last 270 days that have no settled answer
yet, newest first, at most 1,500 a run, and stops asking about a commit
three days after it, once its runs have finished. GitHub drops run
records after some months, so older commits have nothing to give.
The site shows it in three places: a CI column beside each migration on
a repo page, a "What their CI said" table per Mojo version on
/migrations, and a "ci" object on each migration in
/api/repos//.
Co-Authored-By: Claude Fable 5.2
Claude-Session: https://claude.ai/code/session_017TycsxF3PkSX49fnv7cSZd
---
README.md | 16 ++
morca.dev.toml | 7 +
morca.toml | 7 +
pipelines/mojo_ci.mojo | 149 ++++++++++++++
pixi.toml | 3 +-
src/ci.mojo | 335 +++++++++++++++++++++++++++++++
src/console_api.mojo | 17 +-
src/console_cache.mojo | 17 +-
src/console_migrations_body.mojo | 60 +++++-
src/console_repo.mojo | 41 +++-
src/lake.mojo | 25 +++
src/model.mojo | 1 +
tests/test_ci.mojo | 211 +++++++++++++++++++
tests/test_console_routes.mojo | 72 ++++++-
14 files changed, 951 insertions(+), 10 deletions(-)
create mode 100644 pipelines/mojo_ci.mojo
create mode 100644 src/ci.mojo
create mode 100644 tests/test_ci.mojo
diff --git a/README.md b/README.md
index e3bf7b0..4591989 100644
--- a/README.md
+++ b/README.md
@@ -244,6 +244,22 @@ GH Archive ──gharchive──▶ gharchive.events ──mojo_repos──▶ m
key (morca.toml) with mojo_history, mojo_retool and mojo_versions, so the
writers of these tables take turns. `src/refresh.mojo` has the selection;
`tests/test_refresh.mojo` tests it.
+- **`pipelines/mojo_ci.mojo`**: daily at 09:00 UTC, what each repository's
+ own CI said of the commits that moved it to another Mojo version. For each
+ `mojo_version` row of `mojo.migrations` no older than 270 days it asks
+ GitHub for the workflow runs on that commit (`GET
+ /repos/{owner}/{repo}/actions/runs?head_sha=…`, one request a commit) and
+ keeps one row per repository and commit in `mojo.migration_ci`: `passed`,
+ `failed`, `running` or `none`, with the runs counted. Only the
+ repository's own workflows count (a run GitHub starts by itself, such as
+ code scanning's default setup, has a `path` under `dynamic/`), and what a
+ workflow does isn't looked at. A commit is asked again each day until it
+ is three days old and nothing is still running, then never again; GitHub
+ stops listing a commit's runs after some months, so the row is the record.
+ Newest first, at most `MOJO_CI_MAX_REQUESTS` (1500) a run. The repo pages
+ show the answer beside each migration, and `/migrations` counts, per Mojo
+ version, the repositories whose CI passed or failed on the commit that
+ moved them. `src/ci.mojo` has the rules; `tests/test_ci.mojo` tests them.
- **`bin/console.mojo`**: an overview (`/`: repos, commits and lines of
Mojo with their change over 30 days, repos per Mojo version family,
monthly curves from `mojo.commits`, adoption of the newest version,
diff --git a/morca.dev.toml b/morca.dev.toml
index ed4e5b0..840cba0 100644
--- a/morca.dev.toml
+++ b/morca.dev.toml
@@ -90,6 +90,13 @@ env = { MOJO_EMBED_MODEL = "/tmp/mojo-census/models/bge-small-en-v1.5" }
memory_gb = "auto"
secrets = { GITHUB_TOKEN = "orca/github-token" }
+# Daily at 09:00 UTC, an hour after mojo_issues (they share the token's
+# hourly limit): the workflow runs on each commit that moved a repository
+# to another Mojo version, one request a commit, at most 1,500 a run.
+[pipelines.mojo_ci]
+memory_gb = "auto"
+secrets = { GITHUB_TOKEN = "orca/github-token" }
+
# The Live page's poller: one run an hour that polls every 3 minutes, over
# GitHub's GraphQL API (its own rate limit: about 13 points a poll).
[pipelines.mojo_live]
diff --git a/morca.toml b/morca.toml
index c4d1f44..2abcd12 100644
--- a/morca.toml
+++ b/morca.toml
@@ -143,6 +143,13 @@ env = { MOJO_EMBED_MODEL = "/tmp/mojo-census/models/bge-small-en-v1.5" }
memory_gb = "auto"
secrets = { GITHUB_TOKEN = "orca/github-token" }
+# Daily at 09:00 UTC, an hour after mojo_issues (they share the token's
+# hourly limit): the workflow runs on each commit that moved a repository
+# to another Mojo version, one request a commit, at most 1,500 a run.
+[pipelines.mojo_ci]
+memory_gb = "auto"
+secrets = { GITHUB_TOKEN = "orca/github-token" }
+
# The Live page's poller: one run an hour that polls every 3 minutes, over
# GitHub's GraphQL API (its own rate limit: about 13 points a poll).
[pipelines.mojo_live]
diff --git a/pipelines/mojo_ci.mojo b/pipelines/mojo_ci.mojo
new file mode 100644
index 0000000..6eb068b
--- /dev/null
+++ b/pipelines/mojo_ci.mojo
@@ -0,0 +1,149 @@
+"""Asks GitHub what each repository's own CI said of the commits that moved it to another Mojo version, into mojo.migration_ci.
+
+Daily partitions from 2026-11-30, each filled at 09:00 UTC for that day
+(`fire=Current`), an hour after mojo_issues so the two don't share an hour
+of GitHub's rate limit. For each `mojo_version` row of `mojo.migrations`
+no older than 270 days that has no settled answer yet, the step asks for
+the workflow runs on its commit
+(`GET /repos/{owner}/{repo}/actions/runs?head_sha=…`): one request a
+commit. A commit is asked again each day until it is three days old and
+none of its runs is still going, and never after. A day's run merges the
+answers into the table and rewrites it (`replace.replace_files`): one row
+per repository and commit, as GitHub had it last (`ci.mojo`).
+
+Newest commits first, at most MOJO_CI_MAX_REQUESTS (1500) a run; what's
+left comes the next day, so a first run over a year of migrations takes a
+few days. A rate limit is waited out for at most MOJO_CI_MAX_WAIT seconds
+(3900) in all.
+
+ GITHUB_TOKEN=... ./build/mojo_ci run --partitions 2026-11-30
+"""
+
+from std.os import getenv, setenv
+
+from morca import Cron, Ctx, Current, Daily, Day, Mapped, Pipeline, Step, morca_main
+from morca.civil import now
+from morca.tables import ensure_table, scan, table
+
+from ci import CiRow, ci_batch, ci_of, ci_rows, merge_ci, select_due
+from cols import col, i64_at, str_at
+from lake import MIGRATIONS, MIGRATION_CI, migration_ci_schema
+from model import Migration
+from replace import replace_files
+
+
+def _migrations(mut ctx: Ctx) raises -> List[Migration]:
+ """Every row of `mojo.migrations` (at the step's pinned snapshot)."""
+ var out = List[Migration]()
+ var t = table(ctx, MIGRATIONS)
+ for b in scan(ctx, t).to_batches():
+ var c_repo = col(b, "repo")
+ var c_sha = col(b, "sha")
+ var c_at = col(b, "committed_at")
+ var c_kind = col(b, "kind")
+ var c_from = col(b, "from_value")
+ var c_to = col(b, "to_value")
+ for r in range(b.num_rows):
+ out.append(
+ Migration(
+ str_at(b.column(c_repo), r),
+ str_at(b.column(c_sha), r),
+ i64_at(b.column(c_at), r),
+ str_at(b.column(c_kind), r),
+ str_at(b.column(c_from), r),
+ str_at(b.column(c_to), r),
+ )
+ )
+ return out^
+
+
+def fetch(mut ctx: Ctx, d: Day) raises -> Int:
+ """Asks GitHub about the commits that are due, merges the answers into
+ mojo.migration_ci and rewrites the table. Returns the commits answered."""
+ var ms = _migrations(ctx)
+ var t = ensure_table(ctx, MIGRATION_CI, migration_ci_schema())
+ var max_wait = Int(getenv("MOJO_CI_MAX_WAIT", "3900"))
+ var limit = Int(getenv("MOJO_CI_MAX_REQUESTS", "1500"))
+
+ # The current rows, and the files they are in: the commit below removes
+ # every file, so the rows read must add up to what the files hold.
+ var old = List[CiRow]()
+ var files = List[String]()
+ var file_rows = Int64(0)
+ if t.metadata.has_current_snapshot:
+ for task in scan(ctx, t).plan_files():
+ files.append(task.data_file.file_path)
+ file_rows += task.data_file.record_count
+ for b in scan(ctx, t).to_batches():
+ for ref r in ci_rows(b):
+ old.append(r.copy())
+ if Int64(len(old)) != file_rows:
+ raise Error(MIGRATION_CI, ": read ", len(old), " rows but its files hold ", file_rows)
+
+ var due = select_due(ms, old, now() * 1_000_000, limit)
+ var fetched = List[CiRow]()
+ var calls = 0
+ var waited = 0
+ var remaining = -1
+ var states = Dict[String, Int]()
+ for ref m in due:
+ var a = ci_of(m, max_wait - waited)
+ calls += a.calls
+ waited += a.waited_s
+ remaining = a.remaining
+ if not a.row:
+ states[a.error] = states.get(a.error, 0) + 1
+ ctx.log(String(m.repo, " ", m.sha, ": ", a.error))
+ continue
+ var state = a.row.value().state
+ states[state] = states.get(state, 0) + 1
+ fetched.append(a.row.value().copy())
+ var summary = String()
+ for e in states.items():
+ summary += String(" ", e.key, "=", e.value)
+ ctx.log(String(
+ String(d), ": ", len(due), " commits in ", calls, " requests (",
+ waited, " s waiting on the rate limit; ", remaining, " left):", summary,
+ ))
+ if len(fetched) == 0:
+ ctx.log("nothing answered; nothing to commit")
+ return 0
+ var before = len(old)
+ var rows = merge_ci(old^, fetched)
+ # One `overwrite` snapshot removing `files` and adding `rows`; safe
+ # because one run writes the table at a time (max_runs 1).
+ var id = replace_files(ctx, t, files, [ci_batch(rows)])
+ ctx.log(String(MIGRATION_CI, " ", before, " -> ", len(rows), " rows; snapshot ", id))
+ return len(fetched)
+
+
+# `Mapped`: once per partition, here a `Day`. No dista task: the requests
+# are made one at a time by the step itself, within GitHub's rate limit.
+comptime Fetch = Step[
+ "fetch",
+ Day,
+ Int,
+ fetch,
+ Mapped,
+ retries=1,
+ reads=[MIGRATIONS, MIGRATION_CI],
+ # replaces=: a rerun rewrites the table (replace.replace_files) rather
+ # than adding rows again, so `morca backfill --rerun` needs no
+ # --allow-append.
+ replaces=[MIGRATION_CI],
+]
+# A day's run asks about whatever is due, so a missed day needs no catch-up.
+comptime MojoCi = Pipeline[
+ "mojo_ci",
+ Fetch,
+ partitions=Daily["2026-11-30"],
+ schedule=Cron["0 9 * * *"],
+ fire=Current,
+ catchup=False,
+]
+
+
+def main() raises:
+ if not getenv("MORCA_WAREHOUSE"):
+ _ = setenv("MORCA_WAREHOUSE", "build/warehouse")
+ morca_main[MojoCi]()
diff --git a/pixi.toml b/pixi.toml
index 76f0e62..2eb8f44 100644
--- a/pixi.toml
+++ b/pixi.toml
@@ -23,10 +23,11 @@ build-mojo-stats = "mkdir -p build && rm -f build/mojo_stats && mojo build -I sr
build-gharchive-index = "mkdir -p build && rm -f build/gharchive_index && mojo build -I src pipelines/gharchive_index.mojo -o build/gharchive_index"
build-mojo-embed = "mkdir -p build && rm -f build/mojo_embed && mojo build -I src pipelines/mojo_embed.mojo -o build/mojo_embed"
build-mojo-issues = "mkdir -p build && rm -f build/mojo_issues && mojo build -I src pipelines/mojo_issues.mojo -o build/mojo_issues"
+build-mojo-ci = "mkdir -p build && rm -f build/mojo_ci && mojo build -I src pipelines/mojo_ci.mojo -o build/mojo_ci"
build-mojo-live = "mkdir -p build && rm -f build/mojo_live && mojo build -I src pipelines/mojo_live.mojo -o build/mojo_live"
build-mojo-retool = "mkdir -p build && rm -f build/mojo_retool && mojo build -I src pipelines/mojo_retool.mojo -o build/mojo_retool"
build-mojo-refresh = "mkdir -p build && rm -f build/mojo_refresh && mojo build -I src pipelines/mojo_refresh.mojo -o build/mojo_refresh"
-build-pipelines = { depends-on = ["build-gharchive", "build-gharchive-index", "build-mojo-repos", "build-mojo-history", "build-mojo-retool", "build-mojo-versions", "build-mojo-activity", "build-mojo-stats", "build-mojo-embed", "build-mojo-issues", "build-mojo-live", "build-mojo-refresh"] }
+build-pipelines = { depends-on = ["build-gharchive", "build-gharchive-index", "build-mojo-repos", "build-mojo-history", "build-mojo-retool", "build-mojo-versions", "build-mojo-activity", "build-mojo-stats", "build-mojo-embed", "build-mojo-issues", "build-mojo-ci", "build-mojo-live", "build-mojo-refresh"] }
# Every program, as in the image: two multi-call binaries,
# build/multicall-apps and build/multicall-pipelines, and build/morca,
# build/gharchive... as links to them (scripts/build.sh), so the code they
diff --git a/src/ci.mojo b/src/ci.mojo
new file mode 100644
index 0000000..3d83187
--- /dev/null
+++ b/src/ci.mojo
@@ -0,0 +1,335 @@
+"""What a repository's own CI said about a commit, for `mojo.migration_ci`.
+
+A repository that moves to another Mojo version and runs its CI on that
+commit has tested the version for the census. `parse_runs` reads GitHub's
+workflow runs of a commit (`GET /repos/{owner}/{repo}/actions/runs?head_sha=…`)
+into one `CiRow`; `ci_of` asks, waiting out rate limits as mojo_stats does;
+`select_due` picks the migrations to ask about; `ci_by_version` counts the
+answers per Mojo version, for the Migrations page.
+
+Only the repository's own workflows count: a run GitHub starts by itself
+(code scanning's default setup, Pages, Dependabot) has a `path` under
+`dynamic/` and is left out. What a workflow does is not looked at, so a
+`passed` says the repository's workflows passed on that commit, not that
+they built Mojo.
+"""
+
+from std.time import sleep
+
+from morca.civil import now
+from morca.tables import BatchBuilder
+from parquet import RecordBatch
+
+from cols import col, i64_at, str_at
+from detect import long_of
+from fetch import github
+from jscan import Range, each, field, text
+from lake import migration_ci_schema, try_load
+from model import Migration
+from overview import DAY_US
+from stats import limited, state_of, wait_seconds
+from versions import compare_versions
+
+
+comptime MAX_AGE_DAYS = 270
+"""How old a commit can be and still be asked about. GitHub no longer lists
+the runs of a commit after some months (bgreni/EmberJson's stop about ten
+months back), and a commit with none reads the same as one whose runs are
+gone."""
+comptime SETTLE_DAYS = 3
+"""A commit younger than this is asked about again on each run: its CI may
+not have started when it was first asked, and a failed run may be run
+again."""
+
+
+@fieldwise_init
+struct CiRow(Copyable, Movable):
+ var repo: String
+ var sha: String
+ var committed_at: Int64
+ """Microseconds since the epoch, as are `checked_at`."""
+ var state: String
+ """`passed`: a workflow succeeded and none failed. `failed`: one failed.
+ `running`: none failed and one hasn't finished. `none`: no run of the
+ repository's own workflows, or only skipped and cancelled ones. `gone`
+ or `blocked`: GitHub no longer answers for the repository."""
+ var runs: Int64
+ var passed: Int64
+ var failed: Int64
+ var checked_at: Int64
+
+ def settled(self, now_us: Int64) -> Bool:
+ """Whether the row is final: not `running`, and its commit old enough
+ that its runs won't change."""
+ return self.state != "running" and now_us - self.committed_at >= Int64(SETTLE_DAYS) * DAY_US
+
+
+def _key(repo: String, sha: String) -> String:
+ return String(repo, " ", sha)
+
+
+def parse_runs(repo: String, sha: String, committed_at: Int64, body: String, checked_at: Int64) -> CiRow:
+ """The row of a commit from GitHub's list of its workflow runs (the first
+ 100, which is more than a commit has)."""
+ var b = body.as_bytes()
+ var runs = Int64(0)
+ var passed = Int64(0)
+ var failed = Int64(0)
+ var running = Int64(0)
+ for it in each(b, field(b, Range(0, len(b)), "workflow_runs")):
+ if text(b, field(b, it, "path")).startswith("dynamic/"):
+ continue
+ runs += 1
+ if text(b, field(b, it, "status")) != "completed":
+ running += 1
+ continue
+ var conclusion = text(b, field(b, it, "conclusion"))
+ if conclusion == "success":
+ passed += 1
+ elif conclusion == "failure" or conclusion == "timed_out" or conclusion == "startup_failure":
+ failed += 1
+ var state = String("none")
+ if failed > 0:
+ state = String("failed")
+ elif running > 0:
+ state = String("running")
+ elif passed > 0:
+ state = String("passed")
+ return CiRow(repo, sha, committed_at, state^, runs, passed, failed, checked_at)
+
+
+@fieldwise_init
+struct Asked(Movable):
+ """What `ci_of` found: the row, or none for a reply that is neither an
+ answer nor a missing repository (`error`, which says what it was); the
+ requests made, the seconds waited and the rate limit left."""
+
+ var row: Optional[CiRow]
+ var error: String
+ var calls: Int
+ var waited_s: Int
+ var remaining: Int
+
+
+def ci_of(m: Migration, max_wait_s: Int) raises -> Asked:
+ """Asks GitHub for the workflow runs on migration `m`'s commit, waiting
+ out rate limits for at most `max_wait_s` seconds in all; raises when
+ that isn't enough."""
+ var calls = 0
+ var waited = 0
+ var attempt = 0
+ while True:
+ var r = github(String("/repos/", m.repo, "/actions/runs?head_sha=", m.sha, "&per_page=100"))
+ calls += 1
+ if limited(r):
+ var w = wait_seconds(r, Int(now()), attempt)
+ if waited + w > max_wait_s:
+ raise Error(
+ m.repo, ": GitHub's rate limit (HTTP ", r.status,
+ ") would take ", w, " s more after ", waited, " s",
+ )
+ sleep(Float64(w))
+ waited += w
+ attempt += 1
+ continue
+ if r.status >= 500 and attempt < 3:
+ sleep(Float64(5 * (attempt + 1)))
+ waited += 5 * (attempt + 1)
+ attempt += 1
+ continue
+ var at = now() * 1_000_000
+ if r.status == 200:
+ return Asked(parse_runs(m.repo, m.sha, m.at, r.body, at), String(), calls, waited, r.remaining)
+ var state = state_of(r.status)
+ if state == "gone" or state == "blocked":
+ return Asked(
+ CiRow(m.repo, m.sha, m.at, state^, 0, 0, 0, at), String(), calls, waited, r.remaining
+ )
+ # Anything else is asked again by the next run.
+ return Asked(None, state^, calls, waited, r.remaining)
+
+
+def select_due(ms: List[Migration], known: List[CiRow], now_us: Int64, limit: Int) -> List[Migration]:
+ """The migrations to ask GitHub about now, newest first and at most
+ `limit`: each change of Mojo version (once per repository and commit)
+ no older than `MAX_AGE_DAYS` whose row isn't `settled`."""
+ var final = Dict[String, Bool]()
+ for ref r in known:
+ if r.settled(now_us):
+ final[_key(r.repo, r.sha)] = True
+ var due = List[Migration]()
+ var seen = Dict[String, Bool]()
+ for ref m in ms:
+ if m.kind != "mojo_version" or m.sha.byte_length() == 0:
+ continue
+ if now_us - m.at > Int64(MAX_AGE_DAYS) * DAY_US:
+ continue
+ var k = _key(m.repo, m.sha)
+ if k in final or k in seen:
+ continue
+ seen[k] = True
+ due.append(m.copy())
+ for i in range(1, len(due)):
+ var j = i
+ while j > 0 and due[j - 1].at < due[j].at:
+ due.swap_elements(j - 1, j)
+ j -= 1
+ while len(due) > limit:
+ _ = due.pop()
+ return due^
+
+
+def merge_ci(var old: List[CiRow], new: List[CiRow]) -> List[CiRow]:
+ """`old` with each row of `new` in place of the row of the same
+ repository and commit (or added)."""
+ var at = Dict[String, Int]()
+ for i in range(len(old)):
+ at[_key(old[i].repo, old[i].sha)] = i
+ for ref r in new:
+ var k = _key(r.repo, r.sha)
+ var i = at.get(k, -1)
+ if i >= 0:
+ old[i] = r.copy()
+ else:
+ at[k] = len(old)
+ old.append(r.copy())
+ return old^
+
+
+def ci_rows(b: RecordBatch) raises -> List[CiRow]:
+ """The rows of a scanned `mojo.migration_ci` batch."""
+ var c = List[Int]()
+ for name in ["repo", "sha", "committed_at", "state", "runs", "passed", "failed", "checked_at"]:
+ c.append(col(b, name))
+ var out = List[CiRow]()
+ for r in range(b.num_rows):
+ out.append(
+ CiRow(
+ str_at(b.column(c[0]), r),
+ str_at(b.column(c[1]), r),
+ i64_at(b.column(c[2]), r),
+ str_at(b.column(c[3]), r),
+ i64_at(b.column(c[4]), r),
+ i64_at(b.column(c[5]), r),
+ i64_at(b.column(c[6]), r),
+ i64_at(b.column(c[7]), r),
+ )
+ )
+ return out^
+
+
+def ci_batch(rows: List[CiRow]) raises -> RecordBatch:
+ """`rows` as a batch of `mojo.migration_ci`."""
+ var b = BatchBuilder(migration_ci_schema())
+ var cs = b.roots.copy()
+ for ref r in rows:
+ b.add_str(cs[0], r.repo)
+ b.add_str(cs[1], r.sha)
+ b.add_int(cs[2], r.committed_at)
+ b.add_str(cs[3], r.state)
+ b.add_int(cs[4], r.runs)
+ b.add_int(cs[5], r.passed)
+ b.add_int(cs[6], r.failed)
+ b.add_int(cs[7], r.checked_at)
+ return b^.build()
+
+
+def read_ci() raises -> List[CiRow]:
+ """mojo.migration_ci's current snapshot; empty when the table doesn't
+ exist yet."""
+ var rows = List[CiRow]()
+ var t = try_load("mojo", "migration_ci")
+ if not t or not t.value().metadata.has_current_snapshot:
+ return rows^
+ for b in t.value().scan().to_batches():
+ for ref r in ci_rows(b):
+ rows.append(r.copy())
+ return rows^
+
+
+def by_repo(rows: List[CiRow]) -> Dict[String, List[CiRow]]:
+ """`rows` by repository, for the repo pages."""
+ var out = Dict[String, List[CiRow]]()
+ for ref r in rows:
+ if r.repo not in out:
+ out[r.repo] = List[CiRow]()
+ try:
+ out[r.repo].append(r.copy())
+ except:
+ pass
+ return out^
+
+
+def ci_at(rows: List[CiRow], sha: String) -> Optional[CiRow]:
+ """The row of commit `sha` among a repository's, if it has one."""
+ for ref r in rows:
+ if r.sha == sha:
+ return r.copy()
+ return None
+
+
+@fieldwise_init
+struct VersionCi(Copyable, Movable):
+ """Of the repositories that moved to a Mojo version, how many ran their
+ own CI on the commit that moved them, and what it said."""
+
+ var version: String
+ var moved: Int
+ """Repositories with a commit that moved them to the version."""
+ var passed: Int
+ var failed: Int
+ var failed_repos: List[String]
+ """Those whose CI failed, by name."""
+
+ def ran(self) -> Int:
+ return self.passed + self.failed
+
+
+def ci_by_version(ms: List[Migration], rows: List[CiRow]) -> List[VersionCi]:
+ """`VersionCi` per Mojo version moved to (`to_value`), newest version
+ first, for the versions some repository's CI ran on. A repository counts
+ once per version, by its latest commit that moved it there and has a
+ `passed` or `failed` row. `ms` is oldest first (`model.migrations`)."""
+ var state = Dict[String, String]()
+ for ref r in rows:
+ if r.state == "passed" or r.state == "failed":
+ state[_key(r.repo, r.sha)] = r.state
+ # Per version and repository: what its CI said, or "" for a move with no
+ # answer. A later move replaces an earlier one only if it has an answer.
+ var latest = Dict[String, String]()
+ for ref m in ms:
+ if m.kind != "mojo_version" or m.to_value.byte_length() == 0:
+ continue
+ var k = String(m.to_value, " ", m.repo)
+ var s = state.get(_key(m.repo, m.sha), String())
+ if s.byte_length() > 0 or k not in latest:
+ latest[k] = s
+ var at = Dict[String, Int]()
+ var all = List[VersionCi]()
+ for e in latest.items():
+ var parts = e.key.split(" ")
+ var version = String(parts[0])
+ var i = at.get(version, -1)
+ if i < 0:
+ i = len(all)
+ at[version] = i
+ all.append(VersionCi(version, 0, 0, 0, List[String]()))
+ all[i].moved += 1
+ if e.value == "passed":
+ all[i].passed += 1
+ elif e.value == "failed":
+ all[i].failed += 1
+ all[i].failed_repos.append(String(parts[1]))
+ var out = List[VersionCi]()
+ for ref v in all:
+ if v.ran() == 0:
+ continue
+ var x = v.copy()
+ sort(x.failed_repos)
+ out.append(x^)
+ for i in range(1, len(out)):
+ var j = i
+ while j > 0 and compare_versions(out[j - 1].version, out[j].version) < 0:
+ out.swap_elements(j - 1, j)
+ j -= 1
+ return out^
diff --git a/src/console_api.mojo b/src/console_api.mojo
index 52da1ef..849e27d 100644
--- a/src/console_api.mojo
+++ b/src/console_api.mojo
@@ -21,6 +21,7 @@ from console_list import _matches, meaning_hits
from similar import Neighbor
from issues import IssueRow
from categories import CATEGORIES_VERSION
+from ci import CiRow, ci_at
def _q(s: String) -> String:
@@ -343,6 +344,19 @@ def over_time_json(l: Library, data: RepoData) -> String:
return out^
+def _ci_json(ci: List[CiRow], sha: String) -> String:
+ """A migration's `"ci"`: what the repo's own workflows said of its
+ commit (mojo.migration_ci), or null before mojo_ci has an answer."""
+ var found = ci_at(ci, sha)
+ if not found:
+ return String("null")
+ ref r = found.value()
+ return String(
+ '{"state":', _q(r.state), ',"runs":', r.runs, ',"passed":', r.passed,
+ ',"failed":', r.failed, ',"checked_at":', _q(micros_to_iso(r.checked_at)), "}",
+ )
+
+
def repo_json(req: Request, c: Cache) raises -> Response:
try:
var repo = String(req.param("owner"), "/", req.param("name"))
@@ -361,7 +375,8 @@ def repo_json(req: Request, c: Cache) raises -> Response:
first = False
out.write(
'{"at":', _q(micros_to_iso(m.at)), ',"sha":', _q(m.sha), ',"kind":',
- _q(m.kind), ',"from":', _q(m.from_value), ',"to":', _q(m.to_value), "}",
+ _q(m.kind), ',"from":', _q(m.from_value), ',"to":', _q(m.to_value),
+ ',"ci":', _ci_json(data.ci, m.sha), "}",
)
out += '],"commits":['
first = True
diff --git a/src/console_cache.mojo b/src/console_cache.mojo
index 39df011..47abb1a 100644
--- a/src/console_cache.mojo
+++ b/src/console_cache.mojo
@@ -40,6 +40,7 @@ from overview import (
unversioned,
)
+from ci import CiRow, ci_by_version, read_ci
from console_migrations_body import _migrations_body
from measures import Measure, latest_measures
from issues import RepoIssues, add_issue_months, read_issue_rows, summarize
@@ -67,6 +68,8 @@ struct RepoData(Copyable, Movable):
var pts: List[Point]
"""Its commits, oldest first."""
var ms: List[Migration]
+ var ci: List[CiRow]
+ """What its CI said of the commits of `ms` (mojo.migration_ci)."""
var rels: List[Release]
var acts: List[MonthActivity]
var issues: RepoIssues
@@ -77,6 +80,7 @@ struct RepoData(Copyable, Movable):
def __init__(out self):
self.pts = List[Point]()
self.ms = List[Migration]()
+ self.ci = List[CiRow]()
self.rels = List[Release]()
self.acts = List[MonthActivity]()
self.issues = RepoIssues()
@@ -370,6 +374,17 @@ struct Cache(Movable):
if m.repo not in details:
details[m.repo] = RepoData()
details[m.repo].ms.append(m.copy())
+ # mojo.migration_ci's rows under the same keys as the migrations.
+ var kept_ci = List[CiRow]()
+ for ref r in read_ci():
+ if _duplicate(r.repo, key_of, name_of):
+ continue
+ var rr = r.copy()
+ rr.repo = key_of.get(r.repo, r.repo)
+ if rr.repo in details:
+ details[rr.repo].ci.append(rr.copy())
+ kept_ci.append(rr^)
+ var version_ci = ci_by_version(kept_ms, kept_ci)
for e in releases_all().items():
var cur = name_of.get(e.key.lower(), e.key)
if cur not in details:
@@ -399,7 +414,7 @@ struct Cache(Movable):
details[cur] = RepoData()
details[cur].contributors = e.value.copy()
self.loaded = activity_months()
- self.migrations_body = _migrations_body(rows) if len(rows) > 0 else String()
+ self.migrations_body = _migrations_body(rows, version_ci) if len(rows) > 0 else String()
self.version_rows = rows^
self.details = details^
self.commits30 = commits30.copy()
diff --git a/src/console_migrations_body.mojo b/src/console_migrations_body.mojo
index fc37bf5..f18580b 100644
--- a/src/console_migrations_body.mojo
+++ b/src/console_migrations_body.mojo
@@ -5,6 +5,7 @@ chart uses too."""
from flare.http import html_escape
from charts import grid_line
+from ci import VersionCi
from model import VersionMonth
from overview import bucket_color
from search import sort_buckets, version_bucket
@@ -155,13 +156,66 @@ def _migrations_head() -> String:
)
-def _migrations_body(rows: List[VersionMonth]) raises -> String:
- """The Migrations page's HTML for `rows` (at least one), rendered once
- per cache build."""
+comptime CI_VERSIONS_SHOWN = 20
+"""How many versions the CI table lists, newest first."""
+comptime CI_FAILED_SHOWN = 5
+"""How many of a version's repos with failed CI the table names."""
+
+
+def _ci_table(ci: List[VersionCi]) -> String:
+ """What the repos' own CI said of the commit that moved them to each
+ version (`ci.ci_by_version`), newest version first; nothing before
+ mojo_ci has an answer."""
+ if len(ci) == 0:
+ return String()
+ var h = String(
+ "What their CI said",
+ _help(
+ "h-ci", "what their CI said",
+ "Of the repos that moved to a version, the ones whose own GitHub Actions workflows"
+ " ran on the commit that moved them, and whether they passed. A repo counts once per"
+ " version, by its latest such commit. Runs GitHub starts by itself (code scanning's"
+ " default setup, Pages) are left out, and what a workflow does isn't looked at: a"
+ " pass or a failure is the repo's CI on that commit, which can have other causes"
+ " than the Mojo version. GitHub keeps a commit's runs for some months, so versions"
+ " from before mojo_ci started may be missing. Read daily by mojo_ci.",
+ ),
+ "
| Version | Repos moved | ",
+ "Ran CI | Passed | Failed | ",
+ "Failed in |
",
+ )
+ for i in range(min(len(ci), CI_VERSIONS_SHOWN)):
+ ref v = ci[i]
+ h.write(
+ "| ", html_escape(v.version), " | ", v.moved,
+ " | ", v.ran(), " | ", v.passed,
+ " | ", v.failed, " | ",
+ )
+ if v.failed == 0:
+ h.write("–")
+ for k in range(min(len(v.failed_repos), CI_FAILED_SHOWN)):
+ ref repo = v.failed_repos[k]
+ h.write(
+ ", " if k > 0 else "", "",
+ html_escape(repo), "",
+ )
+ if len(v.failed_repos) > CI_FAILED_SHOWN:
+ h.write(" and ", len(v.failed_repos) - CI_FAILED_SHOWN, " more")
+ h.write(" |
")
+ h.write("
")
+ if len(ci) > CI_VERSIONS_SHOWN:
+ h.write("The newest ", CI_VERSIONS_SHOWN, " of ", len(ci), " versions with CI results.
")
+ return h^
+
+
+def _migrations_body(rows: List[VersionMonth], ci: List[VersionCi]) raises -> String:
+ """The Migrations page's HTML for `rows` (at least one) and the CI
+ results per version, rendered once per cache build."""
var h = String(
_migrations_head(),
)
h.write(_versions_chart(rows))
+ h.write(_ci_table(ci))
var late = List[VersionMonth]()
var early = List[VersionMonth]()
for ref r in rows:
diff --git a/src/console_repo.mojo b/src/console_repo.mojo
index a2dad83..2585f96 100644
--- a/src/console_repo.mojo
+++ b/src/console_repo.mojo
@@ -3,6 +3,7 @@ lines of Mojo, commits and issues over time (as tabs, `?chart=`), dependencies,
contributors per month, releases and tags, issues and pull requests, migrations and latest commits."""
from flare.http import Request, Response, html_escape, internal_error, not_found, redirect
+from ci import CiRow, ci_at
from contributors import RepoContributors
from days import day_text
from deps import other_owners
@@ -204,6 +205,37 @@ comptime OVER_TIME_HELP = (
)
+comptime REPO_CI_HELP = (
+ "CI: what the repo's own GitHub Actions workflows said of the commit that moved it"
+ " to that Mojo version, linked to the commit's checks on GitHub. Runs GitHub starts by"
+ " itself (code scanning's default setup, Pages) are left out, and what a workflow does"
+ " isn't looked at. Read by mojo_ci while GitHub still lists the commit's runs."
+)
+
+
+def _ci_cell(ci: List[CiRow], kind: String, sha: String, gh: String) -> String:
+ """The CI cell of a migration's row: the state of its commit's row of
+ mojo.migration_ci, linked to the commit's checks; a dash for a commit
+ mojo_ci hasn't an answer for, and for a change that isn't of Mojo
+ version."""
+ var dash = String("– | ")
+ if kind != "mojo_version":
+ return dash^
+ var found = ci_at(ci, sha)
+ if not found:
+ return dash^
+ ref r = found.value()
+ if r.state == "none":
+ return String("no runs | ")
+ if r.state != "passed" and r.state != "failed" and r.state != "running":
+ return dash^
+ return String(
+ "",
+ r.state, " | ",
+ )
+
+
def _tab(repo: String, view: String, label: String, on: Bool) -> String:
"""A tab of `_over_time`: a link to the page with that chart, so it works
without JS, which then switches the panels in place."""
@@ -636,20 +668,23 @@ def repo_page(req: Request, c: Cache) raises -> Response:
"; all of them are in the JSON.
",
)
h.write(_issues_section(data.issues, gh, True))
- h.write("Migrations
")
+ # The CI column only for a repo mojo_ci has an answer for.
+ var with_ci = len(data.ci) > 0
+ h.write("Migrations", _help("h-repo-ci", "the CI column", REPO_CI_HELP) if with_ci else "", "
")
if len(ms) == 0:
h.write(_empty("No migrations recorded", "No change of Mojo version or tooling between the commits read so far."))
else:
h.write(
"| Date | What | From | To | ",
- "Commit |
",
+ "Commit | ", "CI | " if with_ci else "", "",
)
for ref m in ms:
h.write(
"| ", day(m.at), " | ", html_escape(m.kind), " | ",
_or_dash(m.from_value), " | ", _or_dash(m.to_value),
" | ",
- html_escape(String(m.sha[byte=:10])), " |
",
+ html_escape(String(m.sha[byte=:10])), "",
+ _ci_cell(data.ci, m.kind, m.sha, gh) if with_ci else String(), "",
)
h.write("
")
h.write("Commits
")
diff --git a/src/lake.mojo b/src/lake.mojo
index a61ceb6..2f57547 100644
--- a/src/lake.mojo
+++ b/src/lake.mojo
@@ -37,6 +37,7 @@ comptime LIVE_COMMITS = "mojo.live_commits"
comptime LIVE_HEADS = "mojo.live_heads"
comptime MEASURES = "mojo.measures"
comptime REFRESHED = "mojo.refreshed"
+comptime MIGRATION_CI = "mojo.migration_ci"
comptime EVENTS_SCHEMA = (
'{"schema-id":0,"type":"struct","fields":['
@@ -574,6 +575,30 @@ def measures_schema() raises -> Schema:
return Schema.parse(MEASURES_SCHEMA)
+comptime MIGRATION_CI_SCHEMA = (
+ '{"schema-id":0,"type":"struct","fields":['
+ '{"id":1,"name":"repo","required":true,"type":"string"},'
+ '{"id":2,"name":"sha","required":true,"type":"string"},'
+ '{"id":3,"name":"committed_at","required":true,"type":"timestamptz"},'
+ '{"id":4,"name":"state","required":true,"type":"string"},'
+ '{"id":5,"name":"runs","required":true,"type":"long"},'
+ '{"id":6,"name":"passed","required":true,"type":"long"},'
+ '{"id":7,"name":"failed","required":true,"type":"long"},'
+ '{"id":8,"name":"checked_at","required":true,"type":"timestamptz"}]}'
+)
+"""One row per commit that moved a repository to another Mojo version
+(a `mojo_version` row of mojo.migrations) that mojo_ci has asked GitHub
+about: what the repository's own workflows said of that commit (`ci.mojo`).
+`state` is `passed`, `failed`, `running` or `none`, or `gone` for a
+repository GitHub no longer answers for; `runs` counts the workflow runs on
+the commit, `passed` and `failed` those that ended so. GitHub drops a
+commit's runs after some months, so a row is the only record once it has."""
+
+
+def migration_ci_schema() raises -> Schema:
+ return Schema.parse(MIGRATION_CI_SCHEMA)
+
+
def live_commits_schema() raises -> Schema:
return Schema.parse(LIVE_COMMITS_SCHEMA)
diff --git a/src/model.mojo b/src/model.mojo
index f0563dd..1017fbf 100644
--- a/src/model.mojo
+++ b/src/model.mojo
@@ -935,6 +935,7 @@ def read_sources() raises -> Sources:
var names: List[String] = [
"repos", "commits", "repo_stats", "activity", "migrations", "releases", "tags",
"repo_embeddings", "issues", "contributors", "dep_forks", "measures", "dep_names",
+ "migration_ci",
]
for name in names:
var t = try_load("mojo", name)
diff --git a/tests/test_ci.mojo b/tests/test_ci.mojo
new file mode 100644
index 0000000..38a40aa
--- /dev/null
+++ b/tests/test_ci.mojo
@@ -0,0 +1,211 @@
+# mojo.migration_ci rows: GitHub's workflow runs of a commit read into a
+# row, which migrations are due to be asked about, answers merged into what
+# is stored and read back as written, and the counts per Mojo version the
+# Migrations page shows. No network.
+
+from std.testing import assert_equal, assert_false, assert_true, TestSuite
+
+from ci import (
+ MAX_AGE_DAYS,
+ CiRow,
+ by_repo,
+ ci_at,
+ ci_batch,
+ ci_by_version,
+ ci_rows,
+ merge_ci,
+ parse_runs,
+ select_due,
+)
+from model import Migration
+from overview import DAY_US
+
+# bgreni/EmberJson's commit to 1.2.0.dev2026092905, as GitHub lists it: the
+# repository's own workflow and code scanning's default setup.
+comptime RUNS = """{"total_count": 2, "workflow_runs": [
+ {"id": 1, "name": "CI", "path": ".github/workflows/CI.yml", "event": "push",
+ "status": "completed", "conclusion": "success", "run_attempt": 1},
+ {"id": 2, "name": "Push on main", "path": "dynamic/github-code-scanning/codeql",
+ "event": "dynamic", "status": "completed", "conclusion": "failure", "run_attempt": 1}
+]}"""
+
+
+def _runs(items: List[String]) -> String:
+ """A reply listing one run per `status/conclusion` of `items`."""
+ var out = String('{"total_count": ', len(items), ', "workflow_runs": [')
+ for i in range(len(items)):
+ var parts = items[i].split("/")
+ var conclusion = String("null") if parts[1] == "" else String('"', parts[1], '"')
+ if i > 0:
+ out += ","
+ out.write(
+ '{"path": ".github/workflows/w', i, '.yml", "status": "', parts[0],
+ '", "conclusion": ', conclusion, "}",
+ )
+ out += "]}"
+ return out^
+
+
+def _state(items: List[String]) -> String:
+ return parse_runs("a/b", "abc", 1, _runs(items), 2).state
+
+
+def test_parse_own_workflows_only() raises:
+ var r = parse_runs("bgreni/EmberJson", "82cb016", 5, RUNS, 9)
+ assert_equal(r.repo, "bgreni/EmberJson")
+ assert_equal(r.sha, "82cb016")
+ assert_equal(r.committed_at, 5)
+ assert_equal(r.checked_at, 9)
+ # Code scanning's failed run is GitHub's, not the repository's.
+ assert_equal(r.runs, 1)
+ assert_equal(r.passed, 1)
+ assert_equal(r.failed, 0)
+ assert_equal(r.state, "passed")
+
+
+def test_states() raises:
+ assert_equal(_state(["completed/success", "completed/success"]), "passed")
+ assert_equal(_state(["completed/success", "completed/failure"]), "failed")
+ assert_equal(_state(["completed/timed_out"]), "failed")
+ assert_equal(_state(["completed/startup_failure"]), "failed")
+ # A failure is known before the others finish; a pass is not.
+ assert_equal(_state(["in_progress/", "completed/failure"]), "failed")
+ assert_equal(_state(["queued/", "completed/success"]), "running")
+ # Skipped and cancelled runs say nothing either way.
+ assert_equal(_state(["completed/skipped", "completed/cancelled"]), "none")
+ assert_equal(_state(["completed/skipped", "completed/success"]), "passed")
+ assert_equal(_state(List[String]()), "none")
+ assert_equal(parse_runs("a/b", "abc", 1, '{"total_count": 0, "workflow_runs": []}', 2).runs, 0)
+ # Not a list of runs at all (an error body): no runs, not a crash.
+ assert_equal(parse_runs("a/b", "abc", 1, '{"message": "Not Found"}', 2).state, "none")
+ var r = parse_runs("a/b", "abc", 1, _runs(["completed/success", "completed/failure", "queued/"]), 2)
+ assert_equal(r.runs, 3)
+ assert_equal(r.passed, 1)
+ assert_equal(r.failed, 1)
+
+
+def _m(repo: String, sha: String, day: Int, kind: String = "mojo_version", to: String = "1.3.0") -> Migration:
+ return Migration(repo, sha, Int64(day) * DAY_US, kind, String("1.2.0"), to)
+
+
+def _row(repo: String, sha: String, day: Int, state: String) -> CiRow:
+ var passed = Int64(1) if state == "passed" else Int64(0)
+ var failed = Int64(1) if state == "failed" else Int64(0)
+ return CiRow(repo, sha, Int64(day) * DAY_US, state, 1, passed, failed, 0)
+
+
+def _shas(ms: List[Migration]) -> String:
+ var out = String()
+ for ref m in ms:
+ out += String(m.sha, " ")
+ return out^
+
+
+def test_select_due() raises:
+ var today = 1000
+ var now_us = Int64(today) * DAY_US
+ var ms: List[Migration] = [
+ _m("a/b", "old", today - MAX_AGE_DAYS - 1), # its runs may be gone
+ _m("a/b", "edge", today - MAX_AGE_DAYS),
+ _m("a/b", "tooling", today - 5, "tooling"), # not a change of Mojo version
+ _m("a/b", "settled", today - 10),
+ _m("a/b", "running", today - 10),
+ _m("a/b", "young", today - 1),
+ _m("a/b", "new", today - 20),
+ _m("a/b", "new", today - 20), # the same commit twice is asked once
+ _m("c/d", "new", today - 2), # the same commit in a fork is its own
+ _m("a/b", "", today - 3),
+ ]
+ var known: List[CiRow] = [
+ _row("a/b", "settled", today - 10, "passed"),
+ _row("a/b", "running", today - 10, "running"),
+ _row("a/b", "young", today - 1, "failed"),
+ ]
+ # Newest first; `settled` is final, `running` and `young` are asked again.
+ assert_equal(_shas(select_due(ms, known, now_us, 100)), "young new running new edge ")
+ assert_equal(_shas(select_due(ms, known, now_us, 2)), "young new ")
+ assert_equal(len(select_due(ms, known, now_us, 0)), 0)
+ assert_true(known[0].settled(now_us))
+ assert_false(known[1].settled(now_us))
+ assert_false(known[2].settled(now_us))
+ # `none` settles too: a commit with no CI is not asked about forever.
+ assert_true(_row("a/b", "x", today - 3, "none").settled(now_us))
+ assert_false(_row("a/b", "x", today - 2, "none").settled(now_us))
+
+
+def test_merge_and_roundtrip() raises:
+ var old: List[CiRow] = [_row("a/b", "s1", 1, "running"), _row("a/b", "s2", 2, "passed")]
+ var newer: List[CiRow] = [_row("a/b", "s1", 1, "failed"), _row("c/d", "s1", 3, "none")]
+ var merged = merge_ci(old^, newer)
+ assert_equal(len(merged), 3)
+ assert_equal(merged[0].state, "failed")
+ assert_equal(merged[1].state, "passed")
+ assert_equal(merged[2].repo, "c/d")
+ merged[2].checked_at = 77
+ var back = ci_rows(ci_batch(merged))
+ assert_equal(len(back), 3)
+ assert_equal(back[0].repo, "a/b")
+ assert_equal(back[0].sha, "s1")
+ assert_equal(back[0].committed_at, DAY_US)
+ assert_equal(back[0].state, "failed")
+ assert_equal(back[0].runs, 1)
+ assert_equal(back[0].passed, 0)
+ assert_equal(back[0].failed, 1)
+ assert_equal(back[2].state, "none")
+ assert_equal(back[2].checked_at, 77)
+ var repos = by_repo(back)
+ assert_equal(len(repos), 2)
+ assert_equal(len(repos["a/b"]), 2)
+ assert_equal(ci_at(repos["a/b"], "s2").value().state, "passed")
+ var missing = ci_at(repos["a/b"], "nope")
+ assert_true(not missing)
+
+
+def test_by_version() raises:
+ # Oldest first, as model.migrations gives them.
+ var ms: List[Migration] = [
+ _m("a/b", "s1", 1, "mojo_version", "1.2.0"),
+ _m("a/b", "s2", 2, "mojo_version", "1.3.0"), # failed, then
+ _m("a/b", "s3", 3, "mojo_version", "1.2.0"), # back
+ _m("a/b", "s4", 4, "mojo_version", "1.3.0"), # and passed: counts once, as passed
+ _m("c/d", "s5", 5, "mojo_version", "1.3.0"),
+ _m("e/f", "s6", 6, "mojo_version", "1.3.0"), # no CI
+ _m("g/h", "s7", 7, "mojo_version", "1.3.0"), # never asked
+ _m("g/h", "s8", 8, "tooling", "pixi"),
+ _m("i/j", "s9", 9, "mojo_version", "1.3.0"), # still running
+ _m("k/l", "s10", 10, "mojo_version", "1.3.0.dev2026112605"),
+ _m("k/l", "s11", 11, "mojo_version", "1.1.0"), # no CI on any move to it
+ ]
+ var rows: List[CiRow] = [
+ _row("a/b", "s1", 1, "passed"),
+ _row("a/b", "s2", 2, "failed"),
+ _row("a/b", "s4", 4, "passed"),
+ _row("c/d", "s5", 5, "failed"),
+ _row("e/f", "s6", 6, "none"),
+ _row("g/h", "s8", 8, "passed"),
+ _row("i/j", "s9", 9, "running"),
+ _row("k/l", "s10", 10, "passed"),
+ ]
+ var v = ci_by_version(ms, rows)
+ # Newest version first (a release is newer than its nightlies); 1.1.0,
+ # which no CI ran on, is left out.
+ assert_equal(len(v), 3)
+ assert_equal(v[0].version, "1.3.0")
+ assert_equal(v[0].moved, 5)
+ assert_equal(v[0].passed, 1)
+ assert_equal(v[0].failed, 1)
+ assert_equal(v[0].ran(), 2)
+ assert_equal(v[0].failed_repos, [String("c/d")])
+ assert_equal(v[1].version, "1.3.0.dev2026112605")
+ assert_equal(v[1].moved, 1)
+ assert_equal(v[1].passed, 1)
+ assert_equal(v[2].version, "1.2.0")
+ assert_equal(v[2].moved, 1)
+ assert_equal(v[2].passed, 1)
+ assert_equal(v[2].failed, 0)
+ assert_equal(len(v[2].failed_repos), 0)
+ assert_equal(len(ci_by_version(ms, List[CiRow]())), 0)
+
+
+def main() raises:
+ TestSuite.discover_tests[__functions_in_module()]().run()
diff --git a/tests/test_console_routes.mojo b/tests/test_console_routes.mojo
index 23c6a3c..7cc6a6f 100644
--- a/tests/test_console_routes.mojo
+++ b/tests/test_console_routes.mojo
@@ -9,6 +9,7 @@ from std.testing import TestSuite, assert_equal, assert_false, assert_true
from flare.http import Request, Response, Router
from checks import CheckRun
+from ci import CiRow, VersionCi
from console_ai import html_text
from console_badge import BADGE_CACHE, BRAND_COLOR, MISSING_CACHE, Badge, badge_svg, text_width, version_badge, version_text
from console_cache import Cache, RepoData
@@ -16,10 +17,11 @@ from console_repo import chart_view, month_counts, month_span
from issues import IssueRow
from console_layout import SITE_URL
from console_live import LiveData
+from console_migrations_body import _ci_table
from console_pages import api_pages, site_pages
from console_routes import console_router
from measures import Measure
-from model import Library, Point
+from model import Library, Migration, Point
from querymodel import QueryModel
from search import url_encode
from swap import Swap
@@ -434,6 +436,74 @@ def test_repo_json_over_time() raises:
assert_true('"over_time":{"lines_of_mojo":2000,"commits":{"total":4,"months":[]},"issues":null}' in other)
+def test_migration_ci() raises:
+ # What a repo's CI said of the commits that moved its Mojo version
+ # (mojo.migration_ci): a column of the repo page's Migrations table and
+ # "ci" in its JSON, only for a repo mojo_ci has an answer for.
+ # Shas as long as the page's short form of them (ten bytes) at least.
+ var c = _with_history()
+ var day_us = Int64(86_400_000_000)
+ var d = c.details["acme/tomlkit"].copy()
+ d.ms.append(Migration("acme/tomlkit", "aaa111aaa111", Int64(JAN_1 + 4) * day_us, "mojo_version", "1.2.0", "1.3.0"))
+ d.ms.append(Migration("acme/tomlkit", "bbb222bbb222", Int64(JAN_1 + 19) * day_us, "tooling", "magic", "pixi"))
+ d.ms.append(Migration("acme/tomlkit", "ccc333ccc333", Int64(JAN_1 + 60) * day_us, "mojo_version", "1.3.0", "1.4.0"))
+ d.ms.append(Migration("acme/tomlkit", "ddd444ddd444", Int64(JAN_1 + 68) * day_us, "mojo_version", "1.4.0", "1.5.0"))
+ d.ci.append(CiRow("acme/tomlkit", "aaa111aaa111", Int64(JAN_1 + 4) * day_us, "failed", 3, 2, 1, Int64(JAN_1 + 8) * day_us))
+ d.ci.append(CiRow("acme/tomlkit", "ccc333ccc333", Int64(JAN_1 + 60) * day_us, "none", 0, 0, 0, Int64(JAN_1 + 64) * day_us))
+ c.details["acme/tomlkit"] = d^
+ var other = RepoData()
+ other.ms.append(Migration("acme/http", "eee555eee555", Int64(JAN_1 + 4) * day_us, "mojo_version", "1.2.0", "1.3.0"))
+ c.details["acme/http"] = other^
+ var r = _router_of(c^)
+ var page = _body(_get(r, "/repos/acme/tomlkit"))
+ assert_true("Commit | CI | " in page)
+ assert_true(
+ "failed" in page
+ )
+ assert_true("no runs | " in page)
+ # The tooling change and the commit not asked about yet: a dash each.
+ assert_true("bbb222bbb2– | " in page)
+ assert_true("ddd444ddd4– | " in page)
+ var j = _body(_get(r, "/api/repos/acme/tomlkit"))
+ assert_true(
+ '"sha":"aaa111aaa111","kind":"mojo_version","from":"1.2.0","to":"1.3.0",'
+ '"ci":{"state":"failed","runs":3,"passed":2,"failed":1,"checked_at":"' in j
+ )
+ assert_true('"sha":"bbb222bbb222","kind":"tooling","from":"magic","to":"pixi","ci":null}' in j)
+ assert_true('"sha":"ccc333ccc333","kind":"mojo_version","from":"1.3.0","to":"1.4.0","ci":{"state":"none","runs":0,' in j)
+ # A repo with no answer keeps the table it had.
+ var plain = _body(_get(r, "/repos/acme/http"))
+ assert_true("Commit | " in plain)
+ assert_false("CI | " in plain)
+ assert_true("eee555eee5" in plain)
+ assert_true('"to":"1.3.0","ci":null}' in _body(_get(r, "/api/repos/acme/http")))
+
+
+def test_ci_table() raises:
+ # The Migrations page's table of what CI said per version; nothing
+ # before mojo_ci has an answer.
+ assert_equal(_ci_table(List[VersionCi]()), "")
+ var names = List[String]()
+ for i in range(7):
+ names.append(String("acme/r", i))
+ var t = _ci_table([
+ VersionCi("1.3.0", 12, 6, 7, names^),
+ VersionCi("1.2.0", 4, 3, 0, List[String]()),
+ ])
+ assert_true("What their CI said" in t)
+ assert_true(
+ "| 1.3.0 | 12 | 13 | 6 | "
+ "7 | acme/r0, " in t
+ )
+ assert_true("acme/r4 and 2 more |
" in t)
+ assert_false("acme/r5" in t)
+ assert_true(
+ "| 1.2.0 | 4 | 3 | 3 | "
+ "0 | – |
" in t
+ )
+
+
def test_ai_page() raises:
var r = _router()
var resp = _get(r, "/ai")
From 601a96a672833717a67c1d47fa85ec1ab543a6bd Mon Sep 17 00:00:00 2001
From: Marius S <39998+winding-lines@users.noreply.github.com>
Date: Mon, 30 Nov 2026 17:25:53 -0800
Subject: [PATCH 2/3] Changelog fragment for #270
Co-Authored-By: Claude Fable 5.2
Claude-Session: https://claude.ai/code/session_017TycsxF3PkSX49fnv7cSZd
---
changes/270-migration-ci.minor.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 changes/270-migration-ci.minor.md
diff --git a/changes/270-migration-ci.minor.md b/changes/270-migration-ci.minor.md
new file mode 100644
index 0000000..9955e80
--- /dev/null
+++ b/changes/270-migration-ci.minor.md
@@ -0,0 +1 @@
+- **CI on Mojo version moves**: a daily pipeline, `mojo_ci` (09:00 UTC), records in `mojo.migration_ci` what each repo's own GitHub Actions said of the commits that moved it to another Mojo version; repo pages show it beside each migration and `/migrations` counts it per version. Needs the GitHub token secret, as mojo_stats does; the table fills over its first two daily runs. (#270)
From 1e5024aa901674db6becca25f76de076e6ccffa7 Mon Sep 17 00:00:00 2001
From: Marius S <39998+winding-lines@users.noreply.github.com>
Date: Mon, 30 Nov 2026 17:28:17 -0800
Subject: [PATCH 3/3] ci: drop an unused import (customs)
Co-Authored-By: Claude Fable 5.2
Claude-Session: https://claude.ai/code/session_017TycsxF3PkSX49fnv7cSZd
---
src/ci.mojo | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/ci.mojo b/src/ci.mojo
index 3d83187..d08e4e1 100644
--- a/src/ci.mojo
+++ b/src/ci.mojo
@@ -21,7 +21,6 @@ from morca.tables import BatchBuilder
from parquet import RecordBatch
from cols import col, i64_at, str_at
-from detect import long_of
from fetch import github
from jscan import Range, each, field, text
from lake import migration_ci_schema, try_load