heroku / cnb-shim

This is a shim to run old buildpacks as Cloud Native Buildpacks
MIT License
1 stars 0 forks source link

Update Buildpack API from 0.4 to 0.8 #66

Closed edmorley closed 1 year ago

edmorley commented 1 year ago

Buildpack API 0.4 has been deprecated in lifecycle 0.16.0, and so the CNBs generated by cnb-shim currently result in deprecation warnings:

eg:

===> DETECTING
Warning: Buildpack 'heroku/ruby@0.0.0' requests deprecated API '0.4'
Warning: Buildpack 'heroku/clojure@0.0.0' requests deprecated API '0.4'
Warning: Buildpack 'heroku/python@0.0.0' requests deprecated API '0.4'
Warning: Buildpack 'heroku/java@0.0.0' requests deprecated API '0.4'
Warning: Buildpack 'heroku/gradle@0.0.0' requests deprecated API '0.4'
Warning: Buildpack 'heroku/scala@0.0.0' requests deprecated API '0.4'
Warning: Buildpack 'heroku/php@0.0.0' requests deprecated API '0.4'
Warning: Buildpack 'heroku/go@0.0.0' requests deprecated API '0.4'
Warning: Buildpack 'heroku/nodejs@0.0.0' requests deprecated API '0.4'

From: https://github.com/heroku/builder/actions/runs/4670233967/jobs/8269751652#step:9:9

As such, the default Buildpack API version has been increased from 0.4 to 0.8. This required adding the [types] table to the layer TOML files, per: https://github.com/buildpacks/rfcs/blob/main/text/0074-layer-table.md

The Buildpack API hasn't been updated even further (to 0.9), since that will require further changes due to the removal of implicit bash support and direct = false, and 0.8 isn't deprecated so is fine to use for now.

Changes: https://github.com/buildpacks/spec/releases/tag/buildpack%2Fv0.5 https://github.com/buildpacks/spec/releases/tag/buildpack%2Fv0.6 https://github.com/buildpacks/spec/releases/tag/buildpack%2Fv0.7 https://github.com/buildpacks/spec/releases/tag/buildpack%2Fv0.8

GUS-W-12541119.

edmorley commented 1 year ago

Tested manually (since no integration tests exist for this project):

$ pack build --buildpack 'https://cnb-shim-edmorley-build-kst6yc.herokuapp.com/v1/heroku/python?version=0.0.0&name=Python' shim-test
...
===> ANALYZING
Previous image with name "shim-test" not found
===> DETECTING
heroku/python 0.0.0
===> RESTORING
===> BUILDING
-----> Using Python version specified in runtime.txt
-----> Installing python-3.11.3
-----> Installing pip 23.0.1, setuptools 67.6.1 and wheel 0.40.0
-----> Installing SQLite3
-----> Installing requirements with pip
       Collecting typing-extensions==4.4.0
         Downloading typing_extensions-4.4.0-py3-none-any.whl (26 kB)
       Installing collected packages: typing-extensions
       Successfully installed typing-extensions-4.4.0
===> EXPORTING
Adding layer 'heroku/python:profile'
Adding layer 'buildpacksio/lifecycle:launch.sbom'
Adding 1/1 app layer(s)
Adding layer 'buildpacksio/lifecycle:launcher'
Adding layer 'buildpacksio/lifecycle:config'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
no default process type
Saving shim-test...
*** Images (a560cc443d2f):
      shim-test
Adding cache layer 'heroku/python:shim'
Successfully built image shim-test

And then the cached rebuild case:

$ pack build --buildpack 'https://cnb-shim-edmorley-build-kst6yc.herokuapp.com/v1/heroku/python?version=0.0.0&name=Python' shim-test
...
===> ANALYZING
Restoring data for SBOM from previous image
===> DETECTING
heroku/python 0.0.0
===> RESTORING
Restoring metadata for "heroku/python:shim" from cache
Restoring data for "heroku/python:shim" from cache
===> BUILDING
-----> Using Python version specified in runtime.txt
-----> No change in requirements detected, installing from cache
-----> Using cached install of python-3.11.3
-----> Installing pip 23.0.1, setuptools 67.6.1 and wheel 0.40.0
-----> Installing SQLite3
-----> Installing requirements with pip
===> EXPORTING
Reusing layer 'heroku/python:profile'
Reusing layer 'buildpacksio/lifecycle:launch.sbom'
Adding 1/1 app layer(s)
Reusing layer 'buildpacksio/lifecycle:launcher'
Reusing layer 'buildpacksio/lifecycle:config'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
no default process type
Saving shim-test...
*** Images (1514519ae91a):
      shim-test
Adding cache layer 'heroku/python:shim'
Successfully built image shim-test
edmorley commented 1 year ago

This has been deployed to staging + production CNB shim.

Retrigger of heroku/builder CI run, showing all passing: https://github.com/heroku/builder/actions/runs/4676696475

And showing no deprecation warnings any more: https://github.com/heroku/builder/actions/runs/4676696475/jobs/8283356528#step:9:9

edmorley commented 1 year ago

This has since been reverted in #68.