Skip to content

Commit 29088e2

Browse files
Fix linter issues + test issues
1 parent f302ad0 commit 29088e2

7 files changed

Lines changed: 37 additions & 15 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,13 @@ A Cloud Native Buildpack to install gems from a Gemfile
66

77

88
This will be providing `gems`.
9+
10+
## Build Targets
11+
12+
The buildpack binaries are compiled for `linux/amd64` and `linux/arm64` by default.
13+
14+
To build for custom OS/architecture targets, run [scripts/build.sh](scripts/build.sh) with one or more `--target` flags:
15+
16+
```bash
17+
./scripts/build.sh --target linux/amd64 --target linux/arm64
18+
```

buildpack.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ api = "0.7"
1313
uri = "https://github.com/paketo-buildpacks/bundle-install/blob/main/LICENSE"
1414

1515
[metadata]
16-
include-files = ["bin/build", "bin/detect", "bin/run", "buildpack.toml"]
17-
pre-package = "./scripts/build.sh"
16+
include-files = ["buildpack.toml", "linux/amd64/bin/build", "linux/amd64/bin/detect", "linux/amd64/bin/run", "linux/arm64/bin/build", "linux/arm64/bin/detect", "linux/arm64/bin/run"]
17+
pre-package = "./scripts/build.sh --target linux/amd64 --target linux/arm64"
1818

1919
[[stacks]]
2020
id = "*"

bundle_install_process_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ func testBundleInstallProcess(t *testing.T, context spec.G, it spec.S) {
262262
executions = append(executions, execution)
263263

264264
if strings.Contains(strings.Join(execution.Args, " "), "config --global cache_path --parseable") {
265-
fmt.Fprintf(execution.Stdout, "cache_path=other_dir/other_cache")
265+
_, err := fmt.Fprintf(execution.Stdout, "cache_path=other_dir/other_cache")
266+
Expect(err).NotTo(HaveOccurred())
266267
}
267268

268269
return nil
@@ -398,8 +399,10 @@ func testBundleInstallProcess(t *testing.T, context spec.G, it spec.S) {
398399
it.Before(func() {
399400
executable.ExecuteCall.Stub = func(execution pexec.Execution) error {
400401
if strings.Contains(strings.Join(execution.Args, " "), "config --global path") {
401-
fmt.Fprint(execution.Stdout, "stdout output")
402-
fmt.Fprint(execution.Stderr, "stderr output")
402+
_, err := fmt.Fprint(execution.Stdout, "stdout output")
403+
Expect(err).NotTo(HaveOccurred())
404+
_, err = fmt.Fprint(execution.Stderr, "stderr output")
405+
Expect(err).NotTo(HaveOccurred())
403406

404407
return errors.New("bundle config path failed")
405408
}
@@ -434,8 +437,10 @@ func testBundleInstallProcess(t *testing.T, context spec.G, it spec.S) {
434437
it.Before(func() {
435438
executable.ExecuteCall.Stub = func(execution pexec.Execution) error {
436439
if strings.Contains(strings.Join(execution.Args, " "), "install") {
437-
fmt.Fprint(execution.Stdout, "stdout output")
438-
fmt.Fprint(execution.Stderr, "stderr output")
440+
_, err := fmt.Fprint(execution.Stdout, "stdout output")
441+
Expect(err).NotTo(HaveOccurred())
442+
_, err = fmt.Fprint(execution.Stderr, "stderr output")
443+
Expect(err).NotTo(HaveOccurred())
439444

440445
return errors.New("bundle install failed")
441446
}

gemfile_parser_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ func testGemfileParser(t *testing.T, context spec.G, it spec.S) {
2828
it.Before(func() {
2929
file, err := os.CreateTemp("", "Gemfile")
3030
Expect(err).NotTo(HaveOccurred())
31-
defer file.Close()
31+
defer func() {
32+
Expect(file.Close()).To(Succeed())
33+
}()
3234

3335
path = file.Name()
3436

integration/offline_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ func testOffline(t *testing.T, context spec.G, it spec.S) {
7777

7878
response, err := http.Get(fmt.Sprintf("http://localhost:%s", container.HostPort("9292")))
7979
Expect(err).NotTo(HaveOccurred())
80-
defer response.Body.Close()
80+
defer func() {
81+
Expect(response.Body.Close()).To(Succeed())
82+
}()
8183

8284
Expect(response.StatusCode).To(Equal(http.StatusOK))
8385

ruby_version_resolver_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ func testRubyVersionResolver(t *testing.T, context spec.G, it spec.S) {
2626
it.Before(func() {
2727
executable = &fakes.Executable{}
2828
executable.ExecuteCall.Stub = func(execution pexec.Execution) error {
29-
fmt.Fprintf(execution.Stdout, "ruby 2.7.7p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]")
29+
_, err := fmt.Fprintf(execution.Stdout, "ruby 2.7.7p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]")
30+
Expect(err).NotTo(HaveOccurred())
3031
return nil
3132
}
3233

@@ -48,7 +49,8 @@ func testRubyVersionResolver(t *testing.T, context spec.G, it spec.S) {
4849
context("fails to execute `ruby --version`", func() {
4950
it.Before(func() {
5051
executable.ExecuteCall.Stub = func(execution pexec.Execution) error {
51-
fmt.Fprintf(execution.Stderr, "failed to execute")
52+
_, err := fmt.Fprintf(execution.Stderr, "failed to execute")
53+
Expect(err).NotTo(HaveOccurred())
5254
return errors.New("exit status 1")
5355
}
5456
})
@@ -64,7 +66,8 @@ func testRubyVersionResolver(t *testing.T, context spec.G, it spec.S) {
6466
context("no ruby match is found", func() {
6567
it.Before(func() {
6668
executable.ExecuteCall.Stub = func(execution pexec.Execution) error {
67-
fmt.Fprintf(execution.Stdout, "")
69+
_, err := fmt.Fprintf(execution.Stdout, "")
70+
Expect(err).NotTo(HaveOccurred())
6871
return nil
6972
}
7073
})

scripts/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ function main() {
4545
run::build
4646
cmd::build
4747

48-
## For backwards compatibility with amd64 workflows
49-
if [[ ${#targets[@]} -eq 1 && "${targets[0]}" == "linux/amd64" ]]; then
50-
cp -r "${BUILDPACKDIR}/linux/amd64/bin/" "${BUILDPACKDIR}/"
48+
## Keep top-level bin for backwards compatibility with amd64-only workflows.
49+
if [[ -d "${BUILDPACKDIR}/linux/amd64/bin" ]]; then
50+
cp -r "${BUILDPACKDIR}/linux/amd64/bin/." "${BUILDPACKDIR}/bin/"
5151
fi
5252
}
5353

0 commit comments

Comments
 (0)