Skip to content

ci: wire shared build and nightly builder image into PR CI - #27077

Merged
fengttt merged 10 commits into
matrixorigin:mainfrom
fengttt:ci-shared-build
Aug 14, 2026
Merged

fengttt merged 10 commits into
matrixorigin:mainfrom
fengttt:ci-shared-build

Conversation

@fengttt

@fengttt fengttt commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Test and CI

Which issue(s) this PR fixes:

issue #27076

What this PR does / why we need it:

MatrixOne side of the PR-CI speedup (workflows side: matrixorigin/CI#418).

  1. entrypoint.yaml: add a matrixone-shared-build job (calls matrixorigin/CI/build-mo.yaml@main) that builds the -cover mo-service once per run; the standalone and compose BVT workflows consume the artifact instead of each spending ~10 minutes on identical builds. A compile-broken PR now fails once, in ~4 minutes.
  2. optools/images/Dockerfile.prebuilt: assembles the compose runtime image from the prebuilt artifact in seconds instead of a full in-docker rebuild; its /mo-service -h smoke check guards the glibc contract and any failure falls back to the full docker build.
  3. optools/images/Dockerfile.ci-builder: the nightly-refreshed builder image (published by the existing nightly image workflow as matrixorigin/matrixone:ci-builder, amd64+arm64, Docker Hub + ACR mirror). It bakes every PR-invariant build input — Go module cache, Go build caches warmed in exactly the flavors PR CI compiles (-cover build; -race -tags matrixone_test; -covermode=set + coverpkg; arm64 static-check), and the compiled C thirdparties. A stale image only costs speed, never correctness: go build recompiles and downloads incrementally.

Measured locally: incremental -cover build 20s (unchanged) to ~1min (worst-case exported-API change to pkg/container/types) vs ~10min cold; full race-flavor test compile ~3min warm; make cgo ~11s with seeded thirdparties.

⚠️ MERGE ORDER: matrixorigin/CI#418 must merge first. This PR references build-mo.yaml@main and passes a build_artifact input — merging it before the CI PR breaks every PR's CI at workflow-parse time. Draft until then. After both merge, manually dispatch the "Build and Push Images" workflow once to publish the first ci-builder image (until then, all consumers fall back to today's cold builds).

🤖 Generated with Claude Code

fengttt and others added 4 commits August 12, 2026 12:15
The standalone and compose BVT jobs each spend ~10 minutes compiling the
same head commit. Add a shared build job (matrixorigin/CI build-mo.yaml)
that builds the coverage-instrumented mo-service once and publishes it as
a run-scoped artifact; both BVT workflows consume it and fall back to
building from source when it is missing or mismatched.

Dockerfile.prebuilt assembles the compose runtime image from that
artifact in seconds instead of rebuilding thirdparties and the full Go
graph inside docker. Its mo-service -h smoke check also guards the
glibc contract between the build runner and the ubuntu:22.04 base, so
any skew fails the assembly and triggers the in-docker fallback.

Co-Authored-By: Claude Fable 5 <[email protected]>
All PR-invariant build inputs -- the Go module cache, the Go build cache,
and the compiled C thirdparties -- are identical across PR runs, yet every
run recompiled them from scratch (~10 minutes). Bake them into a builder
image refreshed by the nightly image workflow: PR CI mounts its checkout
into the image and runs make build, so only packages the PR changed
recompile, and go build incrementally downloads any modules newer than
the baked cache. A stale image only costs speed, never correctness.

Measured locally: unchanged tree rebuilds in ~20s, a worst-case exported
API change to pkg/container/types in ~54s, versus ~10 minutes cold. The
binary now links inside the ubuntu-22.04 toolchain container, so it also
matches the matrixorigin/ubuntu:22.04 runtime image glibc by
construction.

Consumed by matrixorigin/CI build-mo.yaml; published nightly as
matrixorigin/matrixone:ci-builder by the image-build workflow.

Co-Authored-By: Claude Fable 5 <[email protected]>
Extend the nightly ci-builder warm stage beyond the -cover mo-service
build with the two go-test compile flavors PR CI pays for on every run:
-race with -tags matrixone_test (the UT job via optools/run_ut.sh) and
-covermode=set with the full coverpkg list (coverage-ut.yaml, whose
package filter is replicated verbatim because the coverpkg value is part
of the compile key). -exec /bin/true links every test binary without
running any test, and -vet=off keeps vet findings out of the warm; both
warms soft-fail since PR CI never depends on them for correctness.

Store the module cache with -modcacherw: its default read-only directory
layout breaks extracting the cache onto CI runners (docker cp creates a
read-only parent, then cannot populate it).

Verified locally against a checkout at a different path with the host
toolchain: the full ./... race-flavor test compile took 3m18s (1m11s on
rerun) instead of a cold full compile, and seeded thirdparties cut make
cgo to ~11s.

Co-Authored-By: Claude Fable 5 <[email protected]>
The builder image now publishes both CI architectures, each warming what
PR CI compiles there: amd64 keeps the -cover build plus the two UT test
flavors; arm64 (the SCA job's architecture) warms the plain build plus a
full make static-check pass, which caches the vet facts and
golangci-lint's analysis cache alongside the compiled packages. The
golangci-lint version comes from make install-static-check-tools, so the
cache matches what the SCA runner installs.

Darwin is intentionally not covered: no PR-path job runs on macOS (the
mac UT job is disabled), and the post-merge mac BVT runs on a persistent
self-hosted runner whose local Go caches survive between runs without
any image.

Co-Authored-By: Claude Fable 5 <[email protected]>
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for two correctness blockers and one fallback/reliability issue. The shared artifact must be runnable by the standalone consumer, and native cache reuse must be proven compatible with the PR inputs/base branch rather than silently replacing them. I also recommend preserving a cold-build path when the shared job itself fails.

Validation performed at this head: actionlint, docker build --check for both Dockerfiles, and git diff --check all passed.

Comment thread .github/workflows/entrypoint.yaml Outdated
with:
bvt_group: ${{ needs.bvt-group-plan.outputs.launch_group }}
bvt_generation: ${{ needs.bvt-group-plan.outputs.generation }}
build_artifact: ${{ needs.matrixone-shared-build.outputs.artifact_name }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] The shared artifact cannot currently launch the standalone BVT. In matrixorigin/CI#418, build-mo.yaml packages the third-party DSOs under lib/ but packages libmo.so under prebuilt-cgo/. The standalone workflow extracts the archive at the checkout root and launches ./mo-service without moving prebuilt-cgo/*.so into lib//cgo/ or setting LD_LIBRARY_PATH. Since the binary's runtime search path is $ORIGIN/lib, the loader exits with libmo.so: cannot open shared object file instead of running the tests. Please put libmo.so beside the other runtime libraries (or relocate it in the standalone consumer) and add a direct artifact smoke test before upload.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in matrixorigin/CI@8b18024 + e417582 here. Every runtime DSO (thirdparties and libmo.so) now ships under lib/ — the binary's $ORIGIN/lib rpath — and the prebuilt-cgo/ contract is removed; Dockerfile.prebuilt copies only lib/*.so. The producer also smoke-tests the staged tree with env -u LD_LIBRARY_PATH GOCOVERDIR=$(mktemp -d) ./mo-service -h twice: once after the cached build (a failure there falls through to the cold build) and once at packaging, so a broken artifact fails at its owner before upload. (Noting @LeftHandCold could not reproduce a hard libmo.so dependency — statically linked today — but the consolidated layout makes the artifact robust if that ever changes.)

COPY --from=warm /root/.cache/golangci-lint /root/.cache/golangci-lint
# Seeded into the PR tree before make build; the prerequisite-less file
# targets in thirdparties/Makefile then treat the C libraries as up to date.
COPY --from=warm /go/src/github.com/matrixorigin/matrixone/thirdparties/install /mo-prebuilt/thirdparties/install

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] This native output is not a correctness-safe cache. CI#418 unconditionally replaces the PR checkout's thirdparties/install with this directory before make build. The relevant thirdparties/Makefile file targets have no archive/config prerequisites, so existing usearch/CRoaring headers and libraries suppress rebuilding when a PR changes thirdparties/, build flags, or targets a release branch that differs from main. That can make CI compile and test yesterday's native implementation and go falsely green. Please attach a branch/architecture/native-input fingerprint and restore only on an exact match, or make these outputs an invalidatable cache that rebuilds on input changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in e417582 + matrixorigin/CI@8b18024. The image now publishes /mo-prebuilt/thirdparties.fingerprint containing schema, os, arch, and git rev-parse HEAD:thirdparties. Because the archives, headers, the Makefile (with its flags), and the download script all live under thirdparties/, the tree hash covers every native input; schema= is bumped whenever the producing base-image/compiler contract changes. All four consumers (build-mo container build, UT, SCA, coverage-UT seeds) compute the same fingerprint from their checkout and restore thirdparties/install only on an exact match — any mismatch clears the seed and builds native deps from source. Validated locally: an unchanged tree seeds; a commit touching thirdparties/ produces a mismatch and a full usearch/CRoaring/onnx rebuild. Go build/module caches remain best-effort acceleration, which is always correctness-safe.

matrixone-standalone-ci:
name: Matrixone Standlone CI
needs: [check-pr-valid, bvt-group-plan]
needs: [check-pr-valid, bvt-group-plan, matrixone-shared-build]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] A shared-build failure skips the consumer before its fallback can run. Because matrixone-shared-build is a normal hard dependency, GitHub will skip this job (and compose) whenever the shared job fails; the consumer's missing/mismatched-artifact cold path is never reached. A pulled but stale/incompatible builder image is one example—the image has a fixed Go toolchain and CI#418 only falls back when the pull itself fails. Please contain cached-execution failures inside build-mo.yaml with a host cold build, or arrange for consumers to run with an empty artifact when the shared job fails for an infrastructure/cache reason.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in matrixorigin/CI@8b18024. The fallback now lives inside the producer: the cached container build is continue-on-error with ownership repair and a loader smoke test; on any failure (image pull, stale/broken cache, toolchain skew, smoke failure) the job sets up the checkout's Go toolchain and runs the existing make clean && make build cold path, and packaging runs after either path succeeds. So the hard needs: here stays as-is and only propagates a genuine PR compile failure to the consumers — which is the intended fail-once behavior.

fengttt and others added 2 commits August 14, 2026 10:43
Part of the upstream-main integration: the SCA job gained a dedicated
trusted actions/cache pipeline (sca-go-module-cache.yaml producer plus
the consumer steps in matrixorigin/CI ci.yaml), which subsumes the arm64
builder-image leg this Dockerfile carried for it — including the
toolchain-identity cache keys this branch had deferred. Drop the
TARGETARCH conditionals, the static-check warm flavor, and the
golangci-lint cache; the image now serves exactly the amd64 consumers:
the shared BVT build and the UT/coverage-UT cache seeds. Also switch the
final stage to ENV GOPROXY for consistency with the warm stage.

Verified: full image build on the merged tree, warm-status records
warm-race=ok and warm-coverage=ok, fingerprint matches the merged
thirdparties tree.

Co-Authored-By: Claude Fable 5 <[email protected]>
@fengttt

fengttt commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Merged latest upstream main (clean merge, head 91d33e7) in lockstep with matrixorigin/CI#418's merge of its main. Integration notes: the SCA cache seeding is ceded to the new sca-go-module-cache.yaml pipeline (which also supplies the toolchain-identity cache keys previously deferred), so Dockerfile.ci-builder is now amd64-only and correspondingly simpler; both BVT consumers use the identical Dockerfile.prebuilt image-assembly path after #419 moved the pessimistic suite onto the compose topology. Full builder-image build on the merged tree validates both warm flavors and the fingerprint. This branch's diff vs upstream/main remains exactly three files: entrypoint.yaml, Dockerfile.ci-builder, Dockerfile.prebuilt.

🤖 Generated with Claude Code

@fengttt

fengttt commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Publish sequence update: matrixorigin/CI#418 is merged. Dispatched "Build and Push Images" on main (run 31826694057) — its new ci-builder job will skip gracefully this time because Dockerfile.ci-builder is not on main yet; that skip path is itself worth validating before tonight's cron. To unblock the actual image publish per the agreed rollout order, the two Dockerfiles are split into #27181 (zero behavior change — nothing references them until this PR's wiring lands). Once #27181 merges: re-dispatch → first ci-builder image publishes → UT/coverage-UT seeds (already live in CI@main) activate → canary on this head incl. forced cached-build failure → measurements posted here → this PR leaves draft.

🤖 Generated with Claude Code

@fengttt
fengttt marked this pull request as ready for review August 14, 2026 18:15
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@fengttt
fengttt merged commit 7e46a25 into matrixorigin:main Aug 14, 2026
20 of 25 checks passed
fengttt added a commit that referenced this pull request Aug 14, 2026
## What type of PR is this?

- [x] Test and CI

## Which issue(s) this PR fixes:

issue #27076

## What this PR does / why we need it:

Publish-prerequisite split from #27077, per the reviewer-required
rollout order there. The nightly `ci-builder` job (already on
`matrixorigin/CI@main` via matrixorigin/CI#418) checks out **main** and
skips gracefully while `optools/images/Dockerfile.ci-builder` is absent
— so the first builder image cannot publish until this file lands.

**Zero behavior change for any existing job**: nothing on main
references either file until the entrypoint wiring in #27077 merges.
What this unblocks, in order:

1. Dispatch/nightly of "Build and Push Images" publishes
`matrixorigin/matrixone:ci-builder` (amd64, Docker Hub + ACR mirror).
2. The UT and coverage-UT cache seeds already live in `matrixorigin/CI
ci.yaml` go from no-op to active (guarded, `continue-on-error`,
cold-build fallback — validated in matrixorigin/CI#418's review rounds).
3. The canary #27077's reviewers require (shared-build path incl. forced
cached-build failure) becomes runnable, after which #27077 leaves draft.

Both Dockerfiles passed `docker build --check`, and a full local image
build on current main + fingerprint/warm-status verification is
documented in matrixorigin/CI#418.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5 <[email protected]>
@fengttt

fengttt commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Canary evidence, part 1 (image published; seed paths live for every PR):

Image publish — "Build and Push Images" run 31827878168 fully green after the ACR attestation fix (matrixorigin/CI#425): product images push again (they had been failing since at least 2026-08-13), and the first matrixorigin/matrixone:ci-builder published to Docker Hub + ACR. Verified post-publish: 3.50GB compressed (10 layers, 13.4GB uncompressed), anonymous Docker Hub pull 1m23s (non-CI vantage), anonymous ACR access confirmed (no credential needed anywhere, consistent with the trust contract), warm-status = warm-race=ok + warm-coverage=ok, fingerprint matches main's thirdparties tree.

Seed canary — rerun of this PR's failed CI jobs (run 31827792011, attempt 2) came back green (prior failures were test flakes; nothing in the new machinery). Observed live:

  • UT job (self-hosted Shanghai pool): Go build cache already populated; skipping seed — the persistent-runner early-exit engaged before any pull, ~0s overhead. This is the designed behavior where seeding is unnecessary; the seed's value case is ephemeral/cold runners, which the next fresh runs will exercise (both seeds are live on CI@main for every PR now).
  • Attempt-1 timing (image mid-publish at the time): both seeds no-op'd gracefully and every job proceeded on its normal path — the first-nightly-absent degradation arc validated in production.

Remaining before Ready: (a) a cold-runner seed observation (will land with normal PR traffic; I'll post it), and (b) the shared-build path itself, which only activates with this PR's entrypoint wiring — pre-merge it cannot run under pull_request_target because the base branch supplies the workflow. Two options: quiet-window merge with revert readiness (first PRs after merge are the canary; a forced cached-failure test PR follows immediately), or a temporary canary base branch on matrixorigin/matrixone carrying the wired entrypoint (needs a maintainer to create it and the entrypoint branch filter to include it). @XuPeng-SH @aptend @LeftHandCold — which do you prefer?

🤖 Generated with Claude Code

This branch was previously deployed

1 inactive deployment
ci — 91d33e7b Deployed Aug 14, 2026 by fengttt via Matrixone Utils CI / Coverage #46467
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants