diff --git a/integration.json b/integration.json index cc09764..418b761 100644 --- a/integration.json +++ b/integration.json @@ -1,5 +1,9 @@ { - "builders": ["paketobuildpacks/builder-jammy-buildpackless-base"], + "builders": [ + "paketobuildpacks/builder-jammy-buildpackless-base", + "index.docker.io/paketocommunity/builder-ubi-buildpackless-base:latest" + ], + "ubi-nodejs-extension": "github.com/paketo-community/ubi-nodejs-extension", "node-engine": "github.com/paketo-buildpacks/node-engine", "npm-install": "github.com/paketo-buildpacks/npm-install", "watchexec": "github.com/paketo-buildpacks/watchexec" diff --git a/integration/default_test.go b/integration/default_test.go index aa13433..7b7b825 100644 --- a/integration/default_test.go +++ b/integration/default_test.go @@ -20,11 +20,21 @@ func testDefault(t *testing.T, context spec.G, it spec.S) { pack occam.Pack docker occam.Docker + + pullPolicy = "never" + extenderBuildStr = "" + extenderBuildStrEscaped = "" ) it.Before(func() { pack = occam.NewPack().WithVerbose().WithNoColor() docker = occam.NewDocker() + + if settings.Extensions.UbiNodejsExtension.Online != "" { + pullPolicy = "always" + extenderBuildStr = "[extender (build)] " + extenderBuildStrEscaped = `\[extender \(build\)\] ` + } }) context("when building a default app", func() { @@ -56,7 +66,10 @@ func testDefault(t *testing.T, context spec.G, it spec.S) { var logs fmt.Stringer image, logs, err = pack.Build. - WithPullPolicy("never"). + WithPullPolicy(pullPolicy). + WithExtensions( + settings.Extensions.UbiNodejsExtension.Online, + ). WithBuildpacks( settings.Buildpacks.NodeEngine.Online, settings.Buildpacks.NodeStart.Online, @@ -74,9 +87,9 @@ func testDefault(t *testing.T, context spec.G, it spec.S) { Eventually(container).Should(Serve(ContainSubstring("hello world"))) Expect(logs).To(ContainLines( - MatchRegexp(fmt.Sprintf(`%s \d+\.\d+\.\d+`, settings.Buildpack.Name)), - " Assigning launch processes:", - " web (default): node server.js", + MatchRegexp(fmt.Sprintf(`%s%s \d+\.\d+\.\d+`, extenderBuildStrEscaped, settings.Buildpack.Name)), + extenderBuildStr+" Assigning launch processes:", + extenderBuildStr+" web (default): node server.js", )) }) @@ -94,7 +107,10 @@ func testDefault(t *testing.T, context spec.G, it spec.S) { var logs fmt.Stringer image, logs, err = pack.Build. - WithPullPolicy("never"). + WithPullPolicy(pullPolicy). + WithExtensions( + settings.Extensions.UbiNodejsExtension.Online, + ). WithBuildpacks( settings.Buildpacks.NodeEngine.Online, settings.Buildpacks.Watchexec.Online, @@ -126,10 +142,10 @@ func testDefault(t *testing.T, context spec.G, it spec.S) { Eventually(noReloadContainer).Should(Serve(ContainSubstring("hello world")).OnPort(8080)) Expect(logs).To(ContainLines( - MatchRegexp(fmt.Sprintf(`%s \d+\.\d+\.\d+`, settings.Buildpack.Name)), - " Assigning launch processes:", - " web (default): watchexec --restart --watch /workspace --shell none -- node server.js", - " no-reload: node server.js", + MatchRegexp(fmt.Sprintf(`%s%s \d+\.\d+\.\d+`, extenderBuildStrEscaped, settings.Buildpack.Name)), + extenderBuildStr+" Assigning launch processes:", + extenderBuildStr+" web (default): watchexec --restart --watch /workspace --shell none -- node server.js", + extenderBuildStr+" no-reload: node server.js", )) }) }) diff --git a/integration/init_test.go b/integration/init_test.go index d90a523..c3fb269 100644 --- a/integration/init_test.go +++ b/integration/init_test.go @@ -33,15 +33,22 @@ var settings struct { } } + Extensions struct { + UbiNodejsExtension struct { + Online string + } + } + Buildpack struct { ID string Name string } Config struct { - NodeEngine string `json:"node-engine"` - NPMInstall string `json:"npm-install"` - Watchexec string `json:"watchexec"` + NodeEngine string `json:"node-engine"` + NPMInstall string `json:"npm-install"` + Watchexec string `json:"watchexec"` + UbiNodejsExtension string `json:"ubi-nodejs-extension"` } } @@ -69,6 +76,17 @@ func TestIntegration(t *testing.T) { buildpackStore := occam.NewBuildpackStore() libpakBuildpackStore := occam.NewBuildpackStore().WithPackager(packagers.NewLibpak()) + pack := occam.NewPack() + + builder, err := pack.Builder.Inspect.Execute() + Expect(err).NotTo(HaveOccurred()) + + if builder.BuilderName == "index.docker.io/paketocommunity/builder-ubi-buildpackless-base:latest" { + settings.Extensions.UbiNodejsExtension.Online, err = buildpackStore.Get. + Execute(settings.Config.UbiNodejsExtension) + Expect(err).ToNot(HaveOccurred()) + } + settings.Buildpacks.NodeStart.Online, err = buildpackStore.Get. WithVersion("1.2.3"). Execute(root) diff --git a/integration/launchpoint_test.go b/integration/launchpoint_test.go index 316096f..ccc5ae5 100644 --- a/integration/launchpoint_test.go +++ b/integration/launchpoint_test.go @@ -20,11 +20,21 @@ func testLaunchpoint(t *testing.T, context spec.G, it spec.S) { pack occam.Pack docker occam.Docker + + pullPolicy = "never" + extenderBuildStr = "" + extenderBuildStrEscaped = "" ) it.Before(func() { pack = occam.NewPack().WithVerbose().WithNoColor() docker = occam.NewDocker() + + if settings.Extensions.UbiNodejsExtension.Online != "" { + pullPolicy = "always" + extenderBuildStr = "[extender (build)] " + extenderBuildStrEscaped = `\[extender \(build\)\] ` + } }) context("when building an app with a non-standard launchpoint", func() { @@ -56,7 +66,10 @@ func testLaunchpoint(t *testing.T, context spec.G, it spec.S) { var logs fmt.Stringer image, logs, err = pack.Build. - WithPullPolicy("never"). + WithPullPolicy(pullPolicy). + WithExtensions( + settings.Extensions.UbiNodejsExtension.Online, + ). WithBuildpacks( settings.Buildpacks.NodeEngine.Online, settings.Buildpacks.NodeStart.Online, @@ -75,9 +88,9 @@ func testLaunchpoint(t *testing.T, context spec.G, it spec.S) { Eventually(container).Should(Serve(ContainSubstring("hello world")).OnPort(8080)) Expect(logs).To(ContainLines( - MatchRegexp(fmt.Sprintf(`%s \d+\.\d+\.\d+`, settings.Buildpack.Name)), - " Assigning launch processes:", - " web (default): node src/launchpoint.js", + MatchRegexp(fmt.Sprintf(`%s%s \d+\.\d+\.\d+`, extenderBuildStrEscaped, settings.Buildpack.Name)), + extenderBuildStr+" Assigning launch processes:", + extenderBuildStr+" web (default): node src/launchpoint.js", )) }) }) diff --git a/integration/node_modules_test.go b/integration/node_modules_test.go index f2b5a87..07a9450 100644 --- a/integration/node_modules_test.go +++ b/integration/node_modules_test.go @@ -26,6 +26,8 @@ func testNodeModules(t *testing.T, context spec.G, it spec.S) { name string source string + + pullPolicy = "never" ) it.Before(func() { @@ -35,6 +37,10 @@ func testNodeModules(t *testing.T, context spec.G, it spec.S) { var err error name, err = occam.RandomName() Expect(err).NotTo(HaveOccurred()) + + if settings.Extensions.UbiNodejsExtension.Online != "" { + pullPolicy = "always" + } }) it.After(func() { @@ -51,7 +57,10 @@ func testNodeModules(t *testing.T, context spec.G, it spec.S) { var logs fmt.Stringer image, logs, err = pack.Build. - WithPullPolicy("never"). + WithPullPolicy(pullPolicy). + WithExtensions( + settings.Extensions.UbiNodejsExtension.Online, + ). WithBuildpacks( settings.Buildpacks.NodeEngine.Online, settings.Buildpacks.NPMInstall.Online, diff --git a/integration/project_path_test.go b/integration/project_path_test.go index d672006..6de12b3 100644 --- a/integration/project_path_test.go +++ b/integration/project_path_test.go @@ -20,11 +20,21 @@ func testProjectPath(t *testing.T, context spec.G, it spec.S) { pack occam.Pack docker occam.Docker + + pullPolicy = "never" + extenderBuildStr = "" + extenderBuildStrEscaped = "" ) it.Before(func() { pack = occam.NewPack().WithVerbose().WithNoColor() docker = occam.NewDocker() + + if settings.Extensions.UbiNodejsExtension.Online != "" { + pullPolicy = "always" + extenderBuildStr = "[extender (build)] " + extenderBuildStrEscaped = `\[extender \(build\)\] ` + } }) context("when building an app with a custom project path", func() { @@ -56,7 +66,10 @@ func testProjectPath(t *testing.T, context spec.G, it spec.S) { var logs fmt.Stringer image, logs, err = pack.Build. - WithPullPolicy("never"). + WithPullPolicy(pullPolicy). + WithExtensions( + settings.Extensions.UbiNodejsExtension.Online, + ). WithBuildpacks( settings.Buildpacks.NodeEngine.Online, settings.Buildpacks.NodeStart.Online, @@ -75,9 +88,9 @@ func testProjectPath(t *testing.T, context spec.G, it spec.S) { Eventually(container).Should(Serve(ContainSubstring("hello world")).OnPort(8080)) Expect(logs).To(ContainLines( - MatchRegexp(fmt.Sprintf(`%s \d+\.\d+\.\d+`, settings.Buildpack.Name)), - " Assigning launch processes:", - " web (default): node src/server.js", + MatchRegexp(fmt.Sprintf(`%s%s \d+\.\d+\.\d+`, extenderBuildStrEscaped, settings.Buildpack.Name)), + extenderBuildStr+" Assigning launch processes:", + extenderBuildStr+" web (default): node src/server.js", )) }) }) diff --git a/scripts/integration.sh b/scripts/integration.sh index 13a5635..07f6f0e 100755 --- a/scripts/integration.sh +++ b/scripts/integration.sh @@ -153,6 +153,7 @@ function tests::run() { util::print::title "Run Buildpack Runtime Integration Tests" util::print::info "Using ${1} as builder..." + pack config experimental true export CGO_ENABLED=0 pushd "${BUILDPACKDIR}" > /dev/null if GOMAXPROCS="${GOMAXPROCS:-4}" go test -count=1 -timeout 0 ./integration/... -v -run Integration | tee "${2}"; then