Skip to content

Commit

Permalink
Add back environment variable and ability to install build time closure
Browse files Browse the repository at this point in the history
  • Loading branch information
MDrakos committed Oct 5, 2023
1 parent d8c2030 commit a2ad4b9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
3 changes: 3 additions & 0 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
22 changes: 17 additions & 5 deletions pkg/platform/runtime/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,6 @@ func (s *Setup) fetchAndInstallArtifactsFromBuildPlan(installFunc artifactInstal
var runtimeAndBuildtimeArtifacts artifact.Map
var runtimeArtifacts artifact.Map // Artifacts required for the runtime to function

runtimeArtifacts, err = buildplan.NewMapFromBuildPlan(buildResult.Build)
if err != nil {
return nil, nil, errs.Wrap(err, "Failed to create artifact map from build plan")
}

// If the build is not ready, we need to get the runtime and buildtime closure
if !buildResult.BuildReady {
runtimeAndBuildtimeArtifacts, err = buildplan.NewBuildtimeMap(buildResult.Build)
Expand All @@ -398,6 +393,23 @@ func (s *Setup) fetchAndInstallArtifactsFromBuildPlan(installFunc artifactInstal
}
}

// If we are installing build dependencies, then buildtime dependencies are also runtime dependencies
if strings.EqualFold(os.Getenv(constants.InstallBuildDependencies), "true") {
logging.Debug("Installing build dependencies")
if runtimeAndBuildtimeArtifacts == nil {
runtimeAndBuildtimeArtifacts, err = buildplan.NewBuildtimeMap(buildResult.Build)
if err != nil {
return nil, nil, errs.Wrap(err, "Failed to create artifact map from build plan")
}
}
runtimeArtifacts = runtimeAndBuildtimeArtifacts
} else {
runtimeArtifacts, err = buildplan.NewMapFromBuildPlan(buildResult.Build)
if err != nil {
return nil, nil, errs.Wrap(err, "Failed to create artifact map from build plan")
}
}

var setup Setuper
if !buildResult.BuildReady {
setup, err = s.selectSetupImplementation(buildResult.BuildEngine, runtimeAndBuildtimeArtifacts)
Expand Down
20 changes: 20 additions & 0 deletions test/integration/checkout_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,26 @@ func (suite *CheckoutIntegrationTestSuite) TestCheckoutCaseInsensitive() {
suite.Assert().NotContains(string(bytes), "ACTIVESTATE-CLI/SMALL-PYTHON", "kept incorrect namespace case")
}

func (suite *CheckoutIntegrationTestSuite) TestCheckoutBuildtimeClosure() {
suite.OnlyRunForTags(tagsuite.Checkout)

if runtime.GOOS != "linux" {
suite.T().Skip("Skipping buildtime closure test on non-linux platform")
}

ts := e2e.New(suite.T(), false)
defer ts.Close()

cp := ts.SpawnWithOpts(
e2e.OptArgs("checkout", "ActiveState-CLI/small-python"),
e2e.OptAppendEnv(constants.InstallBuildDependencies+"=true"),
e2e.OptAppendEnv(constants.DisableRuntime+"=false"),
)
// Expect the number of build deps to be 27 which is more than the number of runtime deps.
cp.Expect("libxcrypt")
cp.ExpectExitCode(0)
}

func TestCheckoutIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(CheckoutIntegrationTestSuite))
}

0 comments on commit a2ad4b9

Please sign in to comment.