Skip to content

Commit

Permalink
Merge branch 'main' into corrupted-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
natalieparellano committed Jul 17, 2024
2 parents 289442a + a87e12e commit 39f37e7
Show file tree
Hide file tree
Showing 36 changed files with 700 additions and 389 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ jobs:
with:
name: lifecycle-bom-cdx-sha256
path: lifecycle-v*-bom.cdx.json.sha256
- uses: azure/docker-login@v1
- uses: azure/docker-login@v2
if: github.event_name == 'push'
with:
username: ${{ secrets.DOCKER_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
go install github.com/google/go-containerregistry/cmd/crane@latest
- name: Install cosign
uses: sigstore/cosign-installer@v3
- uses: azure/docker-login@v1
- uses: azure/docker-login@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-s390x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ jobs:
id: ZVSI
run: |
#creation of zvsi
ibmcloud is instance-create $ZVSI_INSTANCE_NAME ${{ secrets.ZVSI_VPC }} $ZVSI_ZONE_NAME $ZVSI_PROFILE_NAME ${{ secrets.ZVSI_SUBNET }} --image ${{ secrets.ZVSI_IMAGE }} --keys ${{ secrets.ZVSI_KEY }} --resource-group-id ${{ secrets.ZVSI_RG_ID }} --sgs ${{ secrets.ZVSI_SG }}
ibmcloud is instance-create $ZVSI_INSTANCE_NAME ${{ secrets.ZVSI_VPC }} $ZVSI_ZONE_NAME $ZVSI_PROFILE_NAME ${{ secrets.ZVSI_SUBNET }} --image ${{ secrets.ZVSI_IMAGE }} --keys ${{ secrets.ZVSI_KEY }} --resource-group-id ${{ secrets.ZVSI_RG_ID }} --primary-network-interface "{\"name\":\"eth0\",\"allow_ip_spoofing\":false,\"subnet\": {\"name\":\"${{ secrets.ZVSI_SUBNET }}\"},\"security_groups\":[{\"id\":\"${{ secrets.ZVSI_SG }}\"}]}"
#Reserving a floating ip to the ZVSI
ibmcloud is floating-ip-reserve $ZVSI_FP_NAME --zone $ZVSI_ZONE_NAME --resource-group-id ${{ secrets.ZVSI_RG_ID }} --in $ZVSI_INSTANCE_NAME
#Bouding the Floating ip to the ZVSI
ibmcloud is floating-ip-update $ZVSI_FP_NAME --nic primary --in $ZVSI_INSTANCE_NAME
ibmcloud is floating-ip-update $ZVSI_FP_NAME --nic eth0 --in $ZVSI_INSTANCE_NAME
sleep 60
#Saving the Floating IP to login ZVSI
ZVSI_HOST=$(ibmcloud is floating-ip $ZVSI_FP_NAME | awk '/Address/{print $2}')
Expand Down
2 changes: 1 addition & 1 deletion acceptance/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func testAnalyzerFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
output, err := cmd.CombinedOutput()

h.AssertNotNil(t, err)
expected := "validating registry write access: ensure registry read/write access to " + analyzeRegFixtures.InaccessibleImage
expected := "ensure registry read/write access to " + analyzeRegFixtures.InaccessibleImage
h.AssertStringContains(t, string(output), expected)
})
})
Expand Down
2 changes: 1 addition & 1 deletion acceptance/testdata/detector/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:bionic
FROM ubuntu:jammy

ARG cnb_uid=1234
ARG cnb_gid=1000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
api = "0.10"
api = "0.9"

[buildpack]
id = "simple_buildpack"
version = "simple_buildpack_version"
name = "Simple Buildpack"
id = "simple_buildpack"
version = "simple_buildpack_version"
name = "Simple Buildpack"

[[stacks]]
id = "io.buildpacks.stacks.bionic"

[[stacks]]
id = "io.buildpacks.stacks.jammy"
2 changes: 1 addition & 1 deletion api/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var (
// Platform is a pair of lists of Platform API versions:
// 1. All supported versions (including deprecated versions)
// 2. The versions that are deprecated
Platform = newApisMustParse([]string{"0.7", "0.8", "0.9", "0.10", "0.11", "0.12", "0.13"}, []string{})
Platform = newApisMustParse([]string{"0.7", "0.8", "0.9", "0.10", "0.11", "0.12", "0.13", "0.14"}, []string{})
// Buildpack is a pair of lists of Buildpack API versions:
// 1. All supported versions (including deprecated versions)
// 2. The versions that are deprecated
Expand Down
7 changes: 5 additions & 2 deletions buildpack/bp_descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/BurntSushi/toml"

"github.com/buildpacks/lifecycle/api"
"github.com/buildpacks/lifecycle/internal/encoding"
)

Expand All @@ -17,7 +18,7 @@ type BpDescriptor struct {
Order Order `toml:"order"`
WithRootDir string `toml:"-"`
Targets []TargetMetadata `toml:"targets"`
Stacks []StackMetadata `tome:"stacks"` // just for backwards compat so we can check if it's the bionic stack, which we translate to a target
Stacks []StackMetadata `toml:"stacks"` // just for backwards compat so we can check if it's the bionic stack, which we translate to a target

}

Expand Down Expand Up @@ -69,7 +70,9 @@ func ReadBpDescriptor(path string) (*BpDescriptor, error) {
if len(descriptor.Targets) == 0 {
for _, stack := range descriptor.Stacks {
if stack.ID == "io.buildpacks.stacks.bionic" {
descriptor.Targets = append(descriptor.Targets, TargetMetadata{OS: "linux", Arch: "amd64", Distros: []OSDistro{{Name: "ubuntu", Version: "18.04"}}})
if api.MustParse(descriptor.API()).AtLeast("0.10") || len(descriptor.Stacks) == 1 {
descriptor.Targets = append(descriptor.Targets, TargetMetadata{OS: "linux", Arch: "amd64", Distros: []OSDistro{{Name: "ubuntu", Version: "18.04"}}})
}
} else if stack.ID == "*" {
descriptor.Targets = append(descriptor.Targets, TargetMetadata{}) // matches any
}
Expand Down
170 changes: 133 additions & 37 deletions buildpack/bp_descriptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,44 +81,140 @@ func testBpDescriptor(t *testing.T, when spec.G, it spec.S) {
h.AssertEq(t, descriptor.Targets[0].Distros[0].Version, "V8.4-2L3")
})

it("does translate one special stack value into target values for older apis", func() {
path := filepath.Join("testdata", "buildpack", "by-id", "B", "v1", "buildpack.toml")
descriptor, err := buildpack.ReadBpDescriptor(path)
h.AssertNil(t, err)
// common sanity checks
h.AssertEq(t, descriptor.WithAPI, "0.7")
h.AssertEq(t, descriptor.Buildpack.ID, "B")
h.AssertEq(t, descriptor.Buildpack.Name, "Buildpack B")
h.AssertEq(t, descriptor.Buildpack.Version, "v1")
h.AssertEq(t, descriptor.Buildpack.Homepage, "Buildpack B Homepage")
h.AssertEq(t, descriptor.Buildpack.SBOM, []string{"application/vnd.cyclonedx+json"})
// specific behaviors for this test
h.AssertEq(t, descriptor.Stacks[0].ID, "io.buildpacks.stacks.bionic")
h.AssertEq(t, len(descriptor.Targets), 1)
h.AssertEq(t, descriptor.Targets[0].Arch, "amd64")
h.AssertEq(t, descriptor.Targets[0].OS, "linux")
h.AssertEq(t, descriptor.Targets[0].Distros[0].Name, "ubuntu")
h.AssertEq(t, descriptor.Targets[0].Distros[0].Version, "18.04")
})
when("translating stacks to targets", func() {
when("older buildpacks", func() {
when("there is only bionic", func() {
it("creates a target", func() {
path := filepath.Join("testdata", "buildpack", "by-id", "B", "v1", "buildpack.toml")
descriptor, err := buildpack.ReadBpDescriptor(path)
h.AssertNil(t, err)
// common sanity checks
h.AssertEq(t, descriptor.WithAPI, "0.7")
h.AssertEq(t, descriptor.Buildpack.ID, "B")
h.AssertEq(t, descriptor.Buildpack.Name, "Buildpack B")
h.AssertEq(t, descriptor.Buildpack.Version, "v1")
h.AssertEq(t, descriptor.Buildpack.Homepage, "Buildpack B Homepage")
h.AssertEq(t, descriptor.Buildpack.SBOM, []string{"application/vnd.cyclonedx+json"})
// specific behaviors for this test
h.AssertEq(t, descriptor.Stacks[0].ID, "io.buildpacks.stacks.bionic")
h.AssertEq(t, len(descriptor.Targets), 1)
h.AssertEq(t, descriptor.Targets[0].Arch, "amd64")
h.AssertEq(t, descriptor.Targets[0].OS, "linux")
h.AssertEq(t, descriptor.Targets[0].Distros[0].Name, "ubuntu")
h.AssertEq(t, descriptor.Targets[0].Distros[0].Version, "18.04")
})
})

it("translates one special stack value into target values", func() {
path := filepath.Join("testdata", "buildpack", "by-id", "B", "v2", "buildpack.toml")
descriptor, err := buildpack.ReadBpDescriptor(path)
h.AssertNil(t, err)
// common sanity checks
h.AssertEq(t, descriptor.WithAPI, "0.12")
h.AssertEq(t, descriptor.Buildpack.ID, "B")
h.AssertEq(t, descriptor.Buildpack.Name, "Buildpack B")
h.AssertEq(t, descriptor.Buildpack.Version, "v1")
h.AssertEq(t, descriptor.Buildpack.Homepage, "Buildpack B Homepage")
h.AssertEq(t, descriptor.Buildpack.SBOM, []string{"application/vnd.cyclonedx+json"})
// specific behaviors for this test
h.AssertEq(t, descriptor.Stacks[0].ID, "io.buildpacks.stacks.bionic")
h.AssertEq(t, len(descriptor.Targets), 1)
h.AssertEq(t, descriptor.Targets[0].Arch, "amd64")
h.AssertEq(t, descriptor.Targets[0].OS, "linux")
h.AssertEq(t, descriptor.Targets[0].Distros[0].Name, "ubuntu")
h.AssertEq(t, descriptor.Targets[0].Distros[0].Version, "18.04")
when("there are multiple stacks", func() {
it("does NOT create a target", func() {
path := filepath.Join("testdata", "buildpack", "by-id", "B", "v1.2", "buildpack.toml")
descriptor, err := buildpack.ReadBpDescriptor(path)
h.AssertNil(t, err)
// common sanity checks
h.AssertEq(t, descriptor.WithAPI, "0.7")
h.AssertEq(t, descriptor.Buildpack.ID, "B")
h.AssertEq(t, descriptor.Buildpack.Name, "Buildpack B")
h.AssertEq(t, descriptor.Buildpack.Version, "v1.2")
h.AssertEq(t, descriptor.Buildpack.Homepage, "Buildpack B Homepage")
h.AssertEq(t, descriptor.Buildpack.SBOM, []string{"application/vnd.cyclonedx+json"})
// specific behaviors for this test
h.AssertEq(t, descriptor.Stacks[0].ID, "io.buildpacks.stacks.bionic")
h.AssertEq(t, len(descriptor.Targets), 0)
})
})

when("there is a wildcard stack", func() {
it("creates a wildcard target", func() {
path := filepath.Join("testdata", "buildpack", "by-id", "B", "v1.star", "buildpack.toml")
descriptor, err := buildpack.ReadBpDescriptor(path)
h.AssertNil(t, err)
// common sanity checks
h.AssertEq(t, descriptor.WithAPI, "0.7")
h.AssertEq(t, descriptor.Buildpack.ID, "B")
h.AssertEq(t, descriptor.Buildpack.Name, "Buildpack B")
h.AssertEq(t, descriptor.Buildpack.Version, "v1.star")
h.AssertEq(t, descriptor.Buildpack.Homepage, "Buildpack B Homepage")
h.AssertEq(t, descriptor.Buildpack.SBOM, []string{"application/vnd.cyclonedx+json"})
// specific behaviors for this test
h.AssertEq(t, descriptor.Stacks[0].ID, "*")
h.AssertEq(t, len(descriptor.Targets), 1)
// a target that is completely empty will always match whatever is the base image target
h.AssertEq(t, descriptor.Targets[0].Arch, "")
h.AssertEq(t, descriptor.Targets[0].OS, "")
h.AssertEq(t, descriptor.Targets[0].ArchVariant, "")
h.AssertEq(t, len(descriptor.Targets[0].Distros), 0)
})
})
})

when("newer buildpacks", func() {
when("there is only bionic", func() {
it("creates a target", func() {
path := filepath.Join("testdata", "buildpack", "by-id", "B", "v2", "buildpack.toml")
descriptor, err := buildpack.ReadBpDescriptor(path)
h.AssertNil(t, err)
// common sanity checks
h.AssertEq(t, descriptor.WithAPI, "0.12")
h.AssertEq(t, descriptor.Buildpack.ID, "B")
h.AssertEq(t, descriptor.Buildpack.Name, "Buildpack B")
h.AssertEq(t, descriptor.Buildpack.Version, "v2")
h.AssertEq(t, descriptor.Buildpack.Homepage, "Buildpack B Homepage")
h.AssertEq(t, descriptor.Buildpack.SBOM, []string{"application/vnd.cyclonedx+json"})
// specific behaviors for this test
h.AssertEq(t, descriptor.Stacks[0].ID, "io.buildpacks.stacks.bionic")
h.AssertEq(t, len(descriptor.Targets), 1)
h.AssertEq(t, descriptor.Targets[0].Arch, "amd64")
h.AssertEq(t, descriptor.Targets[0].OS, "linux")
h.AssertEq(t, descriptor.Targets[0].Distros[0].Name, "ubuntu")
h.AssertEq(t, descriptor.Targets[0].Distros[0].Version, "18.04")
})
})

when("there are multiple stacks", func() {
it("creates a target", func() {
path := filepath.Join("testdata", "buildpack", "by-id", "B", "v2.2", "buildpack.toml")
descriptor, err := buildpack.ReadBpDescriptor(path)
h.AssertNil(t, err)
// common sanity checks
h.AssertEq(t, descriptor.WithAPI, "0.12")
h.AssertEq(t, descriptor.Buildpack.ID, "B")
h.AssertEq(t, descriptor.Buildpack.Name, "Buildpack B")
h.AssertEq(t, descriptor.Buildpack.Version, "v2.2")
h.AssertEq(t, descriptor.Buildpack.Homepage, "Buildpack B Homepage")
h.AssertEq(t, descriptor.Buildpack.SBOM, []string{"application/vnd.cyclonedx+json"})
// specific behaviors for this test
h.AssertEq(t, descriptor.Stacks[0].ID, "io.buildpacks.stacks.bionic")
h.AssertEq(t, len(descriptor.Targets), 1)
h.AssertEq(t, descriptor.Targets[0].Arch, "amd64")
h.AssertEq(t, descriptor.Targets[0].OS, "linux")
h.AssertEq(t, descriptor.Targets[0].Distros[0].Name, "ubuntu")
h.AssertEq(t, descriptor.Targets[0].Distros[0].Version, "18.04")
})
})

when("there is a wildcard stack", func() {
it("creates a wildcard target", func() {
path := filepath.Join("testdata", "buildpack", "by-id", "B", "v2.star", "buildpack.toml")
descriptor, err := buildpack.ReadBpDescriptor(path)
h.AssertNil(t, err)
// common sanity checks
h.AssertEq(t, descriptor.WithAPI, "0.12")
h.AssertEq(t, descriptor.Buildpack.ID, "B")
h.AssertEq(t, descriptor.Buildpack.Name, "Buildpack B")
h.AssertEq(t, descriptor.Buildpack.Version, "v2.star")
h.AssertEq(t, descriptor.Buildpack.Homepage, "Buildpack B Homepage")
h.AssertEq(t, descriptor.Buildpack.SBOM, []string{"application/vnd.cyclonedx+json"})
// specific behaviors for this test
h.AssertEq(t, descriptor.Stacks[0].ID, "*")
h.AssertEq(t, len(descriptor.Targets), 1)
// a target that is completely empty will always match whatever is the base image target
h.AssertEq(t, descriptor.Targets[0].Arch, "")
h.AssertEq(t, descriptor.Targets[0].OS, "")
h.AssertEq(t, descriptor.Targets[0].ArchVariant, "")
h.AssertEq(t, len(descriptor.Targets[0].Distros), 0)
})
})
})
})

it("does not translate non-special stack values", func() {
Expand Down
2 changes: 1 addition & 1 deletion buildpack/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
filepath.Join(appDir, "launch-A-v1.toml"),
)
_, err := executor.Build(descriptor, inputs, logger)
h.AssertError(t, err, "toml: line 2 (last key \"processes.command\"): incompatible types: TOML value has type []interface {}; destination has type string")
h.AssertError(t, err, "toml: line 2 (last key \"processes.command\"): incompatible types: TOML value has type []any; destination has type string")
})
})
})
Expand Down
14 changes: 14 additions & 0 deletions buildpack/testdata/buildpack/by-id/B/v1.2/buildpack.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
api = "0.7"

[buildpack]
id = "B"
name = "Buildpack B"
version = "v1.2"
homepage = "Buildpack B Homepage"
sbom-formats = ["application/vnd.cyclonedx+json"]

[[stacks]]
id = "io.buildpacks.stacks.bionic"

[[stacks]]
id = "io.buildpacks.stacks.jammy"
11 changes: 11 additions & 0 deletions buildpack/testdata/buildpack/by-id/B/v1.star/buildpack.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
api = "0.7"

[buildpack]
id = "B"
name = "Buildpack B"
version = "v1.star"
homepage = "Buildpack B Homepage"
sbom-formats = ["application/vnd.cyclonedx+json"]

[[stacks]]
id = "*"
14 changes: 14 additions & 0 deletions buildpack/testdata/buildpack/by-id/B/v2.2/buildpack.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
api = "0.12"

[buildpack]
id = "B"
name = "Buildpack B"
version = "v2.2"
homepage = "Buildpack B Homepage"
sbom-formats = ["application/vnd.cyclonedx+json"]

[[stacks]]
id = "io.buildpacks.stacks.bionic"

[[stacks]]
id = "io.buildpacks.stacks.jammy"
11 changes: 11 additions & 0 deletions buildpack/testdata/buildpack/by-id/B/v2.star/buildpack.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
api = "0.12"

[buildpack]
id = "B"
name = "Buildpack B"
version = "v2.star"
homepage = "Buildpack B Homepage"
sbom-formats = ["application/vnd.cyclonedx+json"]

[[stacks]]
id = "*"
2 changes: 1 addition & 1 deletion buildpack/testdata/buildpack/by-id/B/v2/buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ api = "0.12"
[buildpack]
id = "B"
name = "Buildpack B"
version = "v1"
version = "v2"
homepage = "Buildpack B Homepage"
sbom-formats = ["application/vnd.cyclonedx+json"]

Expand Down
Loading

0 comments on commit 39f37e7

Please sign in to comment.