CI Pipeline & Developer Portal
Overview
A single workflow — .github/workflows/ci.yml — validates every change and, on merges to main, publishes the developer portal at <https://developer.datachainr.com>.
The portal is a static site generated from three inputs:
| Input | Produced by | Rendered as |
|---|---|---|
| Per-package coverage reports | the pytest / vitest jobs | /<service>/ HTML reports |
tools/data/cicd_history.jsonl | the update-ci-stats job | home page health cards + modal |
Job graph
hooks ─┐
├─→ spec ────────────────────────────────┐
secrets-scan ─┼─→ pytest (svc-ai/core/bff/auth) ┤
├─→ vitest (fe-core/public/shared)┤
└─→ tools-tests │
│ │
└─→ update-ci-stats ──────┴─→ build-artifacts → publish-coverage
(push to main only) (push to main only)
dependency-scan (independent; report-only)
dependency-scan is deliberately not in any needs: list — see dependency scanning for how to make it blocking.
Why update-ci-stats runs after the test jobs
This is the ordering constraint most likely to be "optimised" back into a bug.
The collector records the results of the run it is part of. The GitHub Actions API only lists completed workflow runs, so a collector scheduled alongside the test jobs can never observe its own run — it can only see the previous one. That is precisely what made the portal permanently one merge out of date.
Declaring needs: [pytest, vitest] fixes it twice over:
The per-service jobs have finished, so their conclusions can be read directly from
/actions/runs/{run_id}/jobsfor this run.Their coverage artifacts exist, so the collector reads exact percentages from
coverage.xml/coverage-summary.jsonrather than regex-scraping a job log.
It is gated on !cancelled() rather than success(): a failing run is exactly the state the dashboard most needs to record.
The CI/CD history store
tools/data/cicd_history.jsonl is newline-delimited JSON, one record per service per run, committed back to main by the update-ci-stats job. The paths-ignore guard on the workflow's push trigger stops that data-only commit from re-triggering CI (no [skip ci] marker is needed — that would leak into squash-merge bodies and skip the whole pipeline).
The AWS deploy pipeline ignores it too. It is a V2 pipeline started by a push trigger that excludes tools/data/cicd_history.jsonl, with change detection off on the source action (infra/terraform/envs/dev/cicd-pipeline.tf). Until October 2026 it deployed on every push, so each merge deployed twice, a few minutes apart: the second deploy restarted every container (Grafana included) while the first was still settling, and cut off the platform benchmark's runs. tools/test_cicd_pipeline.py pins the filter and that it names the file this job commits.
Scope and retention are configured in tools/site_config.yml:
| Key | Default | Meaning |
|---|---|---|
event | push | Only this event type is recorded |
history_days | 30 | Rolling window the portal renders |
retention_days | 180 | Records older than this are pruned on each run |
max_runs | 100 | Runs the backfill pass inspects per service |
Restricting to main pushes is deliberate: a red pull-request run says nothing about the health of shipped code, and mixing the two made the service-health cards misleading.
job_name is matched as a case-insensitive substring of the GitHub job name, so pytest (svc-ai) keeps matching the [test] pytest (svc-ai) job even though ci.yml prefixes job names by category.
Repairing historical false failures
Before the Code Quality upload was made non-blocking, a flaky upload failed the whole test job — and because the collector records per-job conclusions, those runs were written into the history as service failures despite every test passing. tools/collectors/repair_cicd_history.py corrects them:
GITHUB_TOKEN=<pat> make repair-ci-history # dry run: report only
GITHUB_TOKEN=<pat> make repair-ci-history APPLY=1 # write the corrections
A record is only corrected when the test step concluded success and every failing step is a known-benign reporting step. A real test failure, a failed install, or any unrecognised failing step is left untouched — the script is deliberately biased towards leaving a false failure in place rather than hiding a genuine one. Corrected records carry "repaired": "code-quality-upload" so the amendment stays visible in the data.
Coverage reporting
Coverage flows three ways from the same test run:
Artifacts → consumed by
build-artifacts(badges, published reports) and byupdate-ci-stats(dashboard values). This is the authoritative path.Badge SVGs →
badges/*.svg, regenerated bymake coverage-badgesand committed;build-artifactsfails the build if they drift.GitHub Code Quality → the
actions/upload-code-coveragesteps.
How a percentage is derived
Both readers compute from the exact integer counts in the report — lines-covered/lines-valid for Cobertura, covered/total for istanbul — and round half-up to one decimal place with Decimal.
Neither the pre-computed line-rate nor istanbul's pct is used, because both have already lost precision: coverage.py writes line-rate as %.4g (four significant digits), and istanbul rounds pct to two decimal places. On a package the size of svc-ai that quantisation is ~0.01%, enough to land the value exactly on a rounding tie.
round() is avoided for the same reason: it is banker's rounding applied to a binary float, so ties resolve inconsistently — round(83.55, 1) is 83.5 while round(66.65, 1) is 66.7. Combined, these made the badge flip by 0.1% for a one-line coverage change and reported svc-ai as 83.5% when the true figure was 83.554%. A flipping badge fails the "badges are committed" check on a diff nobody introduced, so this determinism is what keeps that gate usable.
A badge diff in CI now means coverage genuinely moved; run make coverage-badges and commit the result.
The Code Quality upload is reporting, not a gate, and is configured with fail-on-error: false plus continue-on-error: true. The API intermittently returns a success response without an upload id, which would otherwise fail a job whose tests all passed — and because the collector reads per-job conclusions, that false failure would then be recorded against the service on the portal.
Publishing
publish-coverage never calls Cloudflare. Cloudflare Pages is connected to this repository through its own GitHub App (Workers & Pages → developer-datachainr-com, production branch pages-deploy, build command none, output dir /) and watches that branch. The job force-pushes the pre-built site to pages-deploy as a fresh orphan commit, which is what gives Cloudflare something new to deploy. No Cloudflare API token lives in GitHub.
A Verify site artifact step checks the key pages exist before that force-push, so a partial artifact cannot overwrite a working portal.
Running the tooling locally
make coverage-badges # regenerate coverage reports + badge SVGs
make test-tools # run the portal/collector/badge tooling tests
make spec # regenerate docs/spec/
To rebuild the portal locally you need coverage artifacts laid out the way CI downloads them (_artifacts/coverage-<id>/), then:
pip install -r tools/requirements.txt
python3 tools/coverage/generate_badges.py
python3 tools/coverage/generate_index.py # writes ./site