ci: install dolt binary on Linux and macOS test runners (#3440)

* ci: install dolt binary on Linux and macOS test runners

Install dolt via the official install.sh on Linux and via Homebrew on
macOS so the main test job can exercise the ~24 test gates that
previously silently skipped on every PR when dolt was absent from PATH.

Matches the installation pattern already used by nightly.yml.
Docker-testcontainer gates (testDoltServerPort == 0 skips) remain
skipped — a known GitHub Actions hang documented in
scripts/repro-dolt-hang/INCIDENT-REPORT.md and nightly.yml:37-41
prevents enabling testcontainers here.

* test: require dolt binary under GITHUB_ACTIONS

Add testutil.RequireDoltBinary: skips when the dolt CLI is absent
locally but fails the test under GITHUB_ACTIONS. Replace bare
exec.LookPath("dolt") skip-gates with the helper so ~24 tests that
previously fell through silently in CI now run — and hard-fail if
the CI workflow ever drops the dolt install step.

tests/regression/regression_test.go uses an inline variant because
its gate lives in TestMain, and internal/remotecache/cache_test.go
duplicates the helper inline to avoid an import cycle
(testutil -> doltutil -> remotecache).
This commit is contained in:
Steven Syrek 2026-04-24 15:58:40 +02:00 • committed by GitHub
commit f0057c7828
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 65 additions and 72 deletions

View file

@ -101,10 +101,20 @@ jobs:
with:
go-version-file: 'go.mod'
- name: Configure Git
- name: Install Dolt (Linux)
if: runner.os == 'Linux'
run: curl -fsSL https://github.com/dolthub/dolt/releases/latest/download/install.sh | sudo bash
- name: Install Dolt (macOS)
if: runner.os == 'macOS'
run: brew install dolt
- name: Configure Git and Dolt identity
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
dolt config --global --add user.name "CI Bot"
dolt config --global --add user.email "ci@beads.test"
- name: Install gotestsum
if: matrix.coverage

View file

@ -5,7 +5,6 @@ import (
"fmt"
"net"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
@ -36,9 +35,7 @@ func TestMain(m *testing.M) {
func skipIfNoDolt(t *testing.T) {
t.Helper()
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("Dolt not installed, skipping test")
}
testutil.RequireDoltBinary(t)
}
func skipIfNoDoltServer(t *testing.T) {

View file

@ -11,6 +11,7 @@ import (
"github.com/steveyegge/beads/internal/configfile"
"github.com/steveyegge/beads/internal/storage/dolt"
"github.com/steveyegge/beads/internal/testutil"
)
// setupDoltWorkspace creates a temp beads workspace with a Dolt database.
@ -18,9 +19,7 @@ import (
// Returns the workspace root path.
func setupDoltWorkspace(t *testing.T) string {
t.Helper()
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("Dolt not installed, skipping test")
}
testutil.RequireDoltBinary(t)
dir := t.TempDir()
beadsDir := filepath.Join(dir, ".beads")

View file

@ -18,15 +18,14 @@ import (
"github.com/steveyegge/beads/internal/configfile"
"github.com/steveyegge/beads/internal/git"
"github.com/steveyegge/beads/internal/storage/dolt"
"github.com/steveyegge/beads/internal/testutil"
)
// skipIfNoDolt skips the test when no Dolt server is available.
// Checks both binary availability and test server status.
func skipIfNoDolt(t *testing.T) {
t.Helper()
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("skipping: dolt not installed")
}
testutil.RequireDoltBinary(t)
if testDoltServerPort == 0 {
t.Skip("skipping: Dolt test server not running")
}
@ -1443,10 +1442,7 @@ func TestInit_WithBEADS_DIR_DoltBackend(t *testing.T) {
t.Skip("Skipping BEADS_DIR Dolt test on Windows")
}
// Check if dolt is available
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("Dolt not installed, skipping Dolt backend test")
}
testutil.RequireDoltBinary(t)
// Reset global state
origDBPath := dbPath
@ -1516,9 +1512,6 @@ func TestInitDoltMetadata(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping Dolt metadata test on Windows")
}
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("Dolt not installed, skipping Dolt metadata test")
}
saveAndRestoreGlobals(t)
dbPath = ""
@ -1630,9 +1623,6 @@ func TestInitDoltMetadataNoGit(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping Dolt metadata test on Windows")
}
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("Dolt not installed, skipping Dolt metadata test")
}
saveAndRestoreGlobals(t)
dbPath = ""

View file

@ -160,9 +160,7 @@ func testPrefix(t *testing.T) string {
func newWorkspace(t *testing.T) *workspace {
t.Helper()
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("skipping: dolt not installed")
}
testutil.RequireDoltBinary(t)
if testDoltPort == 0 {
t.Skip("skipping: test Dolt server not available")
}

View file

@ -10,11 +10,18 @@ import (
"time"
)
// skipIfNoDolt skips the test if the dolt CLI is not installed.
// skipIfNoDolt skips the test if the dolt CLI is not installed. Under
// GitHub Actions the test fails instead — CI must install dolt.
//
// (Duplicated inline rather than importing testutil.RequireDoltBinary to avoid
// an import cycle: testutil → doltutil → remotecache.)
func skipIfNoDolt(t *testing.T) {
t.Helper()
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt CLI not found, skipping integration test")
if os.Getenv("GITHUB_ACTIONS") == "true" {
t.Fatalf("dolt binary missing under GITHUB_ACTIONS: %v — the CI workflow must install dolt", err)
}
t.Skipf("dolt CLI not found, skipping integration test: %v", err)
}
}

View file

@ -6,6 +6,8 @@ import (
"os/exec"
"path/filepath"
"testing"
"github.com/steveyegge/beads/internal/testutil"
)
func TestEncryptDecryptWithKey(t *testing.T) {
@ -340,9 +342,7 @@ func setupCredentialTestStoreWithURL(t *testing.T, remoteUser, remotePassword st
// CLI subprocess routing for Push, ForcePush, and Pull when credentials are set.
// The guard is shared across all three operations (same insertion pattern in store.go).
func TestCredentialCLIRouting(t *testing.T) {
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt not installed, skipping credential routing test")
}
testutil.RequireDoltBinary(t)
tests := []struct {
name string
@ -406,9 +406,7 @@ func TestCredentialCLIRoutingNoRemote(t *testing.T) {
}
func TestCredentialCLIRoutingSharedServerUsesSharedDoltRoot(t *testing.T) {
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt not installed, skipping shared-server credential routing test")
}
testutil.RequireDoltBinary(t)
sharedRoot := t.TempDir()
t.Setenv("BEADS_DOLT_SHARED_SERVER", "1")
@ -448,9 +446,7 @@ func TestCredentialCLIRoutingSharedServerUsesSharedDoltRoot(t *testing.T) {
}
func TestCloudAuthCLIRoutingSharedServerUsesSharedDoltRoot(t *testing.T) {
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt not installed, skipping shared-server cloud-auth routing test")
}
testutil.RequireDoltBinary(t)
sharedRoot := t.TempDir()
t.Setenv("BEADS_DOLT_SHARED_SERVER", "1")
@ -492,9 +488,7 @@ func TestCloudAuthCLIRoutingSharedServerUsesSharedDoltRoot(t *testing.T) {
// that controls CLI subprocess routing for federation PushTo, PullFrom, and Fetch
// when peer credentials are resolved from the federation_peers table.
func TestFederationCredentialCLIRouting(t *testing.T) {
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt not installed, skipping credential routing test")
}
testutil.RequireDoltBinary(t)
tests := []struct {
name string
@ -528,9 +522,7 @@ func TestFederationCredentialCLIRouting(t *testing.T) {
}
func TestCloudAuthCLIRouting(t *testing.T) {
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt not installed")
}
testutil.RequireDoltBinary(t)
tests := []struct {
name string
@ -576,9 +568,7 @@ func TestCloudAuthCLIRouting(t *testing.T) {
}
func TestCloudAuthCLIRoutingStructural(t *testing.T) {
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt not installed")
}
testutil.RequireDoltBinary(t)
t.Run("embedded mode", func(t *testing.T) {
store := setupCredentialTestStoreWithURL(t, "", "", false, true, "origin", "az://account.blob.core.windows.net/container")
@ -600,9 +590,7 @@ func TestCloudAuthCLIRoutingStructural(t *testing.T) {
// DoltHub (primary) + Azure (backup) remotes. AZURE_STORAGE_ACCOUNT should
// trigger CLI routing ONLY for the Azure remote, not the DoltHub remote.
func TestPerRemoteCloudAuthHybrid(t *testing.T) {
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt not installed")
}
testutil.RequireDoltBinary(t)
tmpDir := t.TempDir()
dbName := "testdb"

View file

@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"os"
"os/exec"
"strings"
"testing"
"time"
@ -52,9 +51,7 @@ func testContext(t *testing.T) (context.Context, context.CancelFunc) {
// TestMain in testmain_test.go.
func skipIfNoDolt(t *testing.T) {
t.Helper()
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("Dolt not installed, skipping test")
}
testutil.RequireDoltBinary(t)
if testServerPort == 0 {
t.Skip("Test Dolt server not running, skipping test")
}

View file

@ -22,9 +22,7 @@ import (
// route credential-bearing pushes through the shared Dolt root even when the
// per-project dbPath is stale and lacks the remote.
func TestCredentialCLIRoutingE2ESharedServer(t *testing.T) {
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt not installed, skipping test")
}
testutil.RequireDoltBinary(t)
skipIfNoGit(t)
baseDir, err := os.MkdirTemp("", "credential-cli-routing-shared-server-e2e-*")

View file

@ -1004,9 +1004,7 @@ func findClonedDBName(t *testing.T, doltDir string) string {
// false when the SQL server reports a git-protocol remote but the CLI directory
// (dbPath) lacks that remote.
func TestGitRemoteExternalServerRouting(t *testing.T) {
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt not installed, skipping test")
}
testutil.RequireDoltBinary(t)
skipIfNoGit(t)
baseDir, err := os.MkdirTemp("", "external-server-routing-*")
@ -1108,9 +1106,7 @@ func TestGitRemoteExternalServerRouting(t *testing.T) {
// If the guard fails and falls through to SQL withEnvCredentials, the external
// server process cannot see the env vars and push fails (SC-001).
func TestCredentialCLIRoutingE2E(t *testing.T) {
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt not installed, skipping test")
}
testutil.RequireDoltBinary(t)
skipIfNoGit(t)
baseDir, err := os.MkdirTemp("", "credential-cli-routing-e2e-*")

View file

@ -2,7 +2,6 @@ package migrations
import (
"database/sql"
"os/exec"
"testing"
"time"
@ -17,9 +16,7 @@ import (
func openTestDoltBranch(t *testing.T) *sql.DB {
t.Helper()
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("dolt binary not found, skipping migration test")
}
testutil.RequireDoltBinary(t)
if testServerPort == 0 {
t.Skip("test Dolt server not running, skipping migration test")
}

View file

@ -3,12 +3,29 @@ package testutil
import (
"fmt"
"net"
"os"
"os/exec"
"testing"
"time"
)
// DoltDockerImage is the Docker image used for Dolt test containers.
const DoltDockerImage = "dolthub/dolt-sql-server:1.86.0"
// RequireDoltBinary ensures the `dolt` CLI binary is available. The test is
// skipped locally when dolt is missing but fatally fails under GitHub Actions
// (GITHUB_ACTIONS=true). CI is expected to install dolt; a missing binary
// there means the workflow is broken, not that the test should be skipped.
func RequireDoltBinary(t *testing.T) {
t.Helper()
if _, err := exec.LookPath("dolt"); err != nil {
if os.Getenv("GITHUB_ACTIONS") == "true" {
t.Fatalf("dolt binary missing under GITHUB_ACTIONS: %v — the CI workflow must install dolt (see .github/workflows/ci.yml)", err)
}
t.Skipf("dolt binary not found: %v", err)
}
}
// FindFreePort finds an available TCP port by binding to :0.
func FindFreePort() (int, error) {
l, err := net.Listen("tcp", "127.0.0.1:0")

View file

@ -5,7 +5,6 @@ package tracker
import (
"context"
"fmt"
"os/exec"
"strings"
"testing"
"time"
@ -19,9 +18,7 @@ import (
// newTestStore creates a dolt store on the shared database with branch isolation.
func newTestStore(t *testing.T) *dolt.DoltStore {
t.Helper()
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("Dolt not installed, skipping test")
}
testutil.RequireDoltBinary(t)
if testServerPort == 0 || testSharedDB == "" {
t.Skip("shared test Dolt database not initialized, skipping test")
}

View file

@ -7,18 +7,16 @@ import (
"crypto/rand"
"encoding/hex"
"fmt"
"os/exec"
"testing"
"github.com/steveyegge/beads/internal/storage/dolt"
"github.com/steveyegge/beads/internal/testutil"
"github.com/steveyegge/beads/internal/types"
)
func newTestStore(t *testing.T) *dolt.DoltStore {
t.Helper()
if _, err := exec.LookPath("dolt"); err != nil {
t.Skip("Dolt not installed, skipping test")
}
testutil.RequireDoltBinary(t)
if testServerPort == 0 {
t.Skip("Test Dolt server not running, skipping test")
}

View file

@ -49,6 +49,10 @@ func TestMain(m *testing.M) {
// Start an isolated Dolt server so regression tests don't pollute
// the production database on port 3307.
if _, err := exec.LookPath("dolt"); err != nil {
if os.Getenv("GITHUB_ACTIONS") == "true" {
fmt.Fprintln(os.Stderr, "FAIL: dolt missing under GITHUB_ACTIONS — CI workflow must install dolt")
os.Exit(1)
}
fmt.Fprintln(os.Stderr, "SKIP: dolt not found in PATH; regression tests require dolt")
os.Exit(0)
}