* chore(migration-test): extend the release catalog through v1.3.1 The catalog stopped at v1.1.2 (the v1.2 upgrade census). The migration corpus already upgrades from v1.2.2, and the Bazel targets that replace migration-test.yml and cross-version-smoke.yml take their pinned release binaries from the catalog (@bd_releases), so it has to cover the releases since. Regenerated with `catalog generate` after raising maximumVersion to v1.3.1: five new stable versions (v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.3.1; three with a linux/amd64 asset) and five new proxy prereleases; no existing entry, drift record or repository-only exclusion changed. The count constants and the identity digest are updated to match, and the README now says how to add a release. Refs: ga-96smfk.19 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * ci(bazel): run the historical-upgrade corpus under Bazel; retire migration-test.yml migration-test.yml ran scripts/migration-test/run.sh --version <release> for 14 reviewed releases in 3 shards on GitHub runners: it downloaded each release archive, built v0.9.1 from source with Go 1.25 through the module proxy, installed libicu74 and the dolt 2.1.8 runtime, all over the network. //tests/migration now has one target per corpus release (historical_upgrade_<release>_test) plus legacy_bridge_test, all hermetic: - Published releases come from @bd_releases (the release catalog's sha256-verified assets) through a per-target directory (HISTORICAL_RELEASE_DIR); lib/binary.sh uses it instead of downloading and still checks each binary's self-reported version. - v0.9.1 is //tests/migration:bd_source_tag, the same `go mod download` + `go build -trimpath` with CGO and Go 1.25.0, run offline as a build action: the module files come from tests/migration/source_tag_modules.json through a file:// GOPROXY tree (tools/bazel/go_module_proxy.bzl), the release's own zip is the catalog's source_zip, and go checks every dependency against the release's go.sum (SOURCE_TAG_SQLITE_BIN). - The external Dolt runtime is @dolt_test_runtime_linux_amd64 (dolt.bzl's dolt_release gains a version attribute; 2.1.8 is pinned to versions.sh's digest), passed as DOLT_BIN to the server-Dolt and wisp-plane releases. - The workers already provide jq, python3, sqlite3 and libicu74. The targets are untagged, so bazel-test runs them remotely on every PR, merge group and push; result caching replaces the path filter. Every release also passed inside a loopback-only network namespace. scripts/migration_corpus_bazel_test.go keeps the BUILD lists equal to versions.sh's corpus, the catalog digests equal to STRICT_RELEASE_SHA256, the source-tag lock equal to the catalog's source_zip, and the Dolt runtime pin equal to versions.sh's. migration-test.yml and the policy tests that pinned its shards, caches, apt step and runner are removed. Refs: ga-96smfk.19 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * ci(bazel): run the historical-upgrade targets in the PR-core lane only The integration lane runs every untagged target too, and its check_testcases.py requires Go testcases, which a shell test's test.xml does not list. A new pr-core-only tag keeps //tests/migration out of --config=integration (bazelIntegrationExcludedTags adds it), so the corpus runs once, in bazel-test, against the release-shaped bd_for_tests (no integration tag). build_source_tag.sh carries the build-tags opt-out: it builds a historical release with that release's own go.mod, which predates gms_pure_go. Refs: ga-96smfk.19 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
187 lines
7.4 KiB
Go
187 lines
7.4 KiB
Go
package scripts_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"regexp"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// The historical-upgrade corpus runs as //tests/migration's per-release
|
|
// targets. Their release list and their pinned inputs live in Bazel files;
|
|
// scripts/migration-test/lib/versions.sh stays the reviewed definition of the
|
|
// corpus. These checks keep the two equal, so a release added to the corpus
|
|
// gets a target and a pinned binary, and a target never runs a binary whose
|
|
// digest differs from the one the harness would have verified.
|
|
|
|
// bashArray returns the elements of `declare -ar NAME=( ... )` in versions.sh.
|
|
func bashArray(t *testing.T, src, name string) []string {
|
|
t.Helper()
|
|
m := regexp.MustCompile(`(?s)declare -ar ` + name + `=\((.*?)\)`).FindStringSubmatch(src)
|
|
if m == nil {
|
|
t.Fatalf("versions.sh has no array %s", name)
|
|
}
|
|
return regexp.MustCompile(`"([^"]+)"`).FindAllString(m[1], -1)
|
|
}
|
|
|
|
// bashScalar returns the value of `readonly NAME="..."` in versions.sh.
|
|
func bashScalar(t *testing.T, src, name string) string {
|
|
t.Helper()
|
|
m := regexp.MustCompile(`(?m)^readonly ` + name + `="([^"]*)"$`).FindStringSubmatch(src)
|
|
if m == nil {
|
|
t.Fatalf("versions.sh has no scalar %s", name)
|
|
}
|
|
return m[1]
|
|
}
|
|
|
|
// starlarkList returns the string elements of `NAME = [ ... ]` in a BUILD file.
|
|
func starlarkList(t *testing.T, src, name string) []string {
|
|
t.Helper()
|
|
m := regexp.MustCompile(`(?s)\n` + name + ` = \[(.*?)\]`).FindStringSubmatch(src)
|
|
if m == nil {
|
|
t.Fatalf("tests/migration/BUILD.bazel has no list %s", name)
|
|
}
|
|
var out []string
|
|
for _, q := range regexp.MustCompile(`"([^"]+)"`).FindAllStringSubmatch(m[1], -1) {
|
|
out = append(out, q[1])
|
|
}
|
|
return out
|
|
}
|
|
|
|
func unquote(items []string) []string {
|
|
out := make([]string, len(items))
|
|
for i, s := range items {
|
|
out[i] = strings.Trim(s, `"`)
|
|
}
|
|
return out
|
|
}
|
|
|
|
func sortedSet(items ...[]string) []string {
|
|
var out []string
|
|
for _, list := range items {
|
|
out = append(out, list...)
|
|
}
|
|
slices.Sort(out)
|
|
return slices.Compact(out)
|
|
}
|
|
|
|
func TestMigrationCorpusBazelTargetsMatchVersionsSh(t *testing.T) {
|
|
root := sourceRepoRoot(t)
|
|
versions := readPolicyFile(t, root, "scripts/migration-test/lib/versions.sh")
|
|
build := readPolicyFile(t, root, "tests/migration/BUILD.bazel")
|
|
|
|
sqlite := []string{
|
|
bashScalar(t, versions, "SOURCE_TAG_SQLITE_VERSION"),
|
|
bashScalar(t, versions, "PRE_CANONICAL_SQLITE_VERSION"),
|
|
bashScalar(t, versions, "CLASSIC_SQLITE_VERSION"),
|
|
bashScalar(t, versions, "CONFIGURED_SQLITE_VERSION"),
|
|
}
|
|
server := unquote(bashArray(t, versions, "HISTORICAL_DOLT_VERSIONS"))
|
|
embedded := unquote(bashArray(t, versions, "EMBEDDED_DOLT_VERSIONS"))
|
|
wisp := unquote(bashArray(t, versions, "WISP_PLANE_VERSIONS"))
|
|
|
|
if got, want := sortedSet(starlarkList(t, build, "_CORPUS")), sortedSet(sqlite, server, embedded); !slices.Equal(got, want) {
|
|
t.Errorf("tests/migration _CORPUS = %v, want versions.sh's corpus %v", got, want)
|
|
}
|
|
if got, want := sortedSet(starlarkList(t, build, "_DOLT_RUNTIME")), sortedSet(server, wisp); !slices.Equal(got, want) {
|
|
t.Errorf("tests/migration _DOLT_RUNTIME = %v, want HISTORICAL_DOLT_VERSIONS + WISP_PLANE_VERSIONS %v", got, want)
|
|
}
|
|
if m := regexp.MustCompile(`(?m)^_SOURCE_TAG = "([^"]+)"$`).FindStringSubmatch(build); m == nil || m[1] != sqlite[0] {
|
|
t.Errorf("tests/migration _SOURCE_TAG = %v, want SOURCE_TAG_SQLITE_VERSION %s", m, sqlite[0])
|
|
}
|
|
if !strings.Contains(build, `"github.com/steveyegge/beads `+sqlite[0]+` `+bashScalar(t, versions, "SOURCE_TAG_SQLITE_GO_TOOLCHAIN")+`"`) {
|
|
t.Errorf("tests/migration:bd_source_tag does not build %s@%s with %s",
|
|
bashScalar(t, versions, "SOURCE_TAG_SQLITE_MODULE"), sqlite[0], bashScalar(t, versions, "SOURCE_TAG_SQLITE_GO_TOOLCHAIN"))
|
|
}
|
|
}
|
|
|
|
// Every pinned release a target runs is the archive lib/binary.sh would have
|
|
// downloaded and verified: the catalog's linux/amd64 digest (what
|
|
// @bd_releases checks) equals STRICT_RELEASE_SHA256.
|
|
func TestMigrationCorpusCatalogDigestsMatchStrictPins(t *testing.T) {
|
|
root := sourceRepoRoot(t)
|
|
versions := readPolicyFile(t, root, "scripts/migration-test/lib/versions.sh")
|
|
var catalog struct {
|
|
Versions []struct {
|
|
Version string `json:"version"`
|
|
GithubRelease *struct {
|
|
Asset *struct {
|
|
Name string `json:"name"`
|
|
Digest string `json:"digest"`
|
|
} `json:"linux_amd64_asset"`
|
|
} `json:"github_release"`
|
|
SourceZip struct {
|
|
SHA256 string `json:"sha256"`
|
|
} `json:"source_zip"`
|
|
} `json:"versions"`
|
|
}
|
|
if err := json.Unmarshal([]byte(readPolicyFile(t, root, "scripts/migration-test/release-catalog.json")), &catalog); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
digests, sourceZips := map[string]string{}, map[string]string{}
|
|
for _, v := range catalog.Versions {
|
|
sourceZips[v.Version] = v.SourceZip.SHA256
|
|
if v.GithubRelease != nil && v.GithubRelease.Asset != nil {
|
|
digests[v.Version] = strings.TrimPrefix(v.GithubRelease.Asset.Digest, "sha256:")
|
|
}
|
|
}
|
|
pins := regexp.MustCompile(`\["(v[^|"]+)\|linux\|amd64"\]="([0-9a-f]{64})"`).FindAllStringSubmatch(versions, -1)
|
|
if len(pins) == 0 {
|
|
t.Fatal("versions.sh has no linux/amd64 STRICT_RELEASE_SHA256 pins")
|
|
}
|
|
for _, p := range pins {
|
|
if got := digests[p[1]]; got != p[2] {
|
|
t.Errorf("%s: catalog linux_amd64 digest %q, versions.sh STRICT_RELEASE_SHA256 %q", p[1], got, p[2])
|
|
}
|
|
}
|
|
|
|
// The source-tag build's own module zip is the catalog's source_zip.
|
|
var lock struct {
|
|
Module string `json:"module"`
|
|
Version string `json:"version"`
|
|
Modules []struct {
|
|
Path string `json:"path"`
|
|
Version string `json:"version"`
|
|
ZipSHA256 string `json:"zip_sha256"`
|
|
} `json:"modules"`
|
|
}
|
|
if err := json.Unmarshal([]byte(readPolicyFile(t, root, "tests/migration/source_tag_modules.json")), &lock); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if want := bashScalar(t, versions, "SOURCE_TAG_SQLITE_VERSION"); lock.Version != want || lock.Module != bashScalar(t, versions, "SOURCE_TAG_SQLITE_MODULE") {
|
|
t.Errorf("source_tag_modules.json pins %s@%s, want %s@%s", lock.Module, lock.Version, bashScalar(t, versions, "SOURCE_TAG_SQLITE_MODULE"), want)
|
|
}
|
|
found := false
|
|
for _, m := range lock.Modules {
|
|
if m.Path == lock.Module && m.Version == lock.Version {
|
|
found = true
|
|
if m.ZipSHA256 != sourceZips[lock.Version] {
|
|
t.Errorf("source_tag_modules.json %s zip %q, catalog source_zip %q", lock.Version, m.ZipSHA256, sourceZips[lock.Version])
|
|
}
|
|
}
|
|
}
|
|
if !found {
|
|
t.Errorf("source_tag_modules.json does not pin %s@%s itself", lock.Module, lock.Version)
|
|
}
|
|
}
|
|
|
|
// The external Dolt runtime the server-Dolt and wisp-plane lanes run is the
|
|
// one versions.sh pins: same release, same archive digest.
|
|
func TestMigrationDoltRuntimeMatchesVersionsSh(t *testing.T) {
|
|
root := sourceRepoRoot(t)
|
|
versions := readPolicyFile(t, root, "scripts/migration-test/lib/versions.sh")
|
|
version := strings.TrimPrefix(bashScalar(t, versions, "DOLT_TEST_RUNTIME_VERSION"), "v")
|
|
digest := bashScalar(t, versions, "DOLT_TEST_RUNTIME_SHA256")
|
|
|
|
module := readPolicyFile(t, root, "MODULE.bazel")
|
|
m := regexp.MustCompile(`(?s)name = "dolt_test_runtime_linux_amd64",\s*platform = "linux-amd64",\s*version = "([^"]+)",`).FindStringSubmatch(module)
|
|
if m == nil || m[1] != version {
|
|
t.Errorf("MODULE.bazel's dolt_test_runtime_linux_amd64 = %v, want version %q", m, version)
|
|
}
|
|
bzl := readPolicyFile(t, root, "tools/bazel/dolt.bzl")
|
|
d := regexp.MustCompile(`(?s)"` + regexp.QuoteMeta(version) + `": \{\s*"linux-amd64": "([0-9a-f]{64})",`).FindStringSubmatch(bzl)
|
|
if d == nil || d[1] != digest {
|
|
t.Errorf("tools/bazel/dolt.bzl DOLT_SHA256[%q][linux-amd64] = %v, want %s", version, d, digest)
|
|
}
|
|
}
|