Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable CheckoutFromArchive test. #3554

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const UpdateChannelEnvVarName = "ACTIVESTATE_CLI_UPDATE_CHANNEL"
// InstallBuildDependenciesEnvVarName is the env var that is used to override whether to install build dependencies
const InstallBuildDependenciesEnvVarName = "ACTIVESTATE_CLI_INSTALL_BUILD_DEPENDENCIES"

// InstallInternalDependenciesEnvVarName is the env var that is used to override whether to install internal dependencies.
// This is only used for test cases.
const InstallInternalDependenciesEnvVarName = "ACTIVESTATE_CLI_INSTALL_INTERNAL_DEPENDENCIES"

// InternalConfigFileNameLegacy is effectively the same as InternalConfigName, but includes our preferred extension
const InternalConfigFileNameLegacy = "config.yaml"

Expand Down
11 changes: 8 additions & 3 deletions pkg/buildplan/filters.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package buildplan

import (
"os"
"strings"

"github.com/ActiveState/cli/internal/constants"
"github.com/ActiveState/cli/internal/sliceutils"
"github.com/ActiveState/cli/pkg/buildplan/raw"
"github.com/ActiveState/cli/pkg/platform/api/buildplanner/types"
Expand Down Expand Up @@ -44,9 +46,12 @@ const NamespaceInternal = "internal"

func FilterStateArtifacts() FilterArtifact {
return func(a *Artifact) bool {
internalIngredients := sliceutils.Filter(a.Ingredients, func(i *Ingredient) bool {
return i.Namespace == NamespaceInternal
})
internalIngredients := []*Ingredient{}
if os.Getenv(constants.InstallInternalDependenciesEnvVarName) != "true" {
internalIngredients = sliceutils.Filter(a.Ingredients, func(i *Ingredient) bool {
return i.Namespace == NamespaceInternal
})
}
Comment on lines +49 to +54
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The checkout archive installs a shared/zlib package, which would be excluded by default. In order to keep things small and simple, add an env var override to avoid excluding internal packages.

if len(a.Ingredients) > 0 && len(a.Ingredients) == len(internalIngredients) {
return false
}
Expand Down
19 changes: 14 additions & 5 deletions test/integration/checkout_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
"testing"

"github.com/mholt/archiver/v3"

"github.com/ActiveState/cli/internal/constants"
"github.com/ActiveState/cli/internal/environment"
"github.com/ActiveState/cli/internal/fileutils"
Expand Down Expand Up @@ -365,21 +367,28 @@ func (suite *CheckoutIntegrationTestSuite) TestCveReport() {
}

func (suite *CheckoutIntegrationTestSuite) TestCheckoutFromArchive() {
suite.T().Skip("Skipping until https://activestatef.atlassian.net/browse/DX-3057 is fixed")
suite.OnlyRunForTags(tagsuite.Checkout)
ts := e2e.New(suite.T(), false)
defer ts.Close()

root := environment.GetRootPathUnsafe()
archive := filepath.Join(root, "test", "integration", "testdata", "checkout-from-archive", runtime.GOOS+".tar.gz")
dir := filepath.Join(root, "test", "integration", "testdata", "checkout-from-archive", runtime.GOOS)
tgz := fileutils.TempFilePath("", runtime.GOOS+".tar.gz")
files, err := fileutils.ListDirSimple(dir, false)
suite.Require().NoError(err)
gz := archiver.TarGz{Tar: &archiver.Tar{StripComponents: 1000}} // use a big number to strip all leading dirs
suite.Require().NoError(gz.Archive(files, tgz))
defer os.Remove(tgz)

cp := ts.SpawnWithOpts(
e2e.OptArgs("checkout", archive),
e2e.OptAppendEnv("HTTPS_PROXY=none://"), // simulate lack of network connection
e2e.OptArgs("checkout", tgz),
e2e.OptAppendEnv(
"HTTPS_PROXY=none://", // simulate lack of network connection
constants.InstallInternalDependenciesEnvVarName+"=true",
),
)
cp.Expect("Checking out project: ActiveState-CLI/AlmostEmpty")
cp.Expect("Setting up the following dependencies:")
cp.Expect("└─ [email protected]")
cp.Expect("Sourcing Runtime")
cp.Expect("Unpacking")
cp.Expect("Installing")
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"let": {
"in": "$runtime",
"runtime": {
"state_tool_artifacts_v1": {
"build_flags": [],
"src": "$sources"
}
},
"sources": {
"solve": {
"at_time": "$at_time",
"platforms": [
"46a5b48f-226a-4696-9746-ba4d50d661c2",
"78977bc8-0f32-519d-80f3-9043f059398c",
"7c998ec2-7491-4e75-be4d-8885800ef5f2"
],
"requirements": [
{
"name": "alternative-build-selector",
"namespace": "internal"
},
{
"name": "mingw-build-selector",
"namespace": "internal"
},
{
"name": "zlib",
"namespace": "shared"
}
],
"solver_version": null
}
}
}
}
Loading
Loading