Skip to content

Commit

Permalink
Merge branch version/0-47-0-RC1 to adopt changes from PR #3481
Browse files Browse the repository at this point in the history
  • Loading branch information
as-builds committed Sep 20, 2024
2 parents d55fb20 + 4794f41 commit 97e4b18
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pkg/buildplan/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (a *Artifact) dependencies(recursive bool, maybeIgnore *map[strfmt.UUID]str
for _, ac := range a.children {
related := len(relations) == 0
for _, relation := range relations {
if ac.Relation == relation {
if ac.Relation == relation && raw.IsStateToolMimeType(ac.Artifact.MimeType) {
related = true
}
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/buildplan/hydrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ func (b *BuildPlan) hydrateWithIngredients(artifact *Artifact, platformID *strfm
default:
return errs.New("unexpected node type '%T': %#v", v, v)
}

return nil
})
if err != nil {
return errs.Wrap(err, "error hydrating ingredients")
Expand Down
3 changes: 3 additions & 0 deletions pkg/buildplan/ingredient.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ func (i *Ingredient) runtimeDependencies(recursive bool, seen map[strfmt.UUID]st

dependencies := Ingredients{}
for _, a := range i.Artifacts {
if !raw.IsStateToolMimeType(a.MimeType) {
continue
}
for _, ac := range a.children {
if ac.Relation != RuntimeRelation {
continue
Expand Down
50 changes: 29 additions & 21 deletions pkg/buildplan/mock_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package buildplan

import "github.com/ActiveState/cli/pkg/buildplan/raw"
import (
"github.com/ActiveState/cli/pkg/buildplan/raw"
"github.com/ActiveState/cli/pkg/platform/api/buildplanner/types"
)

// createMockArtifactWithCycles creates a mock artifact with a cycle.
// Unfortunately go doesn't support circular variable initialization, so we have to do it manually.
Expand All @@ -9,14 +12,15 @@ import "github.com/ActiveState/cli/pkg/buildplan/raw"
//
// The artifact cycle is:
// 00000000-0000-0000-0000-000000000001
//
// -> 00000000-0000-0000-0000-000000000002
// -> 00000000-0000-0000-0000-000000000003
// -> 00000000-0000-0000-0000-000000000001 (Cycle back to the first artifact)
func createMockArtifactWithCycles() *Artifact {
// Create the artifacts with placeholders
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001"}
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002"}
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003"}
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001", MimeType: types.XArtifactMimeType}
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002", MimeType: types.XArtifactMimeType}
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003", MimeType: types.XArtifactMimeType}

// Create the deepest ingredients and artifacts first
artifact0003.children = []ArtifactRelation{
Expand Down Expand Up @@ -46,13 +50,14 @@ func createMockArtifactWithCycles() *Artifact {
// createMockArtifactWithRuntimeDeps creates a mock artifact with runtime dependencies.
// The dependencies are:
// 00000000-0000-0000-0000-000000000001
//
// -> 00000000-0000-0000-0000-000000000002 (child)
// -> 00000000-0000-0000-0000-000000000003 (child)
func createMockArtifactWithRuntimeDeps() *Artifact {
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001"}
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002"}
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003"}
artifact0004 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000004"}
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001", MimeType: types.XArtifactMimeType}
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002", MimeType: types.XArtifactMimeType}
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003", MimeType: types.XArtifactMimeType}
artifact0004 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000004", MimeType: types.XArtifactMimeType}

artifact0001.children = []ArtifactRelation{
{
Expand Down Expand Up @@ -81,12 +86,13 @@ func createMockArtifactWithRuntimeDeps() *Artifact {
// createMockArtifactWithBuildTimeDeps creates a mock artifact with build time dependencies.
// The dependencies are:
// 00000000-0000-0000-0000-000000000001
//
// -> 00000000-0000-0000-0000-000000000002 (child)
// -> 00000000-0000-0000-0000-000000000003 (child)
func createMockArtifactWithBuildTimeDeps() *Artifact {
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001"}
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002"}
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003"}
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001", MimeType: types.XArtifactMimeType}
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002", MimeType: types.XArtifactMimeType}
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003", MimeType: types.XArtifactMimeType}

artifact0001.children = []ArtifactRelation{
{
Expand All @@ -108,17 +114,18 @@ func createMockArtifactWithBuildTimeDeps() *Artifact {
// createIngredientWithRuntimeDeps creates a mock ingredient with runtime dependencies.
// The dependencies are:
// 00000000-0000-0000-0000-000000000010 (Ingredient0010)
//
// -> 00000000-0000-0000-0000-000000000001 (Artifact0001)
// -> 00000000-0000-0000-0000-000000000002 (Artifact child of Artifact0001)
// -> 00000000-0000-0000-0000-000000000020 (Ingredient0020)
// -> 00000000-0000-0000-0000-000000000003 (Artifact0003)
// -> 00000000-0000-0000-0000-000000000004 (Artifact child of Artifact0003)
// -> 00000000-0000-0000-0000-000000000030 (Ingredient0030)
func createIngredientWithRuntimeDeps() *Ingredient {
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001"}
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002"}
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003"}
artifact0004 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000004"}
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001", MimeType: types.XArtifactMimeType}
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002", MimeType: types.XArtifactMimeType}
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003", MimeType: types.XArtifactMimeType}
artifact0004 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000004", MimeType: types.XArtifactMimeType}

ingredient0010 := &Ingredient{
IngredientSource: &raw.IngredientSource{
Expand Down Expand Up @@ -181,6 +188,7 @@ func createIngredientWithRuntimeDeps() *Ingredient {
//
// The ingredient cycle is:
// 00000000-0000-0000-0000-000000000010 (Ingredient0010)
//
// -> 00000000-0000-0000-0000-000000000001 (Artifact0001)
// -> 00000000-0000-0000-0000-000000000002 (Child of Artifact0001)
// -> 00000000-0000-0000-0000-000000000020 (Ingredient0020)
Expand All @@ -191,12 +199,12 @@ func createIngredientWithRuntimeDeps() *Ingredient {
// -> 00000000-0000-0000-0000-000000000006 (Child of Artifact0005)
// -> 00000000-0000-0000-0000-000000000010 (Ingredient0010 cycle back to the first ingredient)
func createMockIngredientWithCycles() *Ingredient {
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001"}
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002"}
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003"}
artifact0004 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000004"}
artifact0005 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000005"}
artifact0006 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000006"}
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001", MimeType: types.XArtifactMimeType}
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002", MimeType: types.XArtifactMimeType}
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003", MimeType: types.XArtifactMimeType}
artifact0004 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000004", MimeType: types.XArtifactMimeType}
artifact0005 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000005", MimeType: types.XArtifactMimeType}
artifact0006 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000006", MimeType: types.XArtifactMimeType}

ingredient0010 := &Ingredient{
IngredientSource: &raw.IngredientSource{
Expand Down

0 comments on commit 97e4b18

Please sign in to comment.