mesh-delivery-indexer: pins are in every form's fingerprint
The import form's fingerprint left the pins out, so an importer whose trunk build reported its imports never moved on a re-pin and was never built again against the release. Every form now takes its sorted pins; a build that stands keeps its fingerprint while its pins are the ones it was built with, and a fingerprint with no pin stays as it was. Builds: design 47 H H-A-172, H-A-167
This commit is contained in:
@@ -17,7 +17,11 @@ import (
|
|||||||
type form struct {
|
type form struct {
|
||||||
fp, none string
|
fp, none string
|
||||||
versions sdkstep.PackageVersions
|
versions sdkstep.PackageVersions
|
||||||
line bool // the version line's, whose fingerprint takes the pins too (pinnedOf, H-A-167)
|
// stands: fp is the held fingerprint of the build that reported the imports, made with the pins built (its held
|
||||||
|
// packages) from the import form raw; pinnedOf keeps it while the pins are those (H-A-172).
|
||||||
|
stands bool
|
||||||
|
raw string
|
||||||
|
built map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
// formOf is the module's fingerprint from its kept inputs (bases already its bases' fingerprints) and toolchains, in the
|
// formOf is the module's fingerprint from its kept inputs (bases already its bases' fingerprints) and toolchains, in the
|
||||||
@@ -54,7 +58,8 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp
|
|||||||
return form{none: none}
|
return form{none: none}
|
||||||
case kept.ImportForm == fp && prev.Fp2 != "":
|
case kept.ImportForm == fp && prev.Fp2 != "":
|
||||||
// The build that reported the imports stands, and so do its versions.
|
// 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)}
|
return form{fp: prev.Fp2, versions: refined(sdkstep.PackageVersions(prev.Packages), r.Versions, module, repository, kept, held, pins, heads),
|
||||||
|
stands: true, raw: fp, built: prev.Packages}
|
||||||
}
|
}
|
||||||
kept.ImportForm = fp
|
kept.ImportForm = fp
|
||||||
return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins, heads)}
|
return form{fp: fp, versions: refined(r.Versions, nil, module, repository, kept, held, pins, heads)}
|
||||||
@@ -72,7 +77,7 @@ func formOf(module, repository string, kept *meshcatalog.ModulesByModuleValueInp
|
|||||||
if fp == "" {
|
if fp == "" {
|
||||||
return form{none: none}
|
return form{none: none}
|
||||||
}
|
}
|
||||||
return form{fp: fp, versions: versions, line: true}
|
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
|
// refined are an import form's versions: the first of sets that names a package, else, while the module's go.mod
|
||||||
|
|||||||
@@ -122,6 +122,23 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T
|
|||||||
t.Fatalf("a change of an imported package: fp2 %q (was %q), import form %q, versions %v; want the import form, mesh-sdk kept unpinned (none released, H-A-161)",
|
t.Fatalf("a change of an imported package: fp2 %q (was %q), import form %q, versions %v; want the import form, mesh-sdk kept unpinned (none released, H-A-161)",
|
||||||
moved.Fp2, before.Fp2, moved.Inputs2.ImportForm, moved.Packages)
|
moved.Fp2, before.Fp2, moved.Inputs2.ImportForm, moved.Packages)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mesh-sdk releases 0.1.20: the import form's fingerprint takes the pin too and moves, once (H-A-172).
|
||||||
|
ix.Versions = newMem()
|
||||||
|
ix.Versions.(*memStore).put(meshcatalog.VersionsByModuleVersionKey("mesh-sdk", "0.1.20"), []byte(`{}`))
|
||||||
|
for range 2 {
|
||||||
|
if err := ix.Recompute(ctx); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 == moved.Fp2 || m.Fp2 == "" || m.Packages[meshSDK] != "v0.1.20" || m.Inputs2.ImportForm != moved.Inputs2.ImportForm {
|
||||||
|
t.Fatalf("after mesh-sdk's release: fp2 %q (was %q), versions %v, import form %q; want a new fingerprint pinned to v0.1.20, the import form kept",
|
||||||
|
m.Fp2, moved.Fp2, m.Packages, m.Inputs2.ImportForm)
|
||||||
|
} else if err := ix.Recompute(ctx); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if again, _ := moduleOf(t, mods, "avahi"); again.Fp2 != m.Fp2 {
|
||||||
|
t.Fatalf("a pass with nothing moved moved the pinned fingerprint %q to %q", m.Fp2, again.Fp2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A build of a fingerprint the module no longer holds says nothing of its inputs now: its imports are not kept.
|
// A build of a fingerprint the module no longer holds says nothing of its inputs now: its imports are not kept.
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -415,14 +416,18 @@ func releasedPins(versions sdkstep.PackageVersions, held map[string]meshcatalog.
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
// pinnedOf is a form's fingerprint and its pins (releasedPins): the pins are part of what a build is made of, so the
|
// pinnedOf is a form's fingerprint and its pins (releasedPins): the pins are part of what a build is made of, so every
|
||||||
// version line's fingerprint takes them (design 47 H-A-167, ADR 0573 §4) and a re-pin moves it, the module a mover
|
// form's fingerprint takes them (design 47 H-A-167, H-A-172; ADR 0573 §4) and a re-pin moves it, the module a mover
|
||||||
// built again against the release; a fingerprint with no pin is the form's as it is.
|
// built again against the release; a fingerprint with no pin is the form's as it is. The held fingerprint of a build that
|
||||||
|
// stands is kept while its pins are the ones it was built with, else its import form takes the new pins.
|
||||||
func pinnedOf(f form, held map[string]meshcatalog.ModulesByModuleValue, released map[string]string) (string, sdkstep.PackageVersions) {
|
func pinnedOf(f form, held map[string]meshcatalog.ModulesByModuleValue, released map[string]string) (string, sdkstep.PackageVersions) {
|
||||||
pins := releasedPins(f.versions, held, released)
|
pins := releasedPins(f.versions, held, released)
|
||||||
if !f.line {
|
if f.stands {
|
||||||
|
if maps.Equal(f.built, map[string]string(pins)) {
|
||||||
return f.fp, pins
|
return f.fp, pins
|
||||||
}
|
}
|
||||||
|
return fingerprint.WithPins(f.raw, pins), pins
|
||||||
|
}
|
||||||
return fingerprint.WithPins(f.fp, pins), pins
|
return fingerprint.WithPins(f.fp, pins), pins
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user