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

feat: adding ubi-buildpackless-base builder on integration tests #386

Merged
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
6 changes: 5 additions & 1 deletion integration.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
34 changes: 25 additions & 9 deletions integration/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
Expand All @@ -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",
))
})

Expand All @@ -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,
Expand Down Expand Up @@ -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",
))
})
})
Expand Down
24 changes: 21 additions & 3 deletions integration/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
}

Expand Down Expand Up @@ -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)
Expand Down
21 changes: 17 additions & 4 deletions integration/launchpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
Expand All @@ -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",
))
})
})
Expand Down
11 changes: 10 additions & 1 deletion integration/node_modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func testNodeModules(t *testing.T, context spec.G, it spec.S) {

name string
source string

pullPolicy = "never"
)

it.Before(func() {
Expand All @@ -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() {
Expand All @@ -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,
Expand Down
21 changes: 17 additions & 4 deletions integration/project_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
Expand All @@ -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",
))
})
})
Expand Down
1 change: 1 addition & 0 deletions scripts/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading