diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 335c57082e..81118222fa 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -62,6 +62,9 @@ const DisableUpdates = "ACTIVESTATE_CLI_DISABLE_UPDATES" // UpdateBranchEnvVarName is the env var that is used to override which branch to pull the update from const UpdateBranchEnvVarName = "ACTIVESTATE_CLI_UPDATE_BRANCH" +// InstallBuildDependencies is the env var that is used to override whether to install build dependencies +const InstallBuildDependencies = "ACTIVESTATE_CLI_INSTALL_BUILD_DEPENDENCIES" + // InternalConfigFileNameLegacy is effectively the same as InternalConfigName, but includes our preferred extension const InternalConfigFileNameLegacy = "config.yaml" diff --git a/pkg/platform/api/buildplanner/model/buildplan.go b/pkg/platform/api/buildplanner/model/buildplan.go index ef65076a09..ec26a5b6ac 100644 --- a/pkg/platform/api/buildplanner/model/buildplan.go +++ b/pkg/platform/api/buildplanner/model/buildplan.go @@ -36,7 +36,7 @@ const ( // Tag types TagSource = "src" - TagDependency = "dep" + TagDependency = "deps" TagBuilder = "builder" TagOrphan = "orphans" diff --git a/pkg/platform/model/buildplanner.go b/pkg/platform/model/buildplanner.go index 28f0a1adb9..a3673080de 100644 --- a/pkg/platform/model/buildplanner.go +++ b/pkg/platform/model/buildplanner.go @@ -156,10 +156,9 @@ func (bp *BuildPlanner) FetchBuildResult(commitID strfmt.UUID, owner, project st } res := BuildResult{ - BuildEngine: buildEngine, - Build: build, - // BuildReady: build.Status == bpModel.Completed, - BuildReady: false, + BuildEngine: buildEngine, + Build: build, + BuildReady: build.Status == bpModel.Completed, CommitID: id, BuildExpression: expr, BuildStatus: build.Status, diff --git a/pkg/platform/runtime/buildplan/buildplan.go b/pkg/platform/runtime/buildplan/buildplan.go index fce2d8c230..9df2090003 100644 --- a/pkg/platform/runtime/buildplan/buildplan.go +++ b/pkg/platform/runtime/buildplan/buildplan.go @@ -339,10 +339,8 @@ func buildBuildClosureMap(baseID strfmt.UUID, lookup map[strfmt.UUID]interface{} return errs.New("Incorrect target type for id %s, expected Artifact", baseID) } - _, ok = result[strfmt.UUID(currentArtifact.NodeID)] - // We are only interested in artifacts that have not already been added - // to the result and that have been submitted to be built. - if ok || currentArtifact.Status == model.ArtifactNotSubmitted { + if currentArtifact.MimeType == model.XActiveStateBuilderMimeType { + // Dependency is a builder, skipping return nil } @@ -365,13 +363,6 @@ func buildBuildClosureMap(baseID strfmt.UUID, lookup map[strfmt.UUID]interface{} for a := range recursiveDeps { deps[a] = struct{}{} } - - // For each runtime dependency we need to add its dependencies - // to the result map. - err = buildBuildClosureMap(depID, lookup, result) - if err != nil { - return errs.Wrap(err, "Could not build map for runtime dependency %s", currentArtifact.NodeID) - } } // We need to convert the map of dependencies to a list of @@ -379,6 +370,13 @@ func buildBuildClosureMap(baseID strfmt.UUID, lookup map[strfmt.UUID]interface{} var uniqueDeps []strfmt.UUID for depID := range deps { uniqueDeps = append(uniqueDeps, depID) + + // For each buildtime dependency we need to add it and its dependencies + // to the result map. + err := buildBuildClosureMap(depID, lookup, result) + if err != nil { + return errs.Wrap(err, "Could not build map for runtime dependency %s", currentArtifact.NodeID) + } } // We need to get the source information for the artifact. @@ -419,18 +417,17 @@ func generateBuildtimeDependencies(artifactID strfmt.UUID, lookup map[strfmt.UUI return nil, errs.New("Incorrect target type for id %s, expected Artifact or Source", artifactID) } + result[artifactID] = struct{}{} + if artifact.MimeType == model.XActiveStateBuilderMimeType { // Dependency is a builder, skipping return nil, nil } - // Once we have verified that the artifact has a step that generated it - // we add it to the result map. - result[artifactID] = struct{}{} - // We iterate through the direct dependencies of the artifact // and recursively add all of the dependencies of those artifacts map. for _, depID := range artifact.RuntimeDependencies { + result[artifactID] = struct{}{} _, err := generateBuildtimeDependencies(depID, lookup, result) if err != nil { return nil, errs.Wrap(err, "Could not build map for runtime dependencies of artifact %s", artifact.NodeID) @@ -455,7 +452,7 @@ func generateBuildtimeDependencies(artifactID strfmt.UUID, lookup map[strfmt.UUI // artifact and recursively add all of the dependencies and builders // of those artifacts. for _, input := range step.Inputs { - if input.Tag != model.TagDependency || input.Tag != model.TagBuilder { + if input.Tag != model.TagDependency && input.Tag != model.TagBuilder { continue } diff --git a/pkg/platform/runtime/setup/setup.go b/pkg/platform/runtime/setup/setup.go index 0d5ebcd7aa..7f96bf7901 100644 --- a/pkg/platform/runtime/setup/setup.go +++ b/pkg/platform/runtime/setup/setup.go @@ -382,16 +382,21 @@ func (s *Setup) fetchAndInstallArtifactsFromBuildPlan(installFunc artifactInstal // Compute and handle the change summary // runtimeAndBuildtimeArtifacts records all artifacts that will need to be built in order to obtain the runtime. - // Disabled due to DX-2033. - // Please use this var when we come back to this in the future as we need to make a clear distinction between this - // and runtime-only artifacts. - // var runtimeAndBuildtimeArtifacts artifact.Map + var runtimeAndBuildtimeArtifacts artifact.Map var runtimeArtifacts artifact.Map // Artifacts required for the runtime to function if buildResult.Build != nil { runtimeArtifacts, err = buildplan.NewMapFromBuildPlan(buildResult.Build) if err != nil { return nil, nil, errs.Wrap(err, "Failed to create artifact map from build plan") } + + if strings.EqualFold(os.Getenv(constants.InstallBuildDependencies), "true") { + runtimeAndBuildtimeArtifacts, err = buildplan.BuildtimeArtifacts(buildResult.Build) + if err != nil { + return nil, nil, errs.Wrap(err, "Failed to create artifact map from build plan") + } + runtimeArtifacts = runtimeAndBuildtimeArtifacts + } } setup, err := s.selectSetupImplementation(buildResult.BuildEngine, runtimeArtifacts) @@ -506,6 +511,14 @@ func (s *Setup) fetchAndInstallArtifactsFromBuildPlan(installFunc artifactInstal return nil, nil, errs.Wrap(err, "Could not get buildtime artifacts") } + buildtimeArtifactIDs := []artifact.ArtifactID{} + for _, a := range buildtimeArtifacts { + buildtimeArtifactIDs = append(buildtimeArtifactIDs, a.ArtifactID) + } + + // Update artifactNames to ensure it now includes buildtime artifacts + artifactNames = artifact.ResolveArtifactNames(setup.ResolveArtifactName, buildtimeArtifactIDs) + buildList := []string{} for _, a := range buildtimeArtifacts { buildList = append(buildList, artifactNames[a.ArtifactID])