diff --git a/.buildkite/commands/lint.sh b/.buildkite/commands/lint.sh index 71e35516721c..4b9590ec5cb3 100755 --- a/.buildkite/commands/lint.sh +++ b/.buildkite/commands/lint.sh @@ -1,5 +1,7 @@ #!/bin/bash -u +.buildkite/commands/restore-cache.sh + echo "--- ๐Ÿงน Linting" ./gradlew :WooCommerce:lintJalapenoDebug app_lint_exit_code=$? diff --git a/.buildkite/commands/prototype-build.sh b/.buildkite/commands/prototype-build.sh index 28dfbcf1c159..5f91ec44302b 100755 --- a/.buildkite/commands/prototype-build.sh +++ b/.buildkite/commands/prototype-build.sh @@ -1,5 +1,7 @@ #!/bin/bash -eu +.buildkite/commands/restore-cache.sh + APP_TO_BUILD="${1?You need to specify the app to build, WooCommerce or WooCommerce-Wear}" echo "--- :rubygems: Setting up Gems" diff --git a/.buildkite/commands/restore-cache.sh b/.buildkite/commands/restore-cache.sh new file mode 100755 index 000000000000..480ae6987901 --- /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/commands/run-instrumented-tests.sh b/.buildkite/commands/run-instrumented-tests.sh index b570524de8d0..66ebce299e1b 100755 --- a/.buildkite/commands/run-instrumented-tests.sh +++ b/.buildkite/commands/run-instrumented-tests.sh @@ -1,5 +1,7 @@ #!/bin/bash -eu +.buildkite/commands/restore-cache.sh + echo "--- :rubygems: Setting up Gems" install_gems diff --git a/.buildkite/commands/run-unit-tests.sh b/.buildkite/commands/run-unit-tests.sh index 9d28c534e675..6d2fa7bc21c8 100755 --- a/.buildkite/commands/run-unit-tests.sh +++ b/.buildkite/commands/run-unit-tests.sh @@ -1,5 +1,7 @@ #!/bin/bash -eu +.buildkite/commands/restore-cache.sh + echo "--- ๐Ÿงช Testing" set +e ./gradlew testJalapenoDebugUnitTest testDebugUnitTest diff --git a/.buildkite/commands/save-cache.sh b/.buildkite/commands/save-cache.sh new file mode 100755 index 000000000000..9a62673c4206 --- /dev/null +++ b/.buildkite/commands/save-cache.sh @@ -0,0 +1,42 @@ +#!/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 + +# .buildkite/commands/prototype-build.sh -> build_and_upload_prototype_build +# -> prototype_flavor = 'Jalapeno' +# -> prototype_build_type = 'Debug' +echo "--- ๐Ÿ›  Download Mobile App Dependencies [Assemble Mobile App]" +./gradlew :WooCommerce:assembleJalapenoDebug +echo "" + +# .buildkite/commands/prototype-build.sh -> build_and_upload_prototype_build +# -> prototype_flavor = 'Jalapeno' +# -> prototype_build_type = 'Debug' +echo "--- ๐Ÿ›  Download Wear App Dependencies [Assemble Wear App]" +./gradlew :WooCommerce-Wear:assembleJalapenoDebug +echo "" + +# .buildkite/commands/lint.sh -> ./gradlew :WooCommerce:lintJalapenoDebug +echo "--- ๐Ÿงน Download Lint Dependencies [Lint Mobile App]" +./gradlew :WooCommerce:lintJalapenoDebug +echo "" + +# .buildkite/commands/run-unit-tests.sh -> ./gradlew testJalapenoDebugUnitTest testDebugUnitTest +echo "--- ๐Ÿงช Download Unit Test Dependencies [Assemble Unit Tests]" +./gradlew assembleJalapenoDebugUnitTest assembleDebugUnitTest +echo "" + +# .buildkite/commands/run-instrumented-tests.sh -> build_and_instrumented_test +# -> gradle(tasks: %w[assembleVanillaDebug assembleVanillaDebugAndroidTest]) +echo "--- ๐Ÿงช Download Android Test Dependencies [Assemble Android Tests]" +./gradlew assembleJalapenoDebugAndroidTest +echo "" + +echo "--- ๐Ÿ’พ Save Cache" +save_gradle_dependency_cache diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 360aad54c4b4..02cc3a2b6b0c 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -35,9 +35,7 @@ steps: queue: "linter" - label: "detekt" - command: | - echo "--- ๐Ÿงน Linting" - ./gradlew detektAll + command: ./gradlew detektAll plugins: [$CI_TOOLKIT] artifact_paths: - "**/build/reports/detekt/detekt.html" @@ -60,14 +58,12 @@ steps: steps: - label: "๐Ÿ›  Prototype Build: Mobile App" - command: | - ".buildkite/commands/prototype-build.sh" "WooCommerce" + 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" + command: ".buildkite/commands/prototype-build.sh WooCommerce-Wear" if: build.pull_request.id != null plugins: [$CI_TOOLKIT] diff --git a/.buildkite/schedules/dependency-cache.yml b/.buildkite/schedules/dependency-cache.yml new file mode 100644 index 000000000000..ad18b3e4ef13 --- /dev/null +++ b/.buildkite/schedules/dependency-cache.yml @@ -0,0 +1,24 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json +--- + +agents: + queue: "android" + +steps: + - label: "dependency cache" + command: | + echo "--- ๐Ÿ’พ Download and Cache Dependencies" + .buildkite/commands/save-cache.sh + plugins: [$CI_TOOLKIT] + +notify: + - slack: + channels: + - "#android-core-notifs" + message: "The dependency cache has been updated." + if: build.state == "passed" + - slack: + channels: + - "#android-core-notifs" + message: "Failure to update the dependency cache." + if: build.state == "failed" diff --git a/.buildkite/shared-pipeline-vars b/.buildkite/shared-pipeline-vars index 307dd62e628d..969e154cb6cb 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#3.9.1" export TEST_COLLECTOR="test-collector#v1.10.1" -