diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 21aadfa77..5d4b71768 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -100,8 +100,10 @@ Some options users can provide to our acceptance tests are: | ACCEPTANCE_SUITE_CONFIG | A set of configurations for how to run the acceptance tests, describing the version of `pack` used for testing, the version of `pack` used to create the builders used in the test, and the version of `lifecycle` binaries used to test with Github | `[{"pack": "current", "pack_create_builder": "current", "lifecycle": "default"}]'` | | COMPILE_PACK_WITH_VERSION | Tell `pack` what version to consider itself | `dev` | | GITHUB_TOKEN | A Github Token, used when downloading `pack` and `lifecycle` releases from Github during the test setup | "" | -| PACK_PATH | Path to a `pack` executable. | A compiled version of the current branch | -| PREVIOUS_PACK_PATH | Path to a `pack` executable, used to test compatibility with n-1 version of `pack` | The most recent release from `pack`'s Github release | -| PREVIOUS_PACK_FIXTURES_PATH | Path to a set of fixtures, used to override the most up-to-date fixtures, in case of changed functionality | `acceptance/testdata/pack_previous_fixtures_overrides` | +| LIFECYCLE_IMAGE | Image reference to be used in untrusted builder workflows | buildpacksio/lifecycle: | | LIFECYCLE_PATH | Path to a `.tgz` file filled with a set of `lifecycle` binaries | The Github release for the default version of lifecycle in `pack` | +| PACK_PATH | Path to a `pack` executable. | A compiled version of the current branch | +| PREVIOUS_LIFECYCLE_IMAGE | Image reference to be used in untrusted builder workflows, used to test compatibility of `pack` with the n-1 version of the `lifecycle` | buildpacksio/lifecycle:, buildpacksio/lifecycle: | | PREVIOUS_LIFECYCLE_PATH | Path to a `.tgz` file filled with a set of `lifecycle` binaries, used to test compatibility of `pack` with the n-1 version of the `lifecycle` | The Github release for n-1 release of `lifecycle` | +| PREVIOUS_PACK_FIXTURES_PATH | Path to a set of fixtures, used to override the most up-to-date fixtures, in case of changed functionality | `acceptance/testdata/pack_previous_fixtures_overrides` | +| PREVIOUS_PACK_PATH | Path to a `pack` executable, used to test compatibility with n-1 version of `pack` | The most recent release from `pack`'s Github release | diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index 1c64a29f5..d4c73f7a0 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -35,7 +35,6 @@ import ( "github.com/buildpacks/pack/acceptance/managers" pubcfg "github.com/buildpacks/pack/config" "github.com/buildpacks/pack/internal/cache" - internalConfig "github.com/buildpacks/pack/internal/config" "github.com/buildpacks/pack/internal/style" "github.com/buildpacks/pack/pkg/archive" h "github.com/buildpacks/pack/testhelpers" @@ -772,6 +771,7 @@ func testAcceptance( it.Before(func() { repo = "some-org/" + h.RandString(10) repoName = registryConfig.RepoName(repo) + pack.JustRunSuccessfully("config", "lifecycle-image", lifecycle.Image()) }) it.After(func() { @@ -798,14 +798,13 @@ func testAcceptance( buildpackManager, runImageMirror, ) + assert.Nil(err) - suiteManager.RegisterCleanUp("remove-lifecycle-"+lifecycle.Version(), func() error { - img := imageManager.GetImageID(fmt.Sprintf("%s:%s", internalConfig.DefaultLifecycleImageRepo, lifecycle.Version())) + suiteManager.RegisterCleanUp("remove-lifecycle-"+lifecycle.Image(), func() error { + img := imageManager.GetImageID(lifecycle.Image()) imageManager.CleanupImages(img) return nil }) - - assert.Nil(err) }) it.After(func() { diff --git a/acceptance/config/asset_manager.go b/acceptance/config/asset_manager.go index 5f70d9145..61c394602 100644 --- a/acceptance/config/asset_manager.go +++ b/acceptance/config/asset_manager.go @@ -14,6 +14,7 @@ import ( acceptanceOS "github.com/buildpacks/pack/acceptance/os" "github.com/buildpacks/pack/internal/blob" "github.com/buildpacks/pack/internal/builder" + "github.com/buildpacks/pack/internal/config" "github.com/buildpacks/pack/internal/style" h "github.com/buildpacks/pack/testhelpers" ) @@ -36,8 +37,10 @@ type AssetManager struct { githubAssetFetcher *GithubAssetFetcher lifecyclePath string lifecycleDescriptor builder.LifecycleDescriptor + lifecycleImage string previousLifecyclePath string previousLifecycleDescriptor builder.LifecycleDescriptor + previousLifecycleImage string defaultLifecycleDescriptor builder.LifecycleDescriptor testObject *testing.T } @@ -50,8 +53,10 @@ func ConvergedAssetManager(t *testing.T, assert h.AssertionManager, inputConfig convergedPreviousPackPath string convergedPreviousPackFixturesPaths []string convergedCurrentLifecyclePath string + convergedCurrentLifecycleImage string convergedCurrentLifecycleDescriptor builder.LifecycleDescriptor convergedPreviousLifecyclePath string + convergedPreviousLifecycleImage string convergedPreviousLifecycleDescriptor builder.LifecycleDescriptor convergedDefaultLifecycleDescriptor builder.LifecycleDescriptor ) @@ -78,11 +83,11 @@ func ConvergedAssetManager(t *testing.T, assert h.AssertionManager, inputConfig } if inputConfig.combinations.requiresCurrentLifecycle() { - convergedCurrentLifecyclePath, convergedCurrentLifecycleDescriptor = assetBuilder.ensureCurrentLifecycle() + convergedCurrentLifecyclePath, convergedCurrentLifecycleImage, convergedCurrentLifecycleDescriptor = assetBuilder.ensureCurrentLifecycle() } if inputConfig.combinations.requiresPreviousLifecycle() { - convergedPreviousLifecyclePath, convergedPreviousLifecycleDescriptor = assetBuilder.ensurePreviousLifecycle() + convergedPreviousLifecyclePath, convergedPreviousLifecycleImage, convergedPreviousLifecycleDescriptor = assetBuilder.ensurePreviousLifecycle() } if inputConfig.combinations.requiresDefaultLifecycle() { @@ -95,8 +100,10 @@ func ConvergedAssetManager(t *testing.T, assert h.AssertionManager, inputConfig previousPackPath: convergedPreviousPackPath, previousPackFixturesPaths: convergedPreviousPackFixturesPaths, lifecyclePath: convergedCurrentLifecyclePath, + lifecycleImage: convergedCurrentLifecycleImage, lifecycleDescriptor: convergedCurrentLifecycleDescriptor, previousLifecyclePath: convergedPreviousLifecyclePath, + previousLifecycleImage: convergedPreviousLifecycleImage, previousLifecycleDescriptor: convergedPreviousLifecycleDescriptor, defaultLifecycleDescriptor: convergedDefaultLifecycleDescriptor, testObject: t, @@ -152,6 +159,22 @@ func (a AssetManager) LifecycleDescriptor(kind ComboValue) builder.LifecycleDesc return builder.LifecycleDescriptor{} // Unreachable } +func (a AssetManager) LifecycleImage(kind ComboValue) string { + a.testObject.Helper() + + switch kind { + case Current: + return a.lifecycleImage + case Previous: + return a.previousLifecycleImage + case DefaultKind: + return fmt.Sprintf("%s:%s", config.DefaultLifecycleImageRepo, a.defaultLifecycleDescriptor.Info.Version) + } + + a.testObject.Fatalf("lifecycle kind must be previous, current or default was %s", kind) + return "" // Unreachable +} + type assetManagerBuilder struct { testObject *testing.T assert h.AssertionManager @@ -235,7 +258,7 @@ func (b assetManagerBuilder) ensurePreviousPackFixtures() string { return fixturesDir } -func (b assetManagerBuilder) ensureCurrentLifecycle() (string, builder.LifecycleDescriptor) { +func (b assetManagerBuilder) ensureCurrentLifecycle() (string, string, builder.LifecycleDescriptor) { b.testObject.Helper() lifecyclePath := b.inputConfig.lifecyclePath @@ -255,10 +278,18 @@ func (b assetManagerBuilder) ensureCurrentLifecycle() (string, builder.Lifecycle lifecycle, err := builder.NewLifecycle(blob.NewBlob(lifecyclePath)) b.assert.Nil(err) - return lifecyclePath, lifecycle.Descriptor() + lifecycleImage := b.inputConfig.lifecycleImage + + if lifecycleImage == "" { + lifecycleImage = fmt.Sprintf("%s:%s", config.DefaultLifecycleImageRepo, lifecycle.Descriptor().Info.Version) + + b.testObject.Logf("using %s for current lifecycle image", lifecycleImage) + } + + return lifecyclePath, lifecycleImage, lifecycle.Descriptor() } -func (b assetManagerBuilder) ensurePreviousLifecycle() (string, builder.LifecycleDescriptor) { +func (b assetManagerBuilder) ensurePreviousLifecycle() (string, string, builder.LifecycleDescriptor) { b.testObject.Helper() previousLifecyclePath := b.inputConfig.previousLifecyclePath @@ -278,7 +309,15 @@ func (b assetManagerBuilder) ensurePreviousLifecycle() (string, builder.Lifecycl lifecycle, err := builder.NewLifecycle(blob.NewBlob(previousLifecyclePath)) b.assert.Nil(err) - return previousLifecyclePath, lifecycle.Descriptor() + previousLifecycleImage := b.inputConfig.previousLifecycleImage + + if previousLifecycleImage == "" { + previousLifecycleImage = fmt.Sprintf("%s:%s", config.DefaultLifecycleImageRepo, lifecycle.Descriptor().Info.Version) + + b.testObject.Logf("using %s for previous lifecycle image", previousLifecycleImage) + } + + return previousLifecyclePath, previousLifecycleImage, lifecycle.Descriptor() } func (b assetManagerBuilder) downloadLifecycle(version string) string { diff --git a/acceptance/config/input_configuration_manager.go b/acceptance/config/input_configuration_manager.go index 1bb1a441f..36565f634 100644 --- a/acceptance/config/input_configuration_manager.go +++ b/acceptance/config/input_configuration_manager.go @@ -13,14 +13,16 @@ import ( ) const ( - envPackPath = "PACK_PATH" - envPreviousPackPath = "PREVIOUS_PACK_PATH" - envPreviousPackFixturesPath = "PREVIOUS_PACK_FIXTURES_PATH" - envLifecyclePath = "LIFECYCLE_PATH" - envPreviousLifecyclePath = "PREVIOUS_LIFECYCLE_PATH" - envGitHubToken = "GITHUB_TOKEN" envAcceptanceSuiteConfig = "ACCEPTANCE_SUITE_CONFIG" envCompilePackWithVersion = "COMPILE_PACK_WITH_VERSION" + envGitHubToken = "GITHUB_TOKEN" + envLifecycleImage = "LIFECYCLE_IMAGE" + envLifecyclePath = "LIFECYCLE_PATH" + envPackPath = "PACK_PATH" + envPreviousLifecycleImage = "PREVIOUS_LIFECYCLE_IMAGE" + envPreviousLifecyclePath = "PREVIOUS_LIFECYCLE_PATH" + envPreviousPackFixturesPath = "PREVIOUS_PACK_FIXTURES_PATH" + envPreviousPackPath = "PREVIOUS_PACK_PATH" ) type InputConfigurationManager struct { @@ -29,6 +31,8 @@ type InputConfigurationManager struct { previousPackFixturesPath string lifecyclePath string previousLifecyclePath string + lifecycleImage string + previousLifecycleImage string compilePackWithVersion string githubToken string combinations ComboSet @@ -40,8 +44,6 @@ func NewInputConfigurationManager() (InputConfigurationManager, error) { previousPackFixturesPath := os.Getenv(envPreviousPackFixturesPath) lifecyclePath := os.Getenv(envLifecyclePath) previousLifecyclePath := os.Getenv(envPreviousLifecyclePath) - compilePackWithVersion := os.Getenv(envCompilePackWithVersion) - githubToken := os.Getenv(envGitHubToken) err := resolveAbsolutePaths(&packPath, &previousPackPath, &previousPackFixturesPath, &lifecyclePath, &previousLifecyclePath) if err != nil { @@ -69,8 +71,10 @@ func NewInputConfigurationManager() (InputConfigurationManager, error) { previousPackFixturesPath: previousPackFixturesPath, lifecyclePath: lifecyclePath, previousLifecyclePath: previousLifecyclePath, - compilePackWithVersion: compilePackWithVersion, - githubToken: githubToken, + lifecycleImage: os.Getenv(envLifecycleImage), + previousLifecycleImage: os.Getenv(envPreviousLifecycleImage), + compilePackWithVersion: os.Getenv(envCompilePackWithVersion), + githubToken: os.Getenv(envGitHubToken), combinations: combos, }, nil } diff --git a/acceptance/config/lifecycle_asset.go b/acceptance/config/lifecycle_asset.go index dd340fe4f..3be2bcc63 100644 --- a/acceptance/config/lifecycle_asset.go +++ b/acceptance/config/lifecycle_asset.go @@ -15,12 +15,14 @@ import ( type LifecycleAsset struct { path string descriptor builder.LifecycleDescriptor + image string } func (a AssetManager) NewLifecycleAsset(kind ComboValue) LifecycleAsset { return LifecycleAsset{ path: a.LifecyclePath(kind), descriptor: a.LifecycleDescriptor(kind), + image: a.LifecycleImage(kind), } } @@ -48,6 +50,10 @@ func (l *LifecycleAsset) EscapedPath() string { return strings.ReplaceAll(l.path, `\`, `\\`) } +func (l *LifecycleAsset) Image() string { + return l.image +} + func earliestVersion(versions []*api.Version) *api.Version { var earliest *api.Version for _, version := range versions {