From d3ca146e1bf197d0d3b09a4e010bf71394466b16 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Sun, 6 Mar 2022 23:19:51 +0000 Subject: [PATCH] Use `--pull-policy if-not-present` when running `pack build` Since it: 1. Saves ~2 seconds per integration test re-pulling an image that's already up to date. 2. Helps prevent hitting Docker Hub or ECR rate limits from duplicate (and redundant) image pulling (that counts agains the rate limit even when it's a no-op). Longer term, if Pack CLI supports a periodic pulling mode (buildpacks/pack#1368), we can switch to that, however for now this is the lesser of two evils - and in most cases Pack usage outside of `libcnb-test` will ensure that newer builder images are pulled from time to time. Fixes #306. --- .github/workflows/ci.yml | 9 ++------- libcnb-test/CHANGELOG.md | 1 + libcnb-test/src/pack.rs | 5 +++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52c74a46..75d4925b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,12 +60,6 @@ jobs: uses: Swatinem/rust-cache@v1.3.0 - name: Install Pack CLI uses: buildpacks/github-actions/setup-pack@v4.6.0 - - name: Configure Pack CLI - # Default to a small non-libc image for faster CI + to validate the static musl cross-compilation. - # Adjust pull-policy to prevent redundant image-pulling, which slows CI and risks hitting registry rate limits. - run: | - pack config default-builder cnbs/sample-builder:alpine - pack config pull-policy if-not-present - name: Run integration tests # Runs any tests annotated with the `#[ignore]` attribute (which in this repo, are all of the integration tests). run: cargo test -- --ignored @@ -73,4 +67,5 @@ jobs: run: cargo run --package libcnb-cargo -- libcnb package working-directory: ./examples/basics - name: Pack build using examples/basics - run: pack build example-basics --buildpack target/buildpack/debug/libcnb-examples_basics --path examples/ + # Uses a non-libc image to validate the static musl cross-compilation. + run: pack build example-basics --builder cnbs/sample-builder:alpine --buildpack target/buildpack/debug/libcnb-examples_basics --path examples/ diff --git a/libcnb-test/CHANGELOG.md b/libcnb-test/CHANGELOG.md index e0647b2a..e1ecd3b5 100644 --- a/libcnb-test/CHANGELOG.md +++ b/libcnb-test/CHANGELOG.md @@ -6,6 +6,7 @@ - Replaced `IntegrationTestContext::start_container` with `IntegrationTestContext::prepare_container`, allowing users to configure the container before starting it. Ports can now be exposed via `PrepareContainerContext::expose_port`. ([#346](https://github.com/Malax/libcnb.rs/pull/346)) - Added the ability to set environment variables for the container via `PrepareContainerContext::env` and `PrepareContainerContext::envs`. ([#346](https://github.com/Malax/libcnb.rs/pull/346)) - Switch from `libcnb-cargo` to the new `libcnb-package` crate for buildpack packaging, which improves compile times due to it not including CLI-related dependencies ([#362](https://github.com/Malax/libcnb.rs/pull/362)). +- Use `--pull-policy if-not-present` when running `pack build` ([#373](https://github.com/Malax/libcnb.rs/pull/373)). ## [0.2.0] 2022-02-28 diff --git a/libcnb-test/src/pack.rs b/libcnb-test/src/pack.rs index 9813dfc0..98e9bd55 100644 --- a/libcnb-test/src/pack.rs +++ b/libcnb-test/src/pack.rs @@ -76,6 +76,9 @@ impl From for Command { pack_build_command.builder, String::from("--path"), pack_build_command.path.to_string_lossy().to_string(), + // Adjust pull-policy to prevent redundant image-pulling, which slows CI and risks hitting registry rate limits. + String::from("--pull-policy"), + String::from("if-not-present"), ]; for buildpack in pack_build_command.buildpacks { @@ -141,6 +144,8 @@ mod tests { "builder:20", "--path", "/tmp/foo/bar", + "--pull-policy", + "if-not-present", "--buildpack", "libcnb/buildpack1", "--buildpack",