Skip to content

Commit

Permalink
This buildpack can now use the tiny stack with reloadable processes
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuatcasey authored and ForestEckhardt committed May 17, 2022
1 parent 7440a55 commit 53cd549
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.bin
/build
.idea/
1 change: 0 additions & 1 deletion constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ const (
TargetsLayerName = "targets"
GoCacheLayerName = "gocache"
WorkspaceSHAKey = "workspace_sha"
TinyStackName = "io.paketo.stacks.tiny"
)
4 changes: 0 additions & 4 deletions detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ func Detect(parser ConfigurationParser) packit.DetectFunc {
return packit.DetectResult{}, err
}

if shouldEnableReload && context.Stack == TinyStackName {
return packit.DetectResult{}, fmt.Errorf("cannot enable live reload on stack '%s': stack does not support watchexec", context.Stack)
}

if shouldEnableReload {
requirements = append(requirements, packit.BuildPlanRequirement{
Name: "watchexec",
Expand Down
29 changes: 5 additions & 24 deletions detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {

context("BP_LIVE_RELOAD_ENABLED=true in build environment", func() {
it.Before(func() {
os.Setenv("BP_LIVE_RELOAD_ENABLED", "true")
Expect(os.Setenv("BP_LIVE_RELOAD_ENABLED", "true")).To(Succeed())
})

it.After(func() {
os.Unsetenv("BP_LIVE_RELOAD_ENABLED")
Expect(os.Unsetenv("BP_LIVE_RELOAD_ENABLED")).To(Succeed())
})

it("requires watchexec at launch time", func() {
Expand Down Expand Up @@ -105,13 +105,14 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Expect(err).To(MatchError(ContainSubstring("failed to parse configuration")))
})
})

context("parsing value of $BP_LIVE_RELOAD_ENABLED fails", func() {
it.Before(func() {
os.Setenv("BP_LIVE_RELOAD_ENABLED", "not-a-bool")
Expect(os.Setenv("BP_LIVE_RELOAD_ENABLED", "not-a-bool")).To(Succeed())
})

it.After(func() {
os.Unsetenv("BP_LIVE_RELOAD_ENABLED")
Expect(os.Unsetenv("BP_LIVE_RELOAD_ENABLED")).To(Succeed())
})

it("returns an error", func() {
Expand All @@ -124,25 +125,5 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Expect(err).To(MatchError(ContainSubstring("failed to parse BP_LIVE_RELOAD_ENABLED value not-a-bool")))
})
})
context("BP_LIVE_RELOAD_ENABLED=true and the stack is tiny", func() {
it.Before(func() {
os.Setenv("BP_LIVE_RELOAD_ENABLED", "true")
})

it.After(func() {
os.Unsetenv("BP_LIVE_RELOAD_ENABLED")
})

it("returns an error", func() {
_, err := detect(packit.DetectContext{
WorkingDir: workingDir,
BuildpackInfo: packit.BuildpackInfo{
Version: "some-buildpack-version",
},
Stack: "io.paketo.stacks.tiny",
})
Expect(err).To(MatchError(ContainSubstring("cannot enable live reload on stack 'io.paketo.stacks.tiny': stack does not support watchexec")))
})
})
})
}
1 change: 1 addition & 0 deletions integration/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ func testDefault(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.GoDist.Online,
settings.Buildpacks.GoBuild.Online,
).
WithBuilder("paketobuildpacks/builder:tiny").
WithEnv(map[string]string{
"BP_LIVE_RELOAD_ENABLED": "true",
}).
Expand Down

0 comments on commit 53cd549

Please sign in to comment.