Skip to content

Commit

Permalink
Add order group for poetry - dependency-only. (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
robdimsdale authored Mar 4, 2022
1 parent 841cd5c commit a3cf2d2
Show file tree
Hide file tree
Showing 7 changed files with 357 additions and 0 deletions.
53 changes: 53 additions & 0 deletions buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ api = "0.6"
[metadata]
include-files = ["buildpack.toml"]

# pipenv
[[order]]

[[order.group]]
Expand Down Expand Up @@ -58,6 +59,7 @@ api = "0.6"
optional = true
version = "4.1.0"

# pip
[[order]]

[[order.group]]
Expand Down Expand Up @@ -101,6 +103,7 @@ api = "0.6"
optional = true
version = "4.1.0"

# conda
[[order]]

[[order.group]]
Expand Down Expand Up @@ -140,6 +143,7 @@ api = "0.6"
optional = true
version = "4.1.0"

# poetry run
[[order]]

[[order.group]]
Expand Down Expand Up @@ -182,6 +186,55 @@ api = "0.6"
optional = true
version = "4.1.0"

# poetry (dep only)
[[order]]

[[order.group]]
id = "paketo-buildpacks/ca-certificates"
optional = true
version = "3.1.0"

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

[[order.group]]
id = "paketo-buildpacks/cpython"
version = "0.7.6"

[[order.group]]
id = "paketo-buildpacks/pip"
version = "0.7.0"

[[order.group]]
id = "paketo-buildpacks/poetry"
version = "0.0.1"

[[order.group]]
id = "paketo-buildpacks/poetry-install"
version = "0.1.0"

[[order.group]]
id = "paketo-buildpacks/python-start"
version = "0.9.0"

[[order.group]]
id = "paketo-buildpacks/procfile"
optional = true
version = "5.1.0"

[[order.group]]
id = "paketo-buildpacks/environment-variables"
optional = true
version = "4.1.0"

[[order.group]]
id = "paketo-buildpacks/image-labels"
optional = true
version = "4.1.0"

# no package manager
[[order]]

[[order.group]]
Expand Down
4 changes: 4 additions & 0 deletions integration/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import (
"github.com/sclevine/spec/report"

. "github.com/onsi/gomega"
"github.com/onsi/gomega/format"
)

var pythonBuildpack string

func TestIntegration(t *testing.T) {
Expect := NewWithT(t).Expect

format.MaxLength = 0

bash := pexec.NewExecutable("bash")
buffer := bytes.NewBuffer(nil)
err := bash.Execute(pexec.Execution{
Expand All @@ -36,6 +39,7 @@ func TestIntegration(t *testing.T) {
suite("Conda", testConda)
suite("Pip", testPip)
suite("Pipenv", testPipenv)
suite("PoetryDepOnly", testPoetryDepOnly)
suite("PoetryRun", testPoetryRun)
suite("NoPackageManager", testNoPackageManager)
suite.Run(t)
Expand Down
106 changes: 106 additions & 0 deletions integration/poetry_dep_only_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package integration_test

import (
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"testing"

"github.com/paketo-buildpacks/occam"
"github.com/sclevine/spec"

. "github.com/onsi/gomega"
. "github.com/paketo-buildpacks/occam/matchers"
)

func testPoetryDepOnly(t *testing.T, context spec.G, it spec.S) {
var (
Expect = NewWithT(t).Expect
Eventually = NewWithT(t).Eventually

pack occam.Pack
docker occam.Docker
)

it.Before(func() {
pack = occam.NewPack()
docker = occam.NewDocker()
})

context("when building an app with poetry dependency management", func() {
var (
image occam.Image
container occam.Container

name string
source string
)

it.Before(func() {
var err error
name, err = occam.RandomName()
Expect(err).NotTo(HaveOccurred())
})

it.After(func() {
Expect(docker.Container.Remove.Execute(container.ID)).To(Succeed())
Expect(docker.Image.Remove.Execute(image.ID)).To(Succeed())
Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed())
Expect(os.RemoveAll(source)).To(Succeed())
})

it("creates a working OCI image with a start command", func() {
var err error
source, err = occam.Source(filepath.Join("testdata", "poetry-dep-only"))
Expect(err).NotTo(HaveOccurred())

var logs fmt.Stringer
image, logs, err = pack.WithNoColor().WithVerbose().Build.
WithBuildpacks(pythonBuildpack).
WithPullPolicy("never").
WithEnv(map[string]string{
"BPE_SOME_VARIABLE": "some-value",
"BP_IMAGE_LABELS": "some-label=some-value",
"BP_LIVE_RELOAD_ENABLED": "true",
}).
Execute(name, source)
Expect(err).NotTo(HaveOccurred(), logs.String())

container, err = docker.Container.Run.
WithEnv(map[string]string{"PORT": "8080"}).
WithPublish("8080").
WithPublishAll().
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 := io.ReadAll(response.Body)
Expect(err).NotTo(HaveOccurred())
Expect(string(content)).To(ContainSubstring("Hello, World!"))

Expect(logs).To(ContainLines(ContainSubstring("CA Certificates Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Watchexec Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("CPython Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Pip Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Poetry Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Poetry Install Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Python Start Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Procfile Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Environment Variables Buildpack")))
Expect(logs).To(ContainLines(ContainSubstring("Image Labels Buildpack")))

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"))
})
})
}
1 change: 1 addition & 0 deletions integration/testdata/poetry-dep-only/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn server:app
165 changes: 165 additions & 0 deletions integration/testdata/poetry-dep-only/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a3cf2d2

Please sign in to comment.