Design 47 H1: package edges from go.mod; a pin is the newest released version, in every form's fingerprint; a release re-pins its importers (H-A-157, H-A-161, H-A-165, H-A-167, H-A-172) #279
@@ -24,15 +24,16 @@ type form struct {
|
||||
//
|
||||
// - **The import form**, for a module whose last trunk build reported its imports (kept.Imports) when every import is
|
||||
// published (the packages state): the content digest of each imported package and the requirements' digest of each
|
||||
// mesh Go module holding one. Its versions are each holding module's published commit (another repository's only).
|
||||
// mesh Go module holding one. Its versions are each holding module's published commit (another repository's only); an
|
||||
// import set naming none of another repository while the go.mod requires one keeps the version line's (refined).
|
||||
// - **A change of form never rebuilds by itself** (§4): kept.ImportForm is the import-form fingerprint of the inputs
|
||||
// the build that reported the imports was built from. While the import form computes to it, nothing the build was
|
||||
// built from changed: the module keeps the fingerprint it holds (prev), in whatever form, and its versions.
|
||||
// Otherwise the import form is written, and ImportForm moves with it.
|
||||
// - **The version line** otherwise (no import set, or an import none publishes): the version of each mesh Go module of
|
||||
// another repository its go.sum names, read as the indexer always read it (fingerprint.HeldVersionsOf), and the
|
||||
// content of each mesh Go module of its own repository its go.mod replaces by a directory (fingerprint.VersionLine),
|
||||
// so a change of that directory alone moves it (review finding 2). Its versions are the other repositories' alone.
|
||||
// another repository its go.mod requires, at any version (design 47 H-A-157), read as the indexer always read it
|
||||
// (fingerprint.HeldVersionsOf), and the content of each mesh Go module of its own repository its go.mod replaces by a
|
||||
// directory (fingerprint.VersionLine), so a change of that directory alone moves it (review finding 2). Its versions are the other repositories' alone.
|
||||
// A package of another repository none of them publishes takes the commit the gate's source names for its repository
|
||||
// (heads, design 47 G A-365).
|
||||
// - **An accepted series** (DLV-I6): published and pins come from acceptedSeries, so a mesh Go module of another
|
||||
@@ -51,10 +52,11 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp
|
||||
case fp == "":
|
||||
return form{none: none}
|
||||
case kept.ImportForm == fp && prev.Fp2 != "":
|
||||
return form{fp: prev.Fp2, versions: prev.Packages} // the build that reported the imports stands
|
||||
// The build that reported the imports stands, and so do its versions.
|
||||
return form{fp: prev.Fp2, versions: refined(sdkstep.PackageVersions(prev.Packages), r.Versions, module, repository, kept, held, pins, heads)}
|
||||
}
|
||||
kept.ImportForm = fp
|
||||
return form{fp: fp, versions: r.Versions}
|
||||
return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins, heads)}
|
||||
}
|
||||
if logf != nil {
|
||||
logf("%s: no published package holds %s, so its fingerprint takes the version line", module, strings.Join(r.Missing, ", "))
|
||||
@@ -63,6 +65,34 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp
|
||||
// The fingerprint written here is the version line's, not the import form's: no import form is held for the inputs it was
|
||||
// computed from, so a later pass whose import form computes the same does not take this one for the build's (issue 1966).
|
||||
kept.ImportForm = ""
|
||||
versions := lineVersions(module, repository, kept, held, pins, heads, logf)
|
||||
in.Packages = fingerprint.VersionLine(repository, kept.Packages, versions, published)
|
||||
fp, none := fingerprint.Of(in)
|
||||
if fp == "" {
|
||||
return form{none: none}
|
||||
}
|
||||
return form{fp: fp, versions: versions}
|
||||
}
|
||||
|
||||
// refined are an import form's versions: the first of sets that names a package, else, while the module's go.mod
|
||||
// requires a mesh package of another repository (kept.Packages), the version line's, so a build's reported imports
|
||||
// refine the go.mod's set and never empty it (design 47 H-A-157); nil when nothing names one.
|
||||
func refined(versions, then sdkstep.PackageVersions, module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string) sdkstep.PackageVersions {
|
||||
switch {
|
||||
case len(versions) > 0:
|
||||
return versions
|
||||
case len(then) > 0:
|
||||
return then
|
||||
case len(fingerprint.OtherPackages(kept.Packages, repository)) > 0:
|
||||
return lineVersions(module, repository, kept, held, pins, heads, nil)
|
||||
}
|
||||
return versions
|
||||
}
|
||||
|
||||
// lineVersions are the version line's versions of the mesh Go modules of other repositories the module's go.mod requires
|
||||
// (kept.Packages): each as the indexer has always read it, an accepted series' pin over it, else the commit the gate's
|
||||
// source names for its repository.
|
||||
func lineVersions(module, repository string, kept *meshcatalog.ModulesByModuleValueInputs2, held map[string]meshcatalog.ModulesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string, logf func(string, ...any)) sdkstep.PackageVersions {
|
||||
others := fingerprint.OtherPackages(kept.Packages, repository)
|
||||
versions, unpublished := fingerprint.HeldVersionsOf(others, held)
|
||||
for p, v := range pins { // an accepted series' newest published version (acceptedSeries, DLV-I6)
|
||||
@@ -90,12 +120,7 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp
|
||||
if len(unpublished) > 0 && logf != nil {
|
||||
logf("%s: no module the indexer holds publishes %s, so its fingerprint takes no version of it", module, strings.Join(unpublished, ", "))
|
||||
}
|
||||
in.Packages = fingerprint.VersionLine(repository, kept.Packages, versions, published)
|
||||
fp, none := fingerprint.Of(in)
|
||||
if fp == "" {
|
||||
return form{none: none}
|
||||
}
|
||||
return form{fp: fp, versions: versions}
|
||||
return versions
|
||||
}
|
||||
|
||||
// inputsFrom is the fingerprint's inputs of module m from its kept inputs and the given toolchains, no package of
|
||||
|
||||
@@ -370,22 +370,36 @@ func anUnreadPackagesStateWritesNoFingerprintAndFingerprintsAreComputedAgain(t *
|
||||
head := strings.Repeat("c", 40)
|
||||
contracts := "git.novox.be/novox/mesh-contracts/go/seats/findings"
|
||||
held := map[string]meshcatalog.ModulesByModuleValue{"other": {Repository: "novox/mesh-sdk", Commit: strings.Repeat("d", 40), Path: "go"}}
|
||||
// A build's imports of its own repository alone (design 47 H-A-157): they refine the go.mod's set and never empty it.
|
||||
own := "git.novox.be/novox/mesh-catalog/modules/avahi/lib"
|
||||
published := map[string]meshcatalog.PackagesByModuleValue{own: {Module: own, Repository: "novox/mesh-catalog", Commit: head, Requires: "r1",
|
||||
Packages: []meshcatalog.PackagesByModuleValuePackagesItem{{Package: own, Digest: "d1"}}}}
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
heads map[string]string
|
||||
held map[string]meshcatalog.ModulesByModuleValue
|
||||
want string
|
||||
name string
|
||||
heads map[string]string
|
||||
held map[string]meshcatalog.ModulesByModuleValue
|
||||
imports []string
|
||||
want string
|
||||
}{
|
||||
{"the source names its repository", map[string]string{"novox/mesh-contracts": head}, held, head},
|
||||
{"the source names another repository only", map[string]string{"novox/mesh-sdk": head}, held, ""},
|
||||
{"the source names its repository", map[string]string{"novox/mesh-contracts": head}, held, nil, head},
|
||||
{"the source names another repository only", map[string]string{"novox/mesh-sdk": head}, held, nil, ""},
|
||||
{"a module the indexer holds publishes it", map[string]string{"novox/mesh-contracts": head},
|
||||
map[string]meshcatalog.ModulesByModuleValue{"c": {Repository: "novox/mesh-contracts", Commit: strings.Repeat("e", 40), Path: "go/seats/findings"}}, strings.Repeat("e", 40)},
|
||||
map[string]meshcatalog.ModulesByModuleValue{"c": {Repository: "novox/mesh-contracts", Commit: strings.Repeat("e", 40), Path: "go/seats/findings"}}, nil, strings.Repeat("e", 40)},
|
||||
{"a build's imports naming none of another repository keep the go.mod's", map[string]string{"novox/mesh-contracts": head}, held, []string{own}, head},
|
||||
} {
|
||||
kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Packages: []string{contracts}}
|
||||
f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, c.held, nil, nil, c.heads, nil)
|
||||
kept := meshcatalog.ModulesByModuleValueInputs2{Tree: "t", Packages: []string{contracts}, Imports: c.imports}
|
||||
f := formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{}, c.held, published, nil, c.heads, nil)
|
||||
if got := f.versions[contracts]; got != c.want {
|
||||
t.Errorf("%s: version of %s = %q, want %q", c.name, contracts, got, c.want)
|
||||
}
|
||||
if c.imports == nil {
|
||||
continue
|
||||
}
|
||||
// The build that reported them stands, its held versions empty (a version line read from go.sum).
|
||||
f = formOf("avahi", "novox/mesh-catalog", &kept, nil, meshcatalog.ModulesByModuleValue{Fp2: "src2:" + strings.Repeat("b", 64)}, c.held, published, nil, c.heads, nil)
|
||||
if got := f.versions[contracts]; got != c.want || f.fp != "src2:"+strings.Repeat("b", 64) {
|
||||
t.Errorf("%s, the build standing: version of %s = %q (fp %q), want %q", c.name, contracts, got, f.fp, c.want)
|
||||
}
|
||||
}
|
||||
})
|
||||
t.Run("formOf clears the import form when it writes the version line", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user