Skip to content

Commit

Permalink
Bump version of libcnbv2 to 2.0.0-alpha.3 (#77)
Browse files Browse the repository at this point in the history
* Bump version of libcnbv2 to 2.0.0-alpha.3

Signed-off-by: Daniel Mikusa <dan@mikusa.com>

* Enable ARM64 support

Signed-off-by: Daniel Mikusa <dan@mikusa.com>

---------

Signed-off-by: Daniel Mikusa <dan@mikusa.com>
  • Loading branch information
dmikusa authored Jun 18, 2024
1 parent 53b3b94 commit d301496
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 84 deletions.
27 changes: 8 additions & 19 deletions .github/workflows/pb-create-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,21 @@ jobs:
username: ${{ secrets.DOCKER_USER }}
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
- name: Install create-package
run: |
#!/usr/bin/env bash
set -euo pipefail
go install -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/create-package@latest
- uses: buildpacks/github-actions/setup-tools@v5.5.3
- uses: buildpacks/github-actions/setup-tools@v5.7.2
with:
crane-version: 0.19.0
crane-version: 0.19.1
yj-version: 5.1.0
- name: Install pack
run: |
#!/usr/bin/env bash
# this is coming from a copy of https://github.com/buildpacks/pack/actions/runs/8118576298 stored on box
# TODO to revisit when the official one is out
set -euo pipefail
echo "Installing pack experimental"
mkdir -p "${HOME}"/bin
echo "${HOME}/bin" >> "${GITHUB_PATH}"
curl -L "https://ent.box.com/shared/static/j4d1bfe9uk1sb0i7zjvci0md9xmy41u4" -o ${HOME}/bin/pack
chmod +x "${HOME}"/bin/pack
- uses: buildpacks/github-actions/setup-pack@v5.7.2
with:
pack-version: 0.34.2
- name: Enable pack Experimental
if: ${{ false }}
run: |
Expand Down Expand Up @@ -181,7 +170,7 @@ jobs:
else
pack -v buildpack package \
"${PACKAGE}:${VERSION}" ${CONFIG} \
--format "${FORMAT}"
--format "${FORMAT}" $([ -n "$TTL_SH_PUBLISH" ] && [ "$TTL_SH_PUBLISH" = "true" ] && echo "--publish")
fi
env:
PACKAGES: docker.io/buildpacksio/profile
Expand Down Expand Up @@ -212,7 +201,7 @@ jobs:
DIGEST: ${{ steps.package.outputs.digest }}
GITHUB_TOKEN: ${{ secrets.IMPLEMENTATION_GITHUB_TOKEN }}
- if: ${{ true }}
uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:5.5.3
uses: docker://ghcr.io/buildpacks/actions/registry/request-add-entry:5.7.2
with:
address: docker.io/buildpacksio/profile@${{ steps.package.outputs.digest }}
id: buildpacksio/profile
Expand Down
24 changes: 7 additions & 17 deletions .github/workflows/pb-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,17 @@ jobs:
username: ${{ secrets.DOCKER_USER }}
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
- name: Install create-package
run: |
#!/usr/bin/env bash
set -euo pipefail
go install -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/create-package@latest
- name: Install pack
run: |
#!/usr/bin/env bash
# this is coming from a copy of https://github.com/buildpacks/pack/actions/runs/8118576298 stored on box
# TODO to revisit when the official one is out
set -euo pipefail
echo "Installing pack experimental"
mkdir -p "${HOME}"/bin
echo "${HOME}/bin" >> "${GITHUB_PATH}"
curl -L "https://ent.box.com/shared/static/j4d1bfe9uk1sb0i7zjvci0md9xmy41u4" -o ${HOME}/bin/pack
chmod +x "${HOME}"/bin/pack
- uses: buildpacks/github-actions/setup-pack@v5.7.2
with:
pack-version: 0.34.2
- name: Enable pack Experimental
if: ${{ false }}
run: |
Expand Down Expand Up @@ -180,11 +169,12 @@ jobs:
else
pack -v buildpack package \
"${PACKAGE}:${VERSION}" ${CONFIG} \
--format "${FORMAT}"
--format "${FORMAT}" $([ -n "$TTL_SH_PUBLISH" ] && [ "$TTL_SH_PUBLISH" = "true" ] && echo "--publish")
fi
env:
FORMAT: image
PACKAGES: test
TTL_SH_PUBLISH: "false"
VERSION: ${{ steps.version.outputs.version }}
unit:
name: Unit Test
Expand All @@ -199,7 +189,7 @@ jobs:
restore-keys: ${{ runner.os }}-go-
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
- name: Install richgo
run: |
#!/usr/bin/env bash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pb-update-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
- uses: actions/checkout@v4
- name: Update Go Version & Modules
id: update-go
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
echo "commit-body=${COMMIT_BODY}" >> "$GITHUB_OUTPUT"
echo "commit-semver=${COMMIT_SEMVER}" >> "$GITHUB_OUTPUT"
env:
GO_VERSION: "1.20"
GO_VERSION: "1.22"
- uses: peter-evans/create-pull-request@v6
with:
author: ${{ secrets.IMPLEMENTATION_GITHUB_USERNAME }} <${{ secrets.IMPLEMENTATION_GITHUB_USERNAME }}@users.noreply.github.com>
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pb-update-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
- name: Install octo
run: |
#!/usr/bin/env bash
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018-2022 the original author or authors.
# Copyright 2018-2020 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,8 @@
# limitations under the License.

bin/
linux/
dependencies/
package/
scratch/

42 changes: 24 additions & 18 deletions buildpack.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018-2022 the original author or authors.
# Copyright 2018-2024 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,23 +15,29 @@
api = "0.8"

[buildpack]
id = "buildpacksio/profile"
name = "Profile Buildpack"
version = "{{.version}}"
homepage = "https://github.com/buildpacks/profile"
description = "A Cloud Native Buildpack that handles profile scripts"
homepage = "https://github.com/buildpacks/profile"
id = "buildpacksio/profile"
keywords = ["profile", "bash"]
name = "Profile Buildpack"
sbom-formats = ["application/vnd.cyclonedx+json", "application/vnd.syft+json"]
version = "{{.version}}"

[[stacks]]
id = "*"
[[buildpack.licenses]]
type = "Apache-2.0"
uri = "https://github.com/paketo-buildpacks/apache-tomcat/blob/main/LICENSE"

[metadata]
pre-package = "scripts/build.sh"
include-files = [
"LICENSE",
"NOTICE",
"README.md",
"bin/build",
"bin/detect",
"bin/main",
"scripts/profiled-wrapper.sh",
"buildpack.toml",
]
pre-package = "scripts/build.sh"
include-files = ["LICENSE", "NOTICE", "README.md", "linux/amd64/bin/build", "linux/amd64/bin/detect", "linux/amd64/bin/main", "linux/arm64/bin/build", "linux/arm64/bin/detect", "linux/arm64/bin/main", "scripts/profiled-wrapper.sh", "buildpack.toml"]

[[stacks]]
id = "*"

[[targets]]
arch = "amd64"
os = "linux"

[[targets]]
arch = "arm64"
os = "linux"
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module github.com/buildpacks/profile

go 1.20
go 1.22

toolchain go1.22.4

require (
github.com/buildpacks/libcnb/v2 v2.0.0-alpha.2
github.com/buildpacks/libcnb/v2 v2.0.0-alpha.3
github.com/onsi/gomega v1.33.1
)

Expand All @@ -14,7 +16,7 @@ require (
github.com/google/go-cmp v0.6.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/text v0.16.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
35 changes: 24 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,39 +1,52 @@
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/CycloneDX/cyclonedx-go v0.7.2 h1:kKQ0t1dPOlugSIYVOMiMtFqeXI2wp/f5DBIdfux8gnQ=
github.com/CycloneDX/cyclonedx-go v0.9.0 h1:inaif7qD8bivyxp7XLgxUYtOXWtDez7+j72qKTMQTb8=
github.com/CycloneDX/cyclonedx-go v0.9.0/go.mod h1:NE/EWvzELOFlG6+ljX/QeMlVt9VKcTwu8u0ccsACEsw=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/buildpacks/libcnb/v2 v2.0.0-alpha.2 h1:sbDcSv8lIpu94qOIr4hIzaiakAizkS0htTz18q3+Ej0=
github.com/buildpacks/libcnb/v2 v2.0.0-alpha.2/go.mod h1:JvxNbe4aHoVCvWVLWbu28exEJetjbfB7Y2kcO/RlNN0=
github.com/buildpacks/libcnb/v2 v2.0.0-alpha.3 h1:pk6hGgS9kCnHhW0EQmW1k/+AA4SY/0Jl9FM1+d6LdDo=
github.com/buildpacks/libcnb/v2 v2.0.0-alpha.3/go.mod h1:y0LtfZwPSPDz7EvTBNsdnrjqdmuzyDUGCQJ5nvRdpCg=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg=
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/onsi/ginkgo/v2 v2.17.2 h1:7eMhcy3GimbsA3hEnVKdw/PQM9XN9krpKVXsZdph0/g=
github.com/onsi/ginkgo/v2 v2.17.2/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc=
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1 change: 0 additions & 1 deletion profile/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
)

func Build(context libcnb.BuildContext) (libcnb.BuildResult, error) {
// NOTE: the logger is not passed into this function, that will likely be a change in libcnbv2
result := libcnb.NewBuildResult()

layer, err := context.Layers.Layer(profileName)
Expand Down
6 changes: 3 additions & 3 deletions profile/detect.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 the original author or authors.
* Copyright 2018-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,14 +25,14 @@ import (
)

func Detect(context libcnb.DetectContext) (libcnb.DetectResult, error) {
// NOTE: the logger is not passed into this function, that will likely be a change in libcnbv2

_, shErr := exec.LookPath("bash")

profilePath := filepath.Join(context.ApplicationPath, scriptName)
if _, err := os.Stat(profilePath); shErr == nil && !os.IsNotExist(err) {
context.Logger.Debug("PASSED: a .profile application exists and bash is available")
return libcnb.DetectResult{Pass: true, Plans: []libcnb.BuildPlan{}}, nil
}

context.Logger.Debug("SKIPPED: a .profile application does not exist or bash is not available")
return libcnb.DetectResult{Pass: false}, nil
}
4 changes: 3 additions & 1 deletion profile/detect_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 the original author or authors.
* Copyright 2018-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,6 +27,7 @@ import (
"github.com/buildpacks/profile/profile"

"github.com/buildpacks/libcnb/v2"
"github.com/buildpacks/libcnb/v2/log"
)

type ExpectFunc func(actual interface{}, extra ...interface{}) types.Assertion
Expand All @@ -46,6 +47,7 @@ func NewDetectTestBuilder(t *testing.T) DetectTest {

func (d DetectTest) SetupWorkspace() DetectTest {
d.context.ApplicationPath = d.test.TempDir()
d.context.Logger = log.NewDiscard()
return d
}

Expand Down
15 changes: 9 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#!/usr/bin/env bash

set -euo pipefail

GOOS="linux" go build -ldflags='-s -w' -o bin/main github.com/buildpacks/profile/cmd/main
GOMOD=$(head -1 go.mod | awk '{print $2}')
GOOS="linux" GOARCH="amd64" go build -ldflags='-s -w' -o linux/amd64/bin/main "$GOMOD/cmd/main"
GOOS="linux" GOARCH="arm64" go build -ldflags='-s -w' -o linux/arm64/bin/main "$GOMOD/cmd/main"

if [ "${STRIP:-false}" != "false" ]; then
strip bin/main
strip linux/amd64/bin/main linux/arm64/bin/main
fi

if [ "${COMPRESS:-none}" != "none" ]; then
$COMPRESS bin/main
$COMPRESS linux/amd64/bin/main linux/arm64/bin/main
fi

ln -fs main bin/build
ln -fs main bin/detect
ln -fs main linux/amd64/bin/build
ln -fs main linux/arm64/bin/build
ln -fs main linux/amd64/bin/detect
ln -fs main linux/arm64/bin/detect

0 comments on commit d301496

Please sign in to comment.