From d88a72e7f70bf0939e0f20f93280a2ec402a11cb Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Wed, 2 Nov 2022 12:29:43 +1100 Subject: [PATCH] Add step to load pods in cache before building and testing It occurred to me, because of our steps parallelism, we can run in situations where a commit that changes the `Podfile.lock` results in multiple steps in the same CI build installing the pods from scratch. For example, see this build where all three IPA deployment steps spend 15+ minutes in the CocoaPods part of the build because there was no cached version of the pods available, https://buildkite.com/automattic/wordpress-ios/builds/10636. By introducing a step at the start of the pipeline, on which the following steps depend upon, to install the pods we can make sure parallel steps won't waste time building the same new version of the Pods. --- .buildkite/commands/load-pods.sh | 7 +++++++ .buildkite/pipeline.yml | 12 ++++++++++++ .buildkite/release-builds.yml | 12 ++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 .buildkite/commands/load-pods.sh diff --git a/.buildkite/commands/load-pods.sh b/.buildkite/commands/load-pods.sh new file mode 100644 index 000000000000..c6ac9d6adc02 --- /dev/null +++ b/.buildkite/commands/load-pods.sh @@ -0,0 +1,7 @@ +#!/bin/bash -eu + +echo "--- :rubygems: Set up Gems" +install_gems + +echo "--- :cocoapods: Set up Pods and cache them if needed" +install_cocoapods diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 5953dbf28c42..bb444b68b732 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -13,6 +13,15 @@ common_params: # This is the default pipeline – it will build and test the app steps: + # Make sure there is a cached version of the pods avaialble before testing + # the app or deploying installable builds to avoid parallel steps wasting + # time building the same `Podfile.lock` from scratch. + - label: ':cocoapods: Pre-load Pods' + key: pods + command: .buildkite/commands/load-pods.sh + env: *common_env + plugins: *common_plugins + ################# # Create Installable Builds for WP and JP ################# @@ -20,6 +29,7 @@ steps: steps: - label: "🛠 WordPress Installable Build" command: ".buildkite/commands/installable-build-wordpress.sh" + depends_on: "pods" env: *common_env plugins: *common_plugins if: "build.pull_request.id != null || build.pull_request.draft" @@ -29,6 +39,7 @@ steps: - label: "🛠 Jetpack Installable Build" command: ".buildkite/commands/installable-build-jetpack.sh" + depends_on: "pods" env: *common_env plugins: *common_plugins if: "build.pull_request.id != null || build.pull_request.draft" @@ -42,6 +53,7 @@ steps: - label: "🛠 Build for Testing" key: "build" command: ".buildkite/commands/build-for-testing.sh" + depends_on: "pods" env: *common_env plugins: *common_plugins notify: diff --git a/.buildkite/release-builds.yml b/.buildkite/release-builds.yml index 935514191e35..33b9e8ed4a0a 100644 --- a/.buildkite/release-builds.yml +++ b/.buildkite/release-builds.yml @@ -14,8 +14,18 @@ common_params: steps: + # Make sure there is a cached version of the pods avaialble before testing + # the app or deploying installable builds to avoid parallel steps wasting + # time building the same `Podfile.lock` from scratch. + - label: ':cocoapods: Pre-load Pods' + key: pods + command: .buildkite/commands/load-pods.sh + env: *common_env + plugins: *common_plugins + - label: ":wordpress: :testflight: WordPress Release Build (App Store Connect)" command: ".buildkite/commands/release-build-wordpress.sh $BETA_RELEASE" + depends_on: "pods" env: *common_env plugins: *common_plugins notify: @@ -23,6 +33,7 @@ steps: - label: ":wordpress: :appcenter: WordPress Release Build (App Center)" command: ".buildkite/commands/release-build-wordpress-internal.sh" + depends_on: "pods" env: *common_env plugins: *common_plugins notify: @@ -30,6 +41,7 @@ steps: - label: ":jetpack: :testflight: Jetpack Release Build (App Store Connect)" command: ".buildkite/commands/release-build-jetpack.sh" + depends_on: "pods" env: *common_env plugins: *common_plugins notify: