Skip to content

Commit

Permalink
Add watchexec to order groups (#484)
Browse files Browse the repository at this point in the history
* add watchexec to order groups

* Add watchexec to npm order group

Co-authored-by: Tim Hitchener <thitch97@users.noreply.github.com>
Co-authored-by: Tim Hitchener <thitchener@pivotal.io>
  • Loading branch information
3 people authored Nov 17, 2021
1 parent 4c4ea09 commit 1d34eef
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 53 deletions.
15 changes: 15 additions & 0 deletions buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ api = "0.6"
optional = true
version = "2.4.2"

[[order.group]]
id = "paketo-buildpacks/watchexec"
optional = true
version = "1.2.0"

[[order.group]]
id = "paketo-buildpacks/node-engine"
version = "0.11.0"
Expand Down Expand Up @@ -63,6 +68,11 @@ api = "0.6"
optional = true
version = "2.4.2"

[[order.group]]
id = "paketo-buildpacks/watchexec"
optional = true
version = "1.2.0"

[[order.group]]
id = "paketo-buildpacks/node-engine"
version = "0.11.0"
Expand Down Expand Up @@ -107,6 +117,11 @@ api = "0.6"
optional = true
version = "2.4.2"

[[order.group]]
id = "paketo-buildpacks/watchexec"
optional = true
version = "1.2.0"

[[order.group]]
id = "paketo-buildpacks/node-engine"
version = "0.11.0"
Expand Down
42 changes: 9 additions & 33 deletions integration/node_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,7 @@ func testNodeStart(t *testing.T, context spec.G, it spec.S) {
Execute(image.ID)
Expect(err).NotTo(HaveOccurred())

Eventually(container).Should(BeAvailable())

response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("8080")))
Expect(err).NotTo(HaveOccurred())
defer response.Body.Close()
Expect(response.StatusCode).To(Equal(http.StatusOK))

content, err := ioutil.ReadAll(response.Body)
Expect(err).NotTo(HaveOccurred())
Expect(string(content)).To(ContainSubstring("hello world"))
Eventually(container).Should(Serve(ContainSubstring("hello world")).OnPort(8080))
})

context("when using optional utility buildpacks", func() {
Expand All @@ -100,8 +91,9 @@ func testNodeStart(t *testing.T, context spec.G, it spec.S) {
WithBuildpacks(nodeBuildpack).
WithPullPolicy("never").
WithEnv(map[string]string{
"BPE_SOME_VARIABLE": "some-value",
"BP_IMAGE_LABELS": "some-label=some-value",
"BPE_SOME_VARIABLE": "some-value",
"BP_IMAGE_LABELS": "some-label=some-value",
"BP_LIVE_RELOAD_ENABLED": "true",
}).
Execute(name, source)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -112,8 +104,10 @@ func testNodeStart(t *testing.T, context spec.G, it spec.S) {
Expect(logs).To(ContainLines(ContainSubstring("web: node server.js")))
Expect(logs).To(ContainLines(ContainSubstring("Environment Variables Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Image Labels Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Watchexec Buildpack")))

Expect(image.Buildpacks[4].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Buildpacks[5].Key).To(Equal("paketo-buildpacks/environment-variables"))
Expect(image.Buildpacks[5].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Labels["some-label"]).To(Equal("some-value"))

container, err = docker.Container.Run.
Expand All @@ -123,16 +117,7 @@ func testNodeStart(t *testing.T, context spec.G, it spec.S) {
Execute(image.ID)
Expect(err).NotTo(HaveOccurred())

Eventually(container).Should(BeAvailable())

response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("8080")))
Expect(err).NotTo(HaveOccurred())
defer response.Body.Close()
Expect(response.StatusCode).To(Equal(http.StatusOK))

content, err := ioutil.ReadAll(response.Body)
Expect(err).NotTo(HaveOccurred())
Expect(string(content)).To(ContainSubstring("hello world"))
Eventually(container).Should(Serve(ContainSubstring("hello world")).OnPort(8080))
})
})

Expand Down Expand Up @@ -172,16 +157,7 @@ func testNodeStart(t *testing.T, context spec.G, it spec.S) {
Execute(image.ID)
Expect(err).NotTo(HaveOccurred())

Eventually(container).Should(BeAvailable())

response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("8080")))
Expect(err).NotTo(HaveOccurred())
defer response.Body.Close()
Expect(response.StatusCode).To(Equal(http.StatusOK))

content, err := ioutil.ReadAll(response.Body)
Expect(err).NotTo(HaveOccurred())
Expect(string(content)).To(ContainSubstring("hello world"))
Eventually(container).Should(Serve(ContainSubstring("hello world")).OnPort(8080))
})
})

Expand Down
13 changes: 8 additions & 5 deletions integration/npm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ func testNPM(t *testing.T, context spec.G, it spec.S) {
WithBuildpacks(nodeBuildpack).
WithPullPolicy("never").
WithEnv(map[string]string{
"BPE_SOME_VARIABLE": "some-value",
"BP_IMAGE_LABELS": "some-label=some-value",
"BP_NODE_RUN_SCRIPTS": "some-script",
"BPE_SOME_VARIABLE": "some-value",
"BP_IMAGE_LABELS": "some-label=some-value",
"BP_NODE_RUN_SCRIPTS": "some-script",
"BP_LIVE_RELOAD_ENABLED": "true",
}).
Execute(name, source)
Expect(err).NotTo(HaveOccurred())

Expect(logs).To(ContainLines(ContainSubstring("Watchexec Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("NPM Install Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Module Bill of Materials Generator Buildpack")))
Expand All @@ -125,9 +127,10 @@ func testNPM(t *testing.T, context spec.G, it spec.S) {
Expect(logs).To(ContainLines(ContainSubstring("Image Labels Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Run Script")))

Expect(image.Buildpacks[7].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Buildpacks[8].Key).To(Equal("paketo-buildpacks/environment-variables"))
Expect(image.Buildpacks[8].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Labels["some-label"]).To(Equal("some-value"))
Expect(image.Buildpacks[3].Key).To(Equal("paketo-buildpacks/node-module-bom"))
Expect(image.Buildpacks[4].Key).To(Equal("paketo-buildpacks/node-module-bom"))

container, err = docker.Container.Run.
WithEnv(map[string]string{"PORT": "8080"}).
Expand Down
24 changes: 9 additions & 15 deletions integration/yarn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ func testYarn(t *testing.T, context spec.G, it spec.S) {
WithBuildpacks(nodeBuildpack).
WithPullPolicy("never").
WithEnv(map[string]string{
"BPE_SOME_VARIABLE": "some-value",
"BP_IMAGE_LABELS": "some-label=some-value",
"BP_NODE_RUN_SCRIPTS": "some-script",
"BPE_SOME_VARIABLE": "some-value",
"BP_IMAGE_LABELS": "some-label=some-value",
"BP_NODE_RUN_SCRIPTS": "some-script",
"BP_LIVE_RELOAD_ENABLED": "true",
}).
Execute(name, source)
Expect(err).NotTo(HaveOccurred())

Expect(logs).To(ContainLines(ContainSubstring("Watchexec Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Engine Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Yarn Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Yarn Install Buildpack")))
Expand All @@ -118,9 +120,10 @@ func testYarn(t *testing.T, context spec.G, it spec.S) {
Expect(logs).To(ContainLines(ContainSubstring("Image Labels Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Node Run Script")))

Expect(image.Buildpacks[8].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Buildpacks[9].Key).To(Equal("paketo-buildpacks/environment-variables"))
Expect(image.Buildpacks[9].Layers["environment-variables"].Metadata["variables"]).To(Equal(map[string]interface{}{"SOME_VARIABLE": "some-value"}))
Expect(image.Labels["some-label"]).To(Equal("some-value"))
Expect(image.Buildpacks[4].Key).To(Equal("paketo-buildpacks/node-module-bom"))
Expect(image.Buildpacks[5].Key).To(Equal("paketo-buildpacks/node-module-bom"))

container, err = docker.Container.Run.
WithEnv(map[string]string{"PORT": "8080"}).
Expand All @@ -129,16 +132,7 @@ func testYarn(t *testing.T, context spec.G, it spec.S) {
Execute(image.ID)
Expect(err).NotTo(HaveOccurred())

Eventually(container).Should(BeAvailable())

response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("8080")))
Expect(err).NotTo(HaveOccurred())
defer response.Body.Close()
Expect(response.StatusCode).To(Equal(http.StatusOK))

content, err := ioutil.ReadAll(response.Body)
Expect(err).NotTo(HaveOccurred())
Expect(string(content)).To(ContainSubstring("Hello, World!"))
Eventually(container).Should(Serve(ContainSubstring("Hello, World")).OnPort(8080))
})
})

Expand Down
3 changes: 3 additions & 0 deletions package.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@

[[dependencies]]
uri = "docker://gcr.io/paketo-buildpacks/node-module-bom:0.2.0"

[[dependencies]]
uri = "docker://gcr.io/paketo-buildpacks/watchexec:1.2.0"

0 comments on commit 1d34eef

Please sign in to comment.