Skip to content

Commit

Permalink
Merge pull request #13303 from woocommerce/ci/enable-dependency-cache…
Browse files Browse the repository at this point in the history
…-on-ci-final

[Dependency Cache] Enable Dependency Cache on CI
  • Loading branch information
ParaskP7 authored Jan 17, 2025
2 parents df4ac5a + 25a6483 commit cda6ca5
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .buildkite/commands/lint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash -u

.buildkite/commands/restore-cache.sh

echo "--- 🧹 Linting"
./gradlew :WooCommerce:lintJalapenoDebug
app_lint_exit_code=$?
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/commands/prototype-build.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 6 additions & 0 deletions .buildkite/commands/restore-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

echo "--- 💾 Restore Cache"
restore_gradle_dependency_cache || true
2 changes: 2 additions & 0 deletions .buildkite/commands/run-instrumented-tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash -eu

.buildkite/commands/restore-cache.sh

echo "--- :rubygems: Setting up Gems"
install_gems

Expand Down
2 changes: 2 additions & 0 deletions .buildkite/commands/run-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash -eu

.buildkite/commands/restore-cache.sh

echo "--- 🧪 Testing"
set +e
./gradlew testJalapenoDebugUnitTest testDebugUnitTest
Expand Down
42 changes: 42 additions & 0 deletions .buildkite/commands/save-cache.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 3 additions & 7 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]

Expand Down
24 changes: 24 additions & 0 deletions .buildkite/schedules/dependency-cache.yml
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 1 addition & 2 deletions .buildkite/shared-pipeline-vars
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit cda6ca5

Please sign in to comment.