From 73dbac23de6e0c527044e4b8b64470f9f79ff7ef Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Tue, 4 Jun 2024 18:19:21 +0200 Subject: [PATCH 1/2] Support Ubuntu 24.04 / heroku-24 (amd64 and arm64) GUS-W-14667552 GUS-W-15158300 --- .github/workflows/ci.yml | 14 ++++++++++---- buildpacks/php/CHANGELOG.md | 2 ++ buildpacks/php/buildpack.toml | 12 ++++++++++++ buildpacks/php/src/platform.rs | 2 +- buildpacks/php/tests/integration/utils.rs | 12 ++++++++++-- 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a67f03..71ce487 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,11 +41,17 @@ jobs: run: cargo test --locked integration-test: - runs-on: ubuntu-latest strategy: fail-fast: false matrix: - builder: ["builder:22", "builder:20"] + builder: ["builder:24", "builder:22", "builder:20"] + arch: ["amd64", "arm64"] + exclude: + - builder: "builder:22" + arch: "arm64" + - builder: "builder:20" + arch: "arm64" + runs-on: ${{ matrix.arch == 'arm64' && 'pub-hk-ubuntu-22.04-arm-large' || 'ubuntu-latest' }} env: INTEGRATION_TEST_CNB_BUILDER: heroku/${{ matrix.builder }} steps: @@ -54,11 +60,11 @@ jobs: with: submodules: true - 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' || 'x86_64' }}-unknown-linux-musl - name: Rust Cache uses: Swatinem/rust-cache@v2.7.3 - name: Install Pack CLI diff --git a/buildpacks/php/CHANGELOG.md b/buildpacks/php/CHANGELOG.md index d2a47e5..07adc27 100644 --- a/buildpacks/php/CHANGELOG.md +++ b/buildpacks/php/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Add PHP/8.3, update PHP runtimes, extensions, Composers, web servers (#104) +- Support Ubuntu 24.04 (and, as a result, Heroku-24 and `heroku/builder:24`) +- Support `arm64` CPU architecture (Ubuntu 24.04 / Heroku-24 only) ### Changed diff --git a/buildpacks/php/buildpack.toml b/buildpacks/php/buildpack.toml index 4407e6b..2f68cd9 100644 --- a/buildpacks/php/buildpack.toml +++ b/buildpacks/php/buildpack.toml @@ -23,5 +23,17 @@ version = "20.04" name = "ubuntu" version = "22.04" +[[targets.distros]] +name = "ubuntu" +version = "24.04" + +[[targets]] +os = "linux" +arch = "arm64" + +[[targets.distros]] +name = "ubuntu" +version = "24.04" + [metadata.release] image = { repository = "docker.io/heroku/buildpack-php" } diff --git a/buildpacks/php/src/platform.rs b/buildpacks/php/src/platform.rs index accda31..d3daef5 100644 --- a/buildpacks/php/src/platform.rs +++ b/buildpacks/php/src/platform.rs @@ -41,7 +41,7 @@ pub(crate) fn heroku_stack_name_for_target(target: &Target) -> Result { + ("linux", "ubuntu", v @ ("20.04" | "22.04" | "24.04")) => { Ok(format!("heroku-{}", v.strip_suffix(".04").unwrap_or(v))) } _ => Err(format!("{os}-{distro_name}-{distro_version}")), diff --git a/buildpacks/php/tests/integration/utils.rs b/buildpacks/php/tests/integration/utils.rs index b9a32cf..2616aef 100644 --- a/buildpacks/php/tests/integration/utils.rs +++ b/buildpacks/php/tests/integration/utils.rs @@ -73,10 +73,18 @@ pub(crate) fn smoke_test( P: AsRef, B: Into>, { - let build_config = BuildConfig::new(builder_name.as_ref(), app_dir) + let mut build_config = BuildConfig::new(builder_name.as_ref(), app_dir) .buildpacks(buildpacks.into()) .clone(); + let target_triple = match builder_name.as_ref() { + // 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", + }; + + build_config.target_triple(target_triple); + TestRunner::default().build(&build_config, |context| { start_container_assert_basic_http_response(&context, expected_http_response_body_contains); @@ -89,7 +97,7 @@ pub(crate) fn smoke_test( }); } -const DEFAULT_INTEGRATION_TEST_BUILDER: &str = "heroku/builder:22"; +const DEFAULT_INTEGRATION_TEST_BUILDER: &str = "heroku/builder:24"; const UREQ_RESPONSE_RESULT_EXPECT_MESSAGE: &str = "http request should be successful"; From 906fb938d74812b30791337735cc0a8bf68d3ddb Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Wed, 5 Jun 2024 01:09:16 +0200 Subject: [PATCH 2/2] Use arm-medium runners but turn up test threads Using instances with 16 vCPUs is a bit silly for CI, but we can jack up the number of threads used for integration tests to match num of CPUs plus one --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71ce487..b2042e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: arch: "arm64" - builder: "builder:20" arch: "arm64" - runs-on: ${{ matrix.arch == 'arm64' && 'pub-hk-ubuntu-22.04-arm-large' || 'ubuntu-latest' }} + runs-on: ${{ matrix.arch == 'arm64' && 'pub-hk-ubuntu-22.04-arm-medium' || 'ubuntu-latest' }} env: INTEGRATION_TEST_CNB_BUILDER: heroku/${{ matrix.builder }} steps: @@ -75,4 +75,4 @@ jobs: # only those and not the unit tests, via the `--ignored` option. On the latest stack # we run all integration tests, but on older stacks we only run stack-specific tests. - name: Run integration tests (all tests) - run: cargo test --locked -- --ignored --test-threads 5 + run: cargo test --locked -- --ignored --test-threads $(($(nproc)+1))