beads/.github/workflows
Mark Atwood ba09472ddd
feat(storage): backend-agnostic conformance test suite (#4414)
* feat(storage): add backend-agnostic conformance test suite

40 behavioral contract tests any Storage/DoltStorage implementation
can run via conformance.RunAll(t, factory).

Covers: CRUD (12), search/filter (6), dependencies (3),
ready/blocked (5), labels (3), comments (2), config (2),
metadata slots (1), statistics (1), iterators (2), transactions (1).

Usage:
  func TestConformance(t *testing.T) {
      conformance.RunAll(t, func(t *testing.T) storage.DoltStorage {
          return newTestStore(t)
      })
  }

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test(storage): wire conformance suite into Dolt backends + fix suite to run green

Wire conformance.RunAll into the real Dolt backends so the storage contract is
enforced against an implementation rather than only asserted, and fix the
issues that surfaced the first time the suite ran against a backend (the PR's
"wire into existing Dolt backend tests" box was still unchecked).

- internal/storage/embeddeddolt/conformance_test.go: run the suite against the
  embedded backend. Gated by BEADS_TEST_EMBEDDED_DOLT=1 like its siblings, so
  it executes in the existing test-embedded-storage CI job and self-skips in
  the main fast test job.
- internal/storage/dolt/conformance_test.go: run the suite against server-mode
  Dolt via setupTestStore (branch-isolated, self-skips with no test server).
  Enforcing this every-PR needs a CI job that runs with a live dolt-sql-server;
  tracked as a follow-up.

Suite corrections (it had never been run against a backend):
- Factory contract now documents that the store must be initialized
  (issue_prefix set), and the embedded factory sets it. The storage layer
  validates issue_prefix and does not default it; bd's CLI layer does.
- withDefaults() fills the Status/IssueType the storage layer requires and does
  not default, so terse test literals stay valid.
- Not-found checks use errors.Is(err, storage.ErrNotFound) instead of strict
  equality, since backends wrap the sentinel with context.
- CreateDuplicate asserts the data-integrity invariant (exactly one row for the
  ID after a duplicate create) instead of expecting an error; beads' storage
  layer intentionally upserts on duplicate ID. The test deliberately does not
  bless last-writer-wins overwrite.

Backend parity fix the suite caught:
- issueops/delete.go: DeleteIssue now wraps storage.ErrNotFound, matching
  GetIssue/UpdateIssue. CloseIssue has the same latent gap (untested here);
  tracked as a follow-up.

Co-Authored-By: Mark Atwood <34491708+MarkAtwood@users.noreply.github.com>
Agent-Signature: claude-opus-4-8-high on behalf of matt wilkie

* test(storage): drop dead unused-import anchors in conformance suite

Remove `var _ = fmt.Sprintf` / `var _ = time.Now` and the now-unused fmt
import. time is still used (time.Date in testUpdatePreservesCreatedAt), so only
fmt drops. No behavioral change.

Flagged by kevglynn's over-engineering pass on the sister flat-file PR #4415;
absorbing it here since this PR owns conformance.go.

Co-Authored-By: kevglynn <12972584+kevglynn@users.noreply.github.com>
Agent-Signature: claude-opus-4-8-high on behalf of matt wilkie

* ci: run embedded conformance suite in its own job

Wiring the conformance suite into test-embedded-storage (4e6aaad) pushed that
job past its 10m -test.timeout (panic: test timed out after 10m0s); the
embedded Dolt backend opens a fresh DB per test, so the ~38-scenario
conformance.RunAll added several minutes of wall-clock.

Split TestConformance into a dedicated test-embedded-conformance job instead of
bumping the timeout, so both jobs stay well inside their envelopes and run in
parallel. The job reuses the already-built embeddeddolt-test artifact (no extra
build); test-embedded-storage now -test.skip's TestConformance, the new job
-test.run's only it. Mirrors the dedicated-conformance-job shape planned for the
server backend (mybd-665b). Registered in ci-gate (required, skipped_ok under
full_embedded).

Agent-Signature: claude-opus-4-8-high on behalf of matt wilkie

* ci: enforce conformance suite against server-mode Dolt

internal/storage/dolt/conformance_test.go runs conformance.RunAll against
server-mode Dolt but self-skips everywhere in CI today (no docker image cached
-> isDoltImageCached() false). Add a dedicated test-server-storage job so the
storage contract is enforced against a real server backend on every storage PR,
not just the embedded backend.

build-embedded now also compiles /tmp/dolt-conformance-test (no -race; the Dolt
server runs out-of-process in a container). The new job downloads that binary,
installs+configures the dolt CLI, pulls dolthub/dolt-sql-server:2.1.0 (presence
flips isDoltImageCached() true so TestMain starts the shared server), and runs
-test.run '^TestConformance$' without -short / BEADS_TEST_SKIP=dolt. Server
setup mirrors regression.yml; job shape mirrors the test-embedded-conformance
twin. Registered in ci-gate (required + skipped_ok under full_embedded).

Completes the embedded+server halves of the storage conformance contract
(mybd-9rro criterion 3 / mybd-665b).

Agent-Signature: claude-opus-4-8-high on behalf of matt wilkie

* fix(storage/dolt): stop IterIssues deadlocking under MaxOpenConns=1

The streaming doltIssueIter held a dedicated *sql.Conn for the row cursor and
hydrated each row's labels on a SECOND pool connection (iterFetchLabels via
s.db). That assumes the pool can grant a second connection. Server-mode Dolt
pins each store to MaxOpenConns=1 (branch isolation is session-level:
DOLT_CHECKOUT applies to the connection), so the label query blocks forever
waiting for the cursor's connection -> deadlock whenever IterIssues returns
>=1 row. The server-conformance CI job surfaced it: TestConformance/IterIssues
hung to the 15m timeout. Embedded didn't, because it sets MaxOpenConns=2 and
its IterIssues is slice-then-walk.

Per-row hydration over a held cursor is fundamentally incompatible with a
single connection, so do what SearchIssues already does: read the issue rows
and batch-hydrate labels (WHERE issue_id IN (...) via
GetLabelsForIssuesFromTableInTx) inside one read transaction on one connection,
then wrap the result in storage.NewSliceIter. Same query/filter/ORDER BY/LIMIT;
labels now follow the SearchIssues convention (nil when an issue has none).
Removes the dedicated-conn doltIssueIter and iterFetchLabels.

Fixes mybd-2pcb. Unblocks the server-conformance job (mybd-665b).

Agent-Signature: claude-opus-4-8-high on behalf of matt wilkie

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
Co-authored-by: kevglynn <12972584+kevglynn@users.noreply.github.com>
2026-07-01 22:25:45 -07:00
..
ci-measurements.yml : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
cross-version-smoke.yml : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
deploy-docs.yml build(deps): bump actions/checkout from 6.0.2 to 7.0.0 (#4456) 2026-06-22 13:17:29 -07:00
main.yml feat(gate): state-aware smart remote-migrate gate (#4516) 2026-06-30 14:31:04 -07:00
migration-test.yml : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
nightly.yml : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
nix-build.yml : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
pr-risk.yml feat(storage): backend-agnostic conformance test suite (#4414) 2026-07-01 22:25:45 -07:00
pr.yml : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
regression.yml : refactor to use RunE, emit usage metrics, skip metrics in CI 2026-06-22 20:44:43 +00:00
release.yml chore: re-land v1.1.0-rc.1 release prep (#4486) 2026-06-25 20:10:18 -07:00
test-pypi.yml build(deps): bump actions/checkout from 6.0.2 to 7.0.0 (#4456) 2026-06-22 13:17:29 -07:00
update-flake-lock.yml build(deps): bump actions/checkout from 6.0.2 to 7.0.0 (#4456) 2026-06-22 13:17:29 -07:00
update-vendor-hash.yml build(deps): bump actions/checkout from 6.0.2 to 7.0.0 (#4456) 2026-06-22 13:17:29 -07:00