Skip to content

Commit

Permalink
Merge pull request #369 from paketo-buildpacks/updates
Browse files Browse the repository at this point in the history
Bump Go modules & pipeline
  • Loading branch information
dmikusa authored Oct 16, 2024
2 parents 1ce7dec + f638911 commit 993c7bb
Show file tree
Hide file tree
Showing 59 changed files with 591 additions and 1,042 deletions.
2 changes: 1 addition & 1 deletion .github/pipeline-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.39.0
1.41.2
2 changes: 1 addition & 1 deletion .github/workflows/pb-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
restore-keys: ${{ runner.os }}-go-
- uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.23"
- name: Run Tests
run: |
#!/usr/bin/env bash
Expand Down
6 changes: 3 additions & 3 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.22"
go-version: "1.23"
- uses: actions/checkout@v4
- name: Update Go Version & Modules
id: update-go
Expand All @@ -25,7 +25,7 @@ jobs:
exit 1
fi
OLD_GO_VERSION=$(grep -P '^go \d\.\d+' go.mod | cut -d ' ' -f 2)
OLD_GO_VERSION=$(grep -P '^go \d\.\d+' go.mod | cut -d ' ' -f 2 | cut -d '.' -f 1-2)
go mod edit -go="$GO_VERSION"
go mod tidy
Expand All @@ -49,7 +49,7 @@ jobs:
echo "commit-body=${COMMIT_BODY}" >> "$GITHUB_OUTPUT"
echo "commit-semver=${COMMIT_SEMVER}" >> "$GITHUB_OUTPUT"
env:
GO_VERSION: "1.22"
GO_VERSION: "1.23"
- uses: peter-evans/create-pull-request@v6
with:
author: ${{ secrets.JAVA_GITHUB_USERNAME }} <${{ secrets.JAVA_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.22"
go-version: "1.23"
- name: Install octo
run: |
#!/usr/bin/env bash
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ lint: install-golangci-lint
@golangci-lint run -c golangci.yaml

test: format lint
$(GOCMD) test -parallel=1 -count=1 -v ./...
$(GOCMD) test ./...
6 changes: 3 additions & 3 deletions build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/paketo-buildpacks/libpak/v2/log"
)

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

Expand Down Expand Up @@ -123,9 +123,9 @@ api = "0.8"
[buildpack]
name = "test-name"
version = "test-version"`),
0644)).To(Succeed())
0600)).To(Succeed())

libpak.Build(func(ctx libcnb.BuildContext) (libcnb.BuildResult, error) {
libpak.Build(func(_ libcnb.BuildContext) (libcnb.BuildResult, error) {
return libcnb.BuildResult{}, fmt.Errorf("test-error")
},
libcnb.WithArguments([]string{commandPath, layersPath, platformPath, buildpackPlanPath}),
Expand Down
20 changes: 10 additions & 10 deletions buildmodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ func (b BuildModuleDependency) GetMetadata() DependencyLayerContributorMetadata

// Equals compares the 2 structs if they are equal. This is very simiar to reflect.DeepEqual
// except that properties that will not work (e.g. DeprecationDate) are ignored.
func (b1 BuildModuleDependency) Equals(b2 BuildModuleDependency) bool {
b1.DeprecationDate = b1.DeprecationDate.Truncate(time.Second).In(time.UTC)
b2.DeprecationDate = b2.DeprecationDate.Truncate(time.Second).In(time.UTC)
func (b BuildModuleDependency) Equals(other BuildModuleDependency) bool {
b.DeprecationDate = b.DeprecationDate.Truncate(time.Second).In(time.UTC)
other.DeprecationDate = other.DeprecationDate.Truncate(time.Second).In(time.UTC)

if len(b1.CPEs) == 0 {
b1.CPEs = nil
if len(b.CPEs) == 0 {
b.CPEs = nil
}
if len(b2.CPEs) == 0 {
b2.CPEs = nil
if len(other.CPEs) == 0 {
other.CPEs = nil
}

return reflect.DeepEqual(b1, b2)
return reflect.DeepEqual(b, other)
}

// AsSyftArtifact renders a bill of materials entry describing the dependency as Syft.
Expand Down Expand Up @@ -461,8 +461,8 @@ type DependencyResolver struct {
}

// NewDependencyResolver creates a new instance from the build module metadata and stack id.
func NewDependencyResolver(md BuildModuleMetadata, stackId string) (DependencyResolver, error) {
return DependencyResolver{Dependencies: md.Dependencies, StackID: stackId}, nil
func NewDependencyResolver(md BuildModuleMetadata, stackID string) (DependencyResolver, error) {
return DependencyResolver{Dependencies: md.Dependencies, StackID: stackID}, nil
}

// NoValidDependenciesError is returned when the resolver cannot find any valid dependencies given the constraints.
Expand Down
4 changes: 2 additions & 2 deletions buildmodule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,12 @@ func testBuildpack(t *testing.T, context spec.G, it spec.S) {
}

for _, dependency := range resolver.Dependencies {
resolver.Resolve(dependency.ID, "")
_, err := resolver.Resolve(dependency.ID, "")
Expect(err).ToNot(HaveOccurred())
}

Expect(buff.String()).To(Equal(fmt.Sprintf(" \x1b[33mDeprecation Notice:\x1b[0m\n\x1b[2m \x1b[33mVersion 1.1 of soon-deprecated-dependency will be deprecated after %s.\x1b[0m\x1b[2m\x1b[0m\n\x1b[2m \x1b[33mMigrate your application to a supported version of soon-deprecated-dependency before this time.\x1b[0m\x1b[2m\x1b[0m\n \x1b[33mDeprecation Notice:\x1b[0m\n\x1b[2m \x1b[33mVersion 1.1 of deprecated-dependency is deprecated.\x1b[0m\x1b[2m\x1b[0m\n\x1b[2m \x1b[33mMigrate your application to a supported version of deprecated-dependency.\x1b[0m\x1b[2m\x1b[0m\n", soonDeprecated.Format("2006-01-02"))))
})

})

it("indicates whether error is NoValidDependenciesError", func() {
Expand Down
6 changes: 1 addition & 5 deletions buildpack_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func testBuildpackPlan(t *testing.T, context spec.G, it spec.S) {
)

context("ShallowMerge", func() {

it("merges with empty", func() {
a := libcnb.BuildpackPlanEntry{}
b := libcnb.BuildpackPlanEntry{Name: "test-name"}
Expand Down Expand Up @@ -109,11 +108,9 @@ func testBuildpackPlan(t *testing.T, context spec.G, it spec.S) {
Expect(libpak.ShallowMerge(a, b)).To(Equal(expected))
})
})

})

context("PlanEntryResolver", func() {

context("ResolveWithMerge", func() {
var (
resolver = libpak.PlanEntryResolver{}
Expand All @@ -135,7 +132,7 @@ func testBuildpackPlan(t *testing.T, context spec.G, it spec.S) {
}
})

var f = func(a, b libcnb.BuildpackPlanEntry) (libcnb.BuildpackPlanEntry, error) {
var f = func(_, b libcnb.BuildpackPlanEntry) (libcnb.BuildpackPlanEntry, error) {
return b, nil
}

Expand Down Expand Up @@ -165,7 +162,6 @@ func testBuildpackPlan(t *testing.T, context spec.G, it spec.S) {
})

context("Resolve", func() {

it("merges with empty", func() {
a := libcnb.BuildpackPlanEntry{}
b := libcnb.BuildpackPlanEntry{Name: "test-name"}
Expand Down
2 changes: 1 addition & 1 deletion carton/build_image_dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ func (i BuildImageDependency) Update(options ...Option) {
s := fmt.Sprintf(ImageDependencySubstitution, i.Version)
c = r.ReplaceAll(c, []byte(s))

// #nosec G306 - permissions need to be 644 on the builder
if err := os.WriteFile(i.BuilderPath, c, 0644); err != nil {
config.exitHandler.Error(fmt.Errorf("unable to write %s\n%w", i.BuilderPath, err))
return
}

}
2 changes: 1 addition & 1 deletion carton/build_image_dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/paketo-buildpacks/libpak/v2/carton"
)

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

Expand Down
8 changes: 5 additions & 3 deletions carton/buildmodule_dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"regexp"

"github.com/BurntSushi/toml"

"github.com/paketo-buildpacks/libpak/v2/internal"
"github.com/paketo-buildpacks/libpak/v2/log"
)
Expand Down Expand Up @@ -128,16 +129,16 @@ func (b BuildModuleDependency) Update(options ...Option) {
}

for _, dep := range dependencies {
depIdUnwrapped, found := dep["id"]
depIDUnwrapped, found := dep["id"]
if !found {
continue
}
depId, ok := depIdUnwrapped.(string)
depID, ok := depIDUnwrapped.(string)
if !ok {
continue
}

if depId == b.ID {
if depID == b.ID {
depVersionUnwrapped, found := dep["version"]
if !found {
continue
Expand Down Expand Up @@ -186,6 +187,7 @@ func (b BuildModuleDependency) Update(options ...Option) {

c = append(comments, c...)

// #nosec G306 - permissions need to be 644 on the build module
if err := os.WriteFile(b.BuildModulePath, c, 0644); err != nil {
config.exitHandler.Error(fmt.Errorf("unable to write %s\n%w", b.BuildModulePath, err))
return
Expand Down
14 changes: 7 additions & 7 deletions carton/buildmodule_dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ version = "test-version-1"
uri = "test-uri-1"
sha256 = "test-sha256-1"
stacks = [ "test-stack" ]
`), 0644)).To(Succeed())
`), 0600)).To(Succeed())

d := carton.BuildModuleDependency{
BuildModulePath: path,
Expand Down Expand Up @@ -112,7 +112,7 @@ sha256 = "test-sha256-1"
stacks = [ "test-stack" ]
purl = "pkg:generic/test-jre@different-version-1?arch=amd64"
cpes = ["cpe:2.3:a:test-vendor:test-product:test-version-1:patch1:*:*:*:*:*:*:*"]
`), 0644)).To(Succeed())
`), 0600)).To(Succeed())

d := carton.BuildModuleDependency{
BuildModulePath: path,
Expand Down Expand Up @@ -173,7 +173,7 @@ sha256 = "test-sha256-2"
stacks = [ "test-stack" ]
purl = "pkg:generic/test-jre@different-version-2?arch=amd64"
cpes = ["cpe:2.3:a:test-vendor:test-product:test-version-2:patch2:*:*:*:*:*:*:*"]
`), 0644)).To(Succeed())
`), 0600)).To(Succeed())

d := carton.BuildModuleDependency{
BuildModulePath: path,
Expand Down Expand Up @@ -233,7 +233,7 @@ uri = "test-uri-1"
sha256 = "test-sha256-1"
stacks = [ "test-stack" ]
cpes = ["cpe:2.3:a:test-vendor:test-product:test-version-1:patch1:*:*:*:*:*:*:*"]
`), 0644)).To(Succeed())
`), 0600)).To(Succeed())

d := carton.BuildModuleDependency{
BuildModulePath: path,
Expand Down Expand Up @@ -283,7 +283,7 @@ sha256 = "test-sha256-1"
stacks = [ "test-stack" ]
purl = 1234
cpes = ["cpe:2.3:a:test-vendor:test-product:test-version-1:patch1:*:*:*:*:*:*:*"]
`), 0644)).To(Succeed())
`), 0600)).To(Succeed())

d := carton.BuildModuleDependency{
BuildModulePath: path,
Expand Down Expand Up @@ -334,7 +334,7 @@ sha256 = "test-sha256-1"
stacks = [ "test-stack" ]
purl = "pkg:generic/test-jre@different-version-1?arch=amd64"
cpes = 1234
`), 0644)).To(Succeed())
`), 0600)).To(Succeed())

d := carton.BuildModuleDependency{
BuildModulePath: path,
Expand Down Expand Up @@ -387,7 +387,7 @@ version = "1.2.3"
uri = "test-uri-1"
sha256 = "test-sha256-1"
stacks = [ "test-stack" ]
`), 0644)).To(Succeed())
`), 0600)).To(Succeed())

d := carton.BuildModuleDependency{
BuildModulePath: path,
Expand Down
2 changes: 1 addition & 1 deletion carton/lifecycle_dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ func (l LifecycleDependency) Update(options ...Option) {
s := fmt.Sprintf(LifecycleDependencySubstitution, l.Version)
c = r.ReplaceAll(c, []byte(s))

// #nosec G306 - permissions need to be 644 on the builder
if err := os.WriteFile(l.BuilderPath, c, 0644); err != nil {
config.exitHandler.Error(fmt.Errorf("unable to write %s\n%w", l.BuilderPath, err))
return
}

}
2 changes: 1 addition & 1 deletion carton/lifecycle_dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/paketo-buildpacks/libpak/v2/carton"
)

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

Expand Down
2 changes: 1 addition & 1 deletion carton/netrc.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func ParseNetrc(path string) (Netrc, error) {
i += 2
case "default":
l = NetrcLine{Machine: "default"}
i += 1
i++
case "login":
l.Login = f[i+1]
i += 2
Expand Down
8 changes: 4 additions & 4 deletions carton/netrc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func testNetrc(t *testing.T, context spec.G, it spec.S) {

context("parse", func() {
it("parses one-liner", func() {
Expect(os.WriteFile(path, []byte(`machine test-machine login test-login password test-password`), 0644)).To(Succeed())
Expect(os.WriteFile(path, []byte(`machine test-machine login test-login password test-password`), 0600)).To(Succeed())

Expect(carton.ParseNetrc(path)).To(Equal(carton.Netrc{
{
Expand All @@ -90,7 +90,7 @@ func testNetrc(t *testing.T, context spec.G, it spec.S) {
machine test-machine
login test-login
password test-password
`), 0644)).To(Succeed())
`), 0600)).To(Succeed())

Expect(carton.ParseNetrc(path)).To(Equal(carton.Netrc{
{
Expand All @@ -110,7 +110,7 @@ macdef uploadtest
quit
machine test-machine login test-login password test-password
`), 0644)).To(Succeed())
`), 0600)).To(Succeed())

Expect(carton.ParseNetrc(path)).To(Equal(carton.Netrc{
{
Expand All @@ -130,7 +130,7 @@ login test-login-2
password test-password-2
machine test-machine-3 login test-login-3 password test-password-3
`), 0644)).To(Succeed())
`), 0600)).To(Succeed())

Expect(carton.ParseNetrc(path)).To(Equal(carton.Netrc{
{
Expand Down
8 changes: 5 additions & 3 deletions carton/package_dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"strings"

"github.com/BurntSushi/toml"

"github.com/paketo-buildpacks/libpak/v2/internal"
"github.com/paketo-buildpacks/libpak/v2/log"
)
Expand Down Expand Up @@ -92,17 +93,17 @@ func (p PackageDependency) Update(options ...Option) {
continue
}

bpIdUnwrappd, found := bp["id"]
bpIDUnwrappd, found := bp["id"]
if !found {
continue
}

bpId, ok := bpIdUnwrappd.(string)
bpID, ok := bpIDUnwrappd.(string)
if !ok {
continue
}

if bpId == id {
if bpID == id {
bp["version"] = p.Version
}
}
Expand Down Expand Up @@ -180,6 +181,7 @@ func updateFile(cfgPath string, f func(md map[string]interface{})) error {

b = append(comments, b...)

// #nosec G306 - permissions need to be 644 on the package
if err := os.WriteFile(cfgPath, b, 0644); err != nil {
return fmt.Errorf("unable to write %s\n%w", cfgPath, err)
}
Expand Down
Loading

0 comments on commit 993c7bb

Please sign in to comment.