From e50f41516f3efd665c0d47fb41ed181103423577 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 19 Dec 2024 16:22:47 +0200 Subject: [PATCH 01/13] CI: Use android-staging agent to test with ro dependency cache disabled AMI ID: ami-06a633c14b35c40b9 AMI Name: android-build-image-6.12.0v1.4-rc-1 --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 360aad54c4b..4c258c723b3 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -9,7 +9,7 @@ common_params: format: "junit" agents: - queue: "android" + queue: "android-staging" steps: - label: Gradle Wrapper Validation From 145a096b6c486eac450041b148e436ae3f57807b Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 19 Dec 2024 16:26:20 +0200 Subject: [PATCH 02/13] CI: Remove pre command hook to ignore restore gradle dependency cache With this hook present, every build and its within jobs are all restoring the dependency cache, even when this is not really needed, and as such potentially delaying some jobs unnecessarily, while also consuming unnecessary resources (downloading from s3, (un)compressing, etc). FYI: It is better to use 'restore_gradle_dependency_cache' only on those jobs that could really benefit from it. --- .buildkite/hooks/pre-command | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .buildkite/hooks/pre-command diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command deleted file mode 100644 index 71f70a0cd2b..00000000000 --- a/.buildkite/hooks/pre-command +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# Note that as the script is sourced, not run directly, the shebang line will be ignored -# See https://buildkite.com/docs/agent/v3/hooks#creating-hook-scripts - -set -e - -restore_gradle_dependency_cache || true From 0dcd7b8016ec60e49268d99ca96ed5c3d55df0ad Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 20 Dec 2024 13:24:36 +0200 Subject: [PATCH 03/13] CI: Temporarily remove all pipeline steps but the mobile app prototype --- .buildkite/pipeline.yml | 94 +++-------------------------------------- 1 file changed, 5 insertions(+), 89 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 4c258c723b3..1dc3079f6e2 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,96 +1,12 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json --- -# Nodes with values to reuse in the pipeline. -common_params: - # Common plugin settings to use with the `plugins` key. - - &test_collector_common_params - files: "WooCommerce/build/buildkite-test-analytics/*.xml" - format: "junit" - agents: queue: "android-staging" steps: - - label: Gradle Wrapper Validation - command: validate_gradle_wrapper - agents: - queue: linter - - # Wait for Gradle Wrapper to be validated before running any other jobs - - wait - - ######################################## - - group: "๐Ÿ•ต๏ธ Linters" - steps: - - - label: "โ˜ข๏ธ Danger - PR Check" - command: danger - key: danger - if: "build.pull_request.id != null" - retry: - manual: - permit_on_passed: true - agents: - queue: "linter" - - - label: "detekt" - command: | - echo "--- ๐Ÿงน Linting" - ./gradlew detektAll - plugins: [$CI_TOOLKIT] - artifact_paths: - - "**/build/reports/detekt/detekt.html" - - - label: "lint" - command: .buildkite/commands/lint.sh - plugins: [$CI_TOOLKIT] - artifact_paths: - - "**/build/reports/lint-results*.*" - - - label: "Dependency Tree Diff" - command: comment_with_dependency_diff 'woocommerce' 'vanillaReleaseRuntimeClasspath' - if: build.pull_request.id != null - plugins: [$CI_TOOLKIT] - artifact_paths: - - "**/build/reports/diff/*" - - ######################################## - - group: "๐Ÿ›  Prototype Builds" - steps: - - - label: "๐Ÿ›  Prototype Build: Mobile App" - command: | - ".buildkite/commands/prototype-build.sh" "WooCommerce" - if: build.pull_request.id != null - plugins: [$CI_TOOLKIT] - - - label: "๐Ÿ›  Prototype Build: Wear App" - command: | - ".buildkite/commands/prototype-build.sh" "WooCommerce-Wear" - if: build.pull_request.id != null - plugins: [$CI_TOOLKIT] - - ######################################## - - group: "๐Ÿ”ฌ Tests" - steps: - - - label: "Unit tests" - command: .buildkite/commands/run-unit-tests.sh - plugins: - - $CI_TOOLKIT - - $TEST_COLLECTOR : - <<: *test_collector_common_params - api-token-env-name: "BUILDKITE_ANALYTICS_TOKEN_UNIT_TESTS" - artifact_paths: - - "**/build/test-results/merged-test-results.xml" - - - label: "Instrumented tests" - command: .buildkite/commands/run-instrumented-tests.sh - plugins: - - $CI_TOOLKIT - - $TEST_COLLECTOR : - <<: *test_collector_common_params - api-token-env-name: "BUILDKITE_ANALYTICS_TOKEN_INSTRUMENTED_TESTS" - artifact_paths: - - "**/build/instrumented-tests/**/*" + - label: "๐Ÿ›  Prototype Build: Mobile App" + command: | + ".buildkite/commands/prototype-build.sh" "WooCommerce" + if: build.pull_request.id != null + plugins: [$CI_TOOLKIT] From 539bda5d75286d0775b661e402315a8ad20aa122 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 12 Dec 2024 20:58:39 +0200 Subject: [PATCH 04/13] CI: Add a scheduled dependency cache job FYI: This job will be then used by 'buildkite-ci' and configured as a 'buildkite_pipeline_schedule' with a weekly frequency. --- .buildkite/commands/save-cache.sh | 16 ++++++++++++++++ .buildkite/schedules/dependency-cache.yml | 12 ++++++++++++ 2 files changed, 28 insertions(+) create mode 100755 .buildkite/commands/save-cache.sh create mode 100644 .buildkite/schedules/dependency-cache.yml diff --git a/.buildkite/commands/save-cache.sh b/.buildkite/commands/save-cache.sh new file mode 100755 index 00000000000..0df60026672 --- /dev/null +++ b/.buildkite/commands/save-cache.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -euo pipefail + +echo "--- :rubygems: Setting up Gems" +install_gems + +echo "--- :closed_lock_with_key: Installing Secrets" +bundle exec fastlane run configure_apply + +echo "--- ๐Ÿ›  Download Mobile App Dependencies [Assemble Mobile App]" +./gradlew :WooCommerce:assembleJalapenoDebug +echo "" + +echo "--- ๐Ÿ’พ Save Cache" +save_gradle_dependency_cache diff --git a/.buildkite/schedules/dependency-cache.yml b/.buildkite/schedules/dependency-cache.yml new file mode 100644 index 00000000000..960751c865e --- /dev/null +++ b/.buildkite/schedules/dependency-cache.yml @@ -0,0 +1,12 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json +--- + +agents: + queue: "android-staging" + +steps: + - label: "dependency cache" + command: | + echo "--- ๐Ÿ’พ Download and Cache Dependencies" + .buildkite/commands/save-cache.sh + plugins: [$CI_TOOLKIT] From 3cbe4fc3dc6d6721fdb0e3147e551aeb97377e9c Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 20 Dec 2024 13:41:29 +0200 Subject: [PATCH 05/13] CI: Add restore cache command to run only before mobile app prototype Since the hook was removed (145a096b6c486eac450041b148e436ae3f57807b), no build and its within jobs can restore the dependency cache, that is, unless if it is explicitly specified, just like it is done for mobile app prototype step via this change. --- .buildkite/commands/restore-cache.sh | 6 ++++++ .buildkite/pipeline.yml | 1 + 2 files changed, 7 insertions(+) create mode 100755 .buildkite/commands/restore-cache.sh diff --git a/.buildkite/commands/restore-cache.sh b/.buildkite/commands/restore-cache.sh new file mode 100755 index 00000000000..480ae698790 --- /dev/null +++ b/.buildkite/commands/restore-cache.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +echo "--- ๐Ÿ’พ Restore Cache" +restore_gradle_dependency_cache || true diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 1dc3079f6e2..a63caa35343 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -7,6 +7,7 @@ agents: steps: - label: "๐Ÿ›  Prototype Build: Mobile App" command: | + .buildkite/commands/restore-cache.sh ".buildkite/commands/prototype-build.sh" "WooCommerce" if: build.pull_request.id != null plugins: [$CI_TOOLKIT] From 82bd4449f1fac2cc9e2bb05a7f4253e80a669416 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 20 Dec 2024 13:43:53 +0200 Subject: [PATCH 06/13] CI: Use non read-only dependency cache to save/restore the cache --- .buildkite/shared-pipeline-vars | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.buildkite/shared-pipeline-vars b/.buildkite/shared-pipeline-vars index 307dd62e628..9f45e4a632e 100644 --- a/.buildkite/shared-pipeline-vars +++ b/.buildkite/shared-pipeline-vars @@ -3,6 +3,5 @@ # This file is `source`'d before calling `buildkite-agent pipeline upload`, and can be used # to set up some variables that will be interpolated in the `.yml` pipeline before uploading it. -export CI_TOOLKIT="automattic/a8c-ci-toolkit#3.7.1" +export CI_TOOLKIT="automattic/a8c-ci-toolkit#84a1cb6205bae6ff86dbff520bc3eb1dd90a3839" export TEST_COLLECTOR="test-collector#v1.10.1" - From 3869b31c26c0fa046b354cb4e85b31fe44662119 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 20 Dec 2024 17:33:49 +0200 Subject: [PATCH 07/13] CI: Revert the removal of all pipeline steps This change effectively reverts this initial 0dcd7b8016ec60e49268d99ca96ed5c3d55df0ad commit. --- .buildkite/pipeline.yml | 95 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 89 insertions(+), 6 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index a63caa35343..79af5cef84f 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,13 +1,96 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json --- +# Nodes with values to reuse in the pipeline. +common_params: + # Common plugin settings to use with the `plugins` key. + - &test_collector_common_params + files: "WooCommerce/build/buildkite-test-analytics/*.xml" + format: "junit" + agents: queue: "android-staging" steps: - - label: "๐Ÿ›  Prototype Build: Mobile App" - command: | - .buildkite/commands/restore-cache.sh - ".buildkite/commands/prototype-build.sh" "WooCommerce" - if: build.pull_request.id != null - plugins: [$CI_TOOLKIT] + - label: Gradle Wrapper Validation + command: validate_gradle_wrapper + agents: + queue: linter + + # Wait for Gradle Wrapper to be validated before running any other jobs + - wait + + ######################################## + - group: "๐Ÿ•ต๏ธ Linters" + steps: + + - label: "โ˜ข๏ธ Danger - PR Check" + command: danger + key: danger + if: "build.pull_request.id != null" + retry: + manual: + permit_on_passed: true + agents: + queue: "linter" + + - label: "detekt" + command: | + echo "--- ๐Ÿงน Linting" + ./gradlew detektAll + plugins: [$CI_TOOLKIT] + artifact_paths: + - "**/build/reports/detekt/detekt.html" + + - label: "lint" + command: .buildkite/commands/lint.sh + plugins: [$CI_TOOLKIT] + artifact_paths: + - "**/build/reports/lint-results*.*" + + - label: "Dependency Tree Diff" + command: comment_with_dependency_diff 'woocommerce' 'vanillaReleaseRuntimeClasspath' + if: build.pull_request.id != null + plugins: [$CI_TOOLKIT] + artifact_paths: + - "**/build/reports/diff/*" + + ######################################## + - group: "๐Ÿ›  Prototype Builds" + steps: + + - label: "๐Ÿ›  Prototype Build: Mobile App" + command: | + ".buildkite/commands/prototype-build.sh" "WooCommerce" + if: build.pull_request.id != null + plugins: [$CI_TOOLKIT] + + - label: "๐Ÿ›  Prototype Build: Wear App" + command: | + ".buildkite/commands/prototype-build.sh" "WooCommerce-Wear" + if: build.pull_request.id != null + plugins: [$CI_TOOLKIT] + + ######################################## + - group: "๐Ÿ”ฌ Tests" + steps: + + - label: "Unit tests" + command: .buildkite/commands/run-unit-tests.sh + plugins: + - $CI_TOOLKIT + - $TEST_COLLECTOR : + <<: *test_collector_common_params + api-token-env-name: "BUILDKITE_ANALYTICS_TOKEN_UNIT_TESTS" + artifact_paths: + - "**/build/test-results/merged-test-results.xml" + + - label: "Instrumented tests" + command: .buildkite/commands/run-instrumented-tests.sh + plugins: + - $CI_TOOLKIT + - $TEST_COLLECTOR : + <<: *test_collector_common_params + api-token-env-name: "BUILDKITE_ANALYTICS_TOKEN_INSTRUMENTED_TESTS" + artifact_paths: + - "**/build/instrumented-tests/**/*" From be6b3a0b939283da2198f1bf326023ebfa17f64b Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 20 Dec 2024 17:35:38 +0200 Subject: [PATCH 08/13] CI: Cache all dependencies as part of the scheduled dependency cache job --- .buildkite/commands/save-cache.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.buildkite/commands/save-cache.sh b/.buildkite/commands/save-cache.sh index 0df60026672..12e0d7c335a 100755 --- a/.buildkite/commands/save-cache.sh +++ b/.buildkite/commands/save-cache.sh @@ -12,5 +12,25 @@ echo "--- ๐Ÿ›  Download Mobile App Dependencies [Assemble Mobile App]" ./gradlew :WooCommerce:assembleJalapenoDebug echo "" +echo "--- ๐Ÿ›  Download Wear App Dependencies [Assemble Wear App]" +./gradlew :WooCommerce-Wear:assembleJalapenoDebug +echo "" + +echo "--- ๐Ÿงน Download Lint Dependencies [Lint Mobile App]" +./gradlew :WooCommerce:lintJalapenoDebug +echo "" + +echo "--- ๐Ÿงน Download Detekt Dependencies [Run Detekt]" +./gradlew detektAll +echo "" + +echo "--- ๐Ÿงช Download Unit Test Dependencies [Assemble Unit Tests]" +./gradlew assembleJalapenoDebugUnitTest lib:cardreader:assembleDebugUnitTest lib:iap:assembleDebugUnitTest +echo "" + +echo "--- ๐Ÿงช Download Android Test Dependencies [Assemble Android Tests]" +./gradlew assembleJalapenoDebugAndroidTest +echo "" + echo "--- ๐Ÿ’พ Save Cache" save_gradle_dependency_cache From 13cbd883003cc2c869d83fc1081e47dc61fe4cdc Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 20 Dec 2024 17:54:08 +0200 Subject: [PATCH 09/13] CI: Add restore cache command to run on targeted steps The targeted steps are: - Mobile App - Wear App - Lint - Detekt - Unit Tests - Android tests --- .buildkite/pipeline.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 79af5cef84f..1e692c8f880 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -36,14 +36,16 @@ steps: - label: "detekt" command: | - echo "--- ๐Ÿงน Linting" + .buildkite/commands/restore-cache.sh ./gradlew detektAll plugins: [$CI_TOOLKIT] artifact_paths: - "**/build/reports/detekt/detekt.html" - label: "lint" - command: .buildkite/commands/lint.sh + command: | + .buildkite/commands/restore-cache.sh + .buildkite/commands/lint.sh plugins: [$CI_TOOLKIT] artifact_paths: - "**/build/reports/lint-results*.*" @@ -61,12 +63,14 @@ steps: - label: "๐Ÿ›  Prototype Build: Mobile App" command: | + .buildkite/commands/restore-cache.sh ".buildkite/commands/prototype-build.sh" "WooCommerce" if: build.pull_request.id != null plugins: [$CI_TOOLKIT] - label: "๐Ÿ›  Prototype Build: Wear App" command: | + .buildkite/commands/restore-cache.sh ".buildkite/commands/prototype-build.sh" "WooCommerce-Wear" if: build.pull_request.id != null plugins: [$CI_TOOLKIT] @@ -76,7 +80,9 @@ steps: steps: - label: "Unit tests" - command: .buildkite/commands/run-unit-tests.sh + command: | + .buildkite/commands/restore-cache.sh + .buildkite/commands/run-unit-tests.sh plugins: - $CI_TOOLKIT - $TEST_COLLECTOR : @@ -86,7 +92,9 @@ steps: - "**/build/test-results/merged-test-results.xml" - label: "Instrumented tests" - command: .buildkite/commands/run-instrumented-tests.sh + command: | + .buildkite/commands/restore-cache.sh + .buildkite/commands/run-instrumented-tests.sh plugins: - $CI_TOOLKIT - $TEST_COLLECTOR : From 64c365a46113e0188882d47e4e1b4a920f02ed31 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 20 Dec 2024 18:28:51 +0200 Subject: [PATCH 10/13] CI: Check if modules-2 directory exists prior to placing cache --- .buildkite/shared-pipeline-vars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/shared-pipeline-vars b/.buildkite/shared-pipeline-vars index 9f45e4a632e..01441eee3c9 100644 --- a/.buildkite/shared-pipeline-vars +++ b/.buildkite/shared-pipeline-vars @@ -3,5 +3,5 @@ # This file is `source`'d before calling `buildkite-agent pipeline upload`, and can be used # to set up some variables that will be interpolated in the `.yml` pipeline before uploading it. -export CI_TOOLKIT="automattic/a8c-ci-toolkit#84a1cb6205bae6ff86dbff520bc3eb1dd90a3839" +export CI_TOOLKIT="automattic/a8c-ci-toolkit#1d7a5b2b01d925e0c38d15b924c132763f715a48" export TEST_COLLECTOR="test-collector#v1.10.1" From 307c835f09430a2074ca852b1347922cc1688343 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 10 Jan 2025 14:04:19 +0200 Subject: [PATCH 11/13] CI: Trigger a test build using the latest update from a8c-ci-toolkit PR: https://github.com/Automattic/a8c-ci-toolkit-buildkite-plugin/ pull/135 --- .buildkite/shared-pipeline-vars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/shared-pipeline-vars b/.buildkite/shared-pipeline-vars index 01441eee3c9..96a409dc9e3 100644 --- a/.buildkite/shared-pipeline-vars +++ b/.buildkite/shared-pipeline-vars @@ -3,5 +3,5 @@ # This file is `source`'d before calling `buildkite-agent pipeline upload`, and can be used # to set up some variables that will be interpolated in the `.yml` pipeline before uploading it. -export CI_TOOLKIT="automattic/a8c-ci-toolkit#1d7a5b2b01d925e0c38d15b924c132763f715a48" +export CI_TOOLKIT="automattic/a8c-ci-toolkit#94d9f7a3829cd21d9f31b5ee962178c26606c71e" export TEST_COLLECTOR="test-collector#v1.10.1" From 2a091b1b6737cda9a5a2d6de3f6d05593766fb18 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Mon, 13 Jan 2025 11:59:39 +0200 Subject: [PATCH 12/13] CI: Switch back to android agent to re-test without ro dependency cache After deploying this buildkite-ci#570 change (PR below), which removed the read-only dependency cache (GRADLE_RO_DEP_CACHE), the agent can be switched back to 'android' for us to test that the deployment went as expected, just to be sure. PR: https://github.com/Automattic/buildkite-ci/pull/570 AMI ID: ami-0fdecc22b38a48860 AMI Name: android-build-image-6.12.0v1.4 --- .buildkite/pipeline.yml | 2 +- .buildkite/schedules/dependency-cache.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 1e692c8f880..0be255bc9a7 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -9,7 +9,7 @@ common_params: format: "junit" agents: - queue: "android-staging" + queue: "android" steps: - label: Gradle Wrapper Validation diff --git a/.buildkite/schedules/dependency-cache.yml b/.buildkite/schedules/dependency-cache.yml index 960751c865e..7455533db01 100644 --- a/.buildkite/schedules/dependency-cache.yml +++ b/.buildkite/schedules/dependency-cache.yml @@ -2,7 +2,7 @@ --- agents: - queue: "android-staging" + queue: "android" steps: - label: "dependency cache" From dbc1eefac3ad9cdf2b7c811dfda76c6014c29253 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Mon, 13 Jan 2025 14:59:01 +0200 Subject: [PATCH 13/13] CI: Remove lib:iap unit test as the module is no longer available For more info see: 14e209ebc380157239af17971546ab06db64ad79 --- .buildkite/commands/save-cache.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/commands/save-cache.sh b/.buildkite/commands/save-cache.sh index 12e0d7c335a..7be11f2a128 100755 --- a/.buildkite/commands/save-cache.sh +++ b/.buildkite/commands/save-cache.sh @@ -25,7 +25,7 @@ echo "--- ๐Ÿงน Download Detekt Dependencies [Run Detekt]" echo "" echo "--- ๐Ÿงช Download Unit Test Dependencies [Assemble Unit Tests]" -./gradlew assembleJalapenoDebugUnitTest lib:cardreader:assembleDebugUnitTest lib:iap:assembleDebugUnitTest +./gradlew assembleJalapenoDebugUnitTest lib:cardreader:assembleDebugUnitTest echo "" echo "--- ๐Ÿงช Download Android Test Dependencies [Assemble Android Tests]"