Skip to content

Commit

Permalink
Add arm64 architecture support (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
Malax authored May 23, 2024
1 parent 0d93da6 commit 097a25d
Show file tree
Hide file tree
Showing 41 changed files with 503 additions and 334 deletions.
48 changes: 28 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,46 @@ jobs:
run: cargo test --locked

integration-test:
name: Integration Tests (${{ matrix.buildpack-directory }})
runs-on: pub-hk-ubuntu-22.04-large
needs: gather-repo-metadata
name: Integration Tests (${{ matrix.buildpack-directory }}, ${{matrix.builder}}, ${{matrix.arch}})
runs-on: ${{ matrix.arch == 'arm64' && 'pub-hk-ubuntu-22.04-arm-large' || 'pub-hk-ubuntu-22.04-large' }}
strategy:
fail-fast: false
matrix:
buildpack-directory: ${{ fromJson(needs.gather-repo-metadata.outputs.buildpack_dirs) }}
builder: [ "builder:24", "builder:22", "builder:20" ]
arch: [ "amd64", "arm64" ]
buildpack-directory: [ "buildpacks/gradle", "buildpacks/jvm", "buildpacks/jvm-function-invoker", "buildpacks/maven", "buildpacks/sbt" ]
exclude:
- builder: "builder:22"
arch: "arm64"
- builder: "builder:20"
arch: "arm64"
- buildpack-directory: "buildpacks/jvm-function-invoker"
builder: "builder:20"
- buildpack-directory: "buildpacks/jvm-function-invoker"
builder: "builder:24"
env:
INTEGRATION_TEST_BUILDER: heroku/${{ matrix.builder }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
# The beta ARM64 runners don't yet ship with the normal installed tools.
- name: Install Docker, Rust and missing development libs (ARM64 only)
if: matrix.arch == 'arm64'
run: |
sudo apt-get update --error-on=any
sudo apt-get install -y --no-install-recommends acl docker.io docker-buildx libc6-dev
sudo usermod -aG docker $USER
sudo setfacl --modify user:$USER:rw /var/run/docker.sock
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
echo "${HOME}/.cargo/bin" >> "${GITHUB_PATH}"
- name: Install musl-tools
run: sudo apt-get install musl-tools --no-install-recommends
run: sudo apt-get install -y --no-install-recommends musl-tools
- name: Update Rust toolchain
run: rustup update
- name: Install Rust linux-musl target
run: rustup target add x86_64-unknown-linux-musl
run: rustup target add ${{ matrix.arch == 'arm64' && 'aarch64-unknown-linux-musl' || 'x86_64-unknown-linux-musl' }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Install Pack CLI
Expand All @@ -72,17 +94,3 @@ jobs:
working-directory: ${{ matrix.buildpack-directory }}
# Runs only tests annotated with the `ignore` attribute (which in this repo, are the integration tests).
run: cargo test --locked -- --ignored --test-threads 16

gather-repo-metadata:
name: "Gather Repository Metadata"
runs-on: ubuntu-22.04
outputs:
buildpack_dirs: ${{ steps.find-buildpack-dirs.outputs.buildpack_dirs }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- id: find-buildpack-dirs
name: Find buildpack directories
run: echo "buildpack_dirs=$(find . -type f -name 'buildpack.toml' -exec dirname {} \; | grep -v './meta-buildpacks' | sort | uniq | jq -nRc '[inputs]')" >> $GITHUB_OUTPUT
4 changes: 4 additions & 0 deletions buildpacks/gradle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Support for the `arm64` architecture. ([#668](https://github.com/heroku/buildpacks-jvm/pull/668))

### Changed

- Buildpack API version changed from `0.9` to `0.10`, and so requires `lifecycle` `0.17.x` or newer. ([#662](https://github.com/heroku/buildpacks-jvm/pull/662))
Expand Down
4 changes: 4 additions & 0 deletions buildpacks/gradle/buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ id = "*"
os = "linux"
arch = "amd64"

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

[metadata.release]
image = { repository = "docker.io/heroku/buildpack-gradle" }
32 changes: 26 additions & 6 deletions buildpacks/gradle/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,35 @@
// Required due to: https://github.com/rust-lang/rust/issues/95513
#![allow(unused_crate_dependencies)]

use libcnb_test::BuildpackReference;
use libcnb::data::buildpack_id;
use libcnb_test::{BuildConfig, BuildpackReference};
use std::path::Path;

mod smoke;
mod ux;

fn default_buildpacks() -> Vec<BuildpackReference> {
vec![
BuildpackReference::Other(String::from("heroku/jvm")),
fn default_build_config(fixture_path: impl AsRef<Path>) -> BuildConfig {
let builder = builder();

// TODO: Once Pack build supports `--platform` and libcnb-test adjusted accordingly, change this
// to allow configuring the target arch independently of the builder name (eg via env var).
let target_triple = match builder.as_str() {
// Compile the buildpack for ARM64 iff the builder supports multi-arch and the host is ARM64.
"heroku/builder:24" if cfg!(target_arch = "aarch64") => "aarch64-unknown-linux-musl",
_ => "x86_64-unknown-linux-musl",
};

let mut config = BuildConfig::new(&builder, fixture_path);
config.target_triple(target_triple);
config.buildpacks(vec![
BuildpackReference::WorkspaceBuildpack(buildpack_id!("heroku/jvm")),
BuildpackReference::CurrentCrate,
BuildpackReference::Other(String::from("heroku/procfile")),
]
]);
config
}

fn builder() -> String {
std::env::var("INTEGRATION_TEST_BUILDER").unwrap_or(String::from(DEFAULT_BUILDER))
}

const DEFAULT_BUILDER: &str = "heroku/builder:24";
8 changes: 3 additions & 5 deletions buildpacks/gradle/tests/integration/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
//!
//! These tests are strictly happy-path tests and do not assert any output of the buildpack.
use crate::default_buildpacks;
use buildpacks_jvm_shared_test::{smoke_test, DEFAULT_INTEGRATION_TEST_BUILDER};
use crate::default_build_config;
use buildpacks_jvm_shared_test::smoke_test;

#[test]
#[ignore = "integration test"]
fn smoke_test_getting_started_guide() {
smoke_test(
DEFAULT_INTEGRATION_TEST_BUILDER,
"test-apps/heroku-gradle-getting-started",
default_buildpacks(),
&default_build_config("test-apps/heroku-gradle-getting-started"),
"Getting Started with Gradle on Heroku",
);
}
31 changes: 0 additions & 31 deletions buildpacks/gradle/tests/integration/ux.rs

This file was deleted.

31 changes: 31 additions & 0 deletions buildpacks/jvm-function-invoker/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,35 @@
// Required due to: https://github.com/rust-lang/rust/issues/95513
#![allow(unused_crate_dependencies)]

use libcnb::data::buildpack_id;
use libcnb_test::{BuildConfig, BuildpackReference};
use std::path::Path;

mod smoke;

fn default_build_config(fixture_path: impl AsRef<Path>) -> BuildConfig {
let builder = builder();

// TODO: Once Pack build supports `--platform` and libcnb-test adjusted accordingly, change this
// to allow configuring the target arch independently of the builder name (eg via env var).
let target_triple = match builder.as_str() {
// Compile the buildpack for ARM64 iff the builder supports multi-arch and the host is ARM64.
"heroku/builder:24" if cfg!(target_arch = "aarch64") => "aarch64-unknown-linux-musl",
_ => "x86_64-unknown-linux-musl",
};

let mut config = BuildConfig::new(&builder, fixture_path);
config.target_triple(target_triple);
config.buildpacks(vec![
BuildpackReference::WorkspaceBuildpack(buildpack_id!("heroku/jvm")),
BuildpackReference::WorkspaceBuildpack(buildpack_id!("heroku/maven")),
BuildpackReference::CurrentCrate,
]);
config
}

fn builder() -> String {
std::env::var("INTEGRATION_TEST_BUILDER").unwrap_or(String::from(DEFAULT_BUILDER))
}

const DEFAULT_BUILDER: &str = "heroku/builder:24";
12 changes: 4 additions & 8 deletions buildpacks/jvm-function-invoker/tests/integration/smoke.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
use crate::default_build_config;
use base64::Engine;
use buildpacks_jvm_shared_test::{
DEFAULT_INTEGRATION_TEST_BUILDER, UREQ_RESPONSE_AS_STRING_EXPECT_MESSAGE,
UREQ_RESPONSE_RESULT_EXPECT_MESSAGE,
UREQ_RESPONSE_AS_STRING_EXPECT_MESSAGE, UREQ_RESPONSE_RESULT_EXPECT_MESSAGE,
};
use libcnb_test::{BuildConfig, BuildpackReference, ContainerConfig, TestRunner};
use libcnb_test::{ContainerConfig, TestRunner};
use std::time::Duration;

#[test]
#[ignore = "integration test"]
fn smoke_test_simple_function() {
TestRunner::default().build(
BuildConfig::new(DEFAULT_INTEGRATION_TEST_BUILDER, "test-apps/simple-function").buildpacks([
BuildpackReference::Other(String::from("heroku/jvm")),
BuildpackReference::Other(String::from("heroku/maven")),
BuildpackReference::CurrentCrate,
]),
default_build_config("test-apps/simple-function"),
|context| {
context.start_container(
ContainerConfig::new()
Expand Down
6 changes: 5 additions & 1 deletion buildpacks/jvm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Support for the `arm64` architecture. ([#668](https://github.com/heroku/buildpacks-jvm/pull/668))

### Changed

- Buildpack API version changed from `0.9` to `0.10`, and so requires `lifecycle` `0.17.x` or newer. ([#662](https://github.com/heroku/buildpacks-jvm/pull/662))
- This buildpack is no longer Heroku stack specific and can be used with most x86 Linux based CNB build and run images. ([#662](https://github.com/heroku/buildpacks-jvm/pull/662))
- This buildpack is no longer Heroku stack specific and can be used with most `amd64` or `arm64` Linux based CNB build and run images. ([#662](https://github.com/heroku/buildpacks-jvm/pull/662))
- Default OpenJDK distribution is now always Azul® Zulu®. ([#662](https://github.com/heroku/buildpacks-jvm/pull/662))
- Some error messages relating to OpenJDK installation changed. ([#665](https://github.com/heroku/buildpacks-jvm/pull/665))
- OpenJDK is now downloaded from `heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com`. Users that use allow-listing for internet access during builds might need to add this new URL to their allow-list. ([#665](https://github.com/heroku/buildpacks-jvm/pull/665))
Expand Down
4 changes: 4 additions & 0 deletions buildpacks/jvm/buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ id = "*"
os = "linux"
arch = "amd64"

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

[metadata.heroku-metrics-agent]
url = "https://repo1.maven.org/maven2/com/heroku/agent/heroku-java-metrics-agent/4.0.1/heroku-java-metrics-agent-4.0.1.jar"
sha256 = "9a718680e4a93f93a8755b20fb21cc541e5c2692acc9da27c667530f48a716db"
Expand Down
43 changes: 42 additions & 1 deletion buildpacks/jvm/openjdk_inventory.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ url = "https://heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com/openjdk/zulu/amd
checksum = "sha256:739a1707b8fe24798ae8793667263b2d283d61b7958a576808b38a34fbd79ef1"
metadata.distribution = "zulu"

[[artifacts]]
version = "1.8.0_412"
os = "linux"
arch = "arm64"
url = "https://heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com/openjdk/zulu/arm64/1.8.0_412.tar.gz"
checksum = "sha256:9189e22cdef4d80f74e4415c4ad82ac0669b8ca1a4afad1ba132e2035f29f53c"
metadata.distribution = "zulu"

[[artifacts]]
version = "11.0.10"
os = "linux"
Expand Down Expand Up @@ -278,12 +286,20 @@ url = "https://heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com/openjdk/zulu/amd
checksum = "sha256:b8278982c689cab951ef4daf60a6690f0aef671bbd13ead4f467e2d27e8af034"
metadata.distribution = "zulu"

[[artifacts]]
version = "11.0.23"
os = "linux"
arch = "arm64"
url = "https://heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com/openjdk/zulu/arm64/11.0.23.tar.gz"
checksum = "sha256:7ab8f4ff3f1c675d8ca9a904f5d3657afcb59b6d852c4c1b2c5988a2854896cd"
metadata.distribution = "zulu"

[[artifacts]]
version = "11.0.23"
os = "linux"
arch = "amd64"
url = "https://heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com/openjdk/zulu/amd64/11.0.23.tar.gz"
checksum = "sha256:7ab8f4ff3f1c675d8ca9a904f5d3657afcb59b6d852c4c1b2c5988a2854896cd"
checksum = "sha256:5b8b551785c4f23417c10feba5e0342af300f491cb7f4c62c7ed84fd37857960"
metadata.distribution = "zulu"

[[artifacts]]
Expand Down Expand Up @@ -342,6 +358,14 @@ url = "https://heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com/openjdk/zulu/amd
checksum = "sha256:474a59b57d194cf1e1189f51f14325b3be46001cf41b4246cee68a7cef29ddeb"
metadata.distribution = "zulu"

[[artifacts]]
version = "17.0.11"
os = "linux"
arch = "arm64"
url = "https://heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com/openjdk/zulu/arm64/17.0.11.tar.gz"
checksum = "sha256:e406854386e38f35a9529a14d1262f9db082afa3bef331f755943922c2f0f091"
metadata.distribution = "zulu"

[[artifacts]]
version = "17.0.2"
os = "linux"
Expand Down Expand Up @@ -454,6 +478,15 @@ url = "https://heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com/openjdk/zulu/amd
checksum = "sha256:057674a3aff2110a5e11187ecb57ed1342efa89fab63587b20cd3785e374b9b8"
metadata.distribution = "zulu"

[[artifacts]]
version = "21.0.3"
os = "linux"
arch = "arm64"
url = "https://heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com/openjdk/zulu/arm64/21.0.3.tar.gz"
checksum = "sha256:02968e30fb3037a89e89a9d4e56e39918db8e5118893e42bf4c880e9779027dc"
metadata.distribution = "zulu"


[[artifacts]]
version = "22.0.0"
os = "linux"
Expand All @@ -469,3 +502,11 @@ arch = "amd64"
url = "https://heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com/openjdk/zulu/amd64/22.0.1.tar.gz"
checksum = "sha256:44a1a5883f1c67a59e5dafcef0538c09e09ac849dfb24e1088f9529080c1fd43"
metadata.distribution = "zulu"

[[artifacts]]
version = "22.0.1"
os = "linux"
arch = "arm64"
url = "https://heroku-buildpacks-jvm.s3.us-east-1.amazonaws.com/openjdk/zulu/arm64/22.0.1.tar.gz"
checksum = "sha256:263f1773515a42d1ae85a4c911530f4af6e4dabe466a386a9698e922c94e950f"
metadata.distribution = "zulu"
1 change: 1 addition & 0 deletions buildpacks/jvm/test-apps/java-11-app/system.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java.runtime.version = 11
1 change: 1 addition & 0 deletions buildpacks/jvm/test-apps/java-17-app/system.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java.runtime.version = 17
1 change: 1 addition & 0 deletions buildpacks/jvm/test-apps/java-21-app/system.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java.runtime.version = 21
1 change: 1 addition & 0 deletions buildpacks/jvm/test-apps/java-22-app/system.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java.runtime.version = 22
25 changes: 25 additions & 0 deletions buildpacks/jvm/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,29 @@
// Required due to: https://github.com/rust-lang/rust/issues/95513
#![allow(unused_crate_dependencies)]

use libcnb_test::BuildConfig;
use std::path::Path;

mod versions;

fn default_build_config(fixture_path: impl AsRef<Path>) -> BuildConfig {
let builder = builder();

// TODO: Once Pack build supports `--platform` and libcnb-test adjusted accordingly, change this
// to allow configuring the target arch independently of the builder name (eg via env var).
let target_triple = match builder.as_str() {
// Compile the buildpack for ARM64 iff the builder supports multi-arch and the host is ARM64.
"heroku/builder:24" if cfg!(target_arch = "aarch64") => "aarch64-unknown-linux-musl",
_ => "x86_64-unknown-linux-musl",
};

let mut config = BuildConfig::new(&builder, fixture_path);
config.target_triple(target_triple);
config
}

fn builder() -> String {
std::env::var("INTEGRATION_TEST_BUILDER").unwrap_or(String::from(DEFAULT_BUILDER))
}

const DEFAULT_BUILDER: &str = "heroku/builder:24";
Loading

0 comments on commit 097a25d

Please sign in to comment.