Publish domain artifacts without reporting sidecars
This commit is contained in:
@@ -24,13 +24,13 @@ func (output testEvidenceOutput) EvidenceContextPolicy() EvidenceContextPolicy {
|
||||
}
|
||||
|
||||
func TestEvidencePolicyResolutionAndPreparationSurviveLaneFiltering(t *testing.T) {
|
||||
registries, _ := constructionRegistries(t, nil, nil)
|
||||
registries := registriesFromModuleCatalog(typedResolutionCatalog(t, completeTypedCatalogOptions()))
|
||||
registries.ArtifactEvidence = NewArtifactEvidenceRegistry()
|
||||
policy := EvidenceContextPolicy{Enabled: true, WindowUnits: 2, LaneIDs: []string{"artifact", "inactive"}}
|
||||
policy := EvidenceContextPolicy{Enabled: true, WindowUnits: 2, LaneIDs: []string{"notes", "inactive"}}
|
||||
profileValidated := false
|
||||
registerTestEvidenceOutputWithProfileValidation(t, ®istries, policy, func(context OutputProfileOptionContext, _ map[string]any) error {
|
||||
profileValidated = true
|
||||
if want := []string{"artifact", "inactive"}; !reflect.DeepEqual(context.LaneIDs, want) {
|
||||
if want := []string{"inactive", "notes"}; !reflect.DeepEqual(context.LaneIDs, want) {
|
||||
return fmt.Errorf("configured lane ids = %#v, want %#v", context.LaneIDs, want)
|
||||
}
|
||||
return nil
|
||||
@@ -38,31 +38,33 @@ func TestEvidencePolicyResolutionAndPreparationSurviveLaneFiltering(t *testing.T
|
||||
if err := RegisterArtifactEvidence(registries.ArtifactEvidence, "test/notes", func(codecNotes) []source.SourceRef { return nil }); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
profile := constructionProfile()
|
||||
profile.Artifacts["inactive"] = profile.Artifacts["artifact"]
|
||||
profile := typedResolutionProfile()
|
||||
delete(profile.Artifacts, "score")
|
||||
profile.Output = Binding("output")
|
||||
profile.Artifacts["inactive"] = profile.Artifacts["notes"]
|
||||
profile.Output.Options = map[string]any{"known": true}
|
||||
resolved, err := ResolvePipeline(profile, ResolveOptions{Only: []string{"artifact"}}, registries.catalog())
|
||||
resolved, err := ResolvePipeline(profile, ResolveOptions{Only: []string{"notes"}}, registries.catalog())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !profileValidated {
|
||||
t.Fatal("output profile options were not validated")
|
||||
}
|
||||
if lanes := resolved.AllArtifactLanes(); len(lanes) != 1 || lanes[0].ID != "artifact" {
|
||||
if lanes := resolved.AllArtifactLanes(); len(lanes) != 1 || lanes[0].ID != "notes" {
|
||||
t.Fatalf("resolved lanes = %#v, want only the invocation-selected lane", lanes)
|
||||
}
|
||||
prepared, err := Prepare(resolved, registries, ModuleDependencies{})
|
||||
if err != nil {
|
||||
t.Fatalf("Prepare() error = %v, want nil", err)
|
||||
}
|
||||
if prepared.evidencePlan == nil || !reflect.DeepEqual(prepared.evidencePlan.policy.LaneIDs, []string{"artifact", "inactive"}) {
|
||||
if prepared.evidencePlan == nil || !reflect.DeepEqual(prepared.evidencePlan.policy.LaneIDs, []string{"inactive", "notes"}) {
|
||||
t.Fatalf("evidence plan = %#v, want complete configured policy", prepared.evidencePlan)
|
||||
}
|
||||
if got := prepared.evidencePlan.lanes; len(got) != 1 || got[0].laneID != "artifact" {
|
||||
if got := prepared.evidencePlan.lanes; len(got) != 1 || got[0].laneID != "notes" {
|
||||
t.Fatalf("active evidence lanes = %#v, want artifact only", got)
|
||||
}
|
||||
prepared.evidencePlan.policy.LaneIDs[0] = "mutated"
|
||||
if policy := prepared.output.(EvidenceContextPolicyProvider).EvidenceContextPolicy(); policy.LaneIDs[0] != "artifact" {
|
||||
if policy := prepared.output.(EvidenceContextPolicyProvider).EvidenceContextPolicy(); policy.LaneIDs[0] != "notes" {
|
||||
t.Fatalf("prepared plan mutated provider policy: %#v", policy)
|
||||
}
|
||||
}
|
||||
@@ -82,11 +84,13 @@ func TestPrepareEvidencePlanRejectsMissingAndMismatchedCapabilities(t *testing.T
|
||||
}, want: "requires Go type"},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
registries, _ := constructionRegistries(t, nil, nil)
|
||||
registries := registriesFromModuleCatalog(typedResolutionCatalog(t, completeTypedCatalogOptions()))
|
||||
registries.ArtifactEvidence = NewArtifactEvidenceRegistry()
|
||||
registerTestEvidenceOutput(t, ®istries, EvidenceContextPolicy{Enabled: true, LaneIDs: []string{"artifact"}})
|
||||
registerTestEvidenceOutput(t, ®istries, EvidenceContextPolicy{Enabled: true, LaneIDs: []string{"notes"}})
|
||||
test.configure(®istries)
|
||||
profile := constructionProfile()
|
||||
profile := typedResolutionProfile()
|
||||
delete(profile.Artifacts, "score")
|
||||
profile.Output = Binding("output")
|
||||
profile.Output.Options = map[string]any{"known": true}
|
||||
resolved, err := ResolvePipeline(profile, ResolveOptions{}, registries.catalog())
|
||||
if err != nil {
|
||||
@@ -108,7 +112,7 @@ func registerTestEvidenceOutput(t *testing.T, registries *Registries, policy Evi
|
||||
func registerTestEvidenceOutputWithProfileValidation(t *testing.T, registries *Registries, policy EvidenceContextPolicy, validateProfile OutputProfileOptionValidator) {
|
||||
t.Helper()
|
||||
registry := NewOutputEncoderRegistry()
|
||||
if err := registry.RegisterBuilderWithProfileValidation(testModuleSpec("output", StageOutput), func(options map[string]any) error {
|
||||
if err := registry.RegisterBuilderWithProfileValidation(ModuleSpec{Key: "output", Stage: StageOutput, ExecutionClass: contracts.ExecutionClassDeterministic}, func(options map[string]any) error {
|
||||
return RejectUnknownOptions(options, "known")
|
||||
}, validateProfile, func(BuildRequest) (contracts.OutputEncoder, error) {
|
||||
return testEvidenceOutput{policy: cloneEvidenceContextPolicy(policy)}, nil
|
||||
|
||||
Reference in New Issue
Block a user