Skip to content

Commit

Permalink
[Dependency Cache] Enable Dependency Cache on CI (#3463)
Browse files Browse the repository at this point in the history
  • Loading branch information
ParaskP7 authored Jan 22, 2025
1 parent ff909ab commit 6bcb4c8
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 18 deletions.
15 changes: 15 additions & 0 deletions .buildkite/commands/assemble-release-apk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -eu

"$(dirname "${BASH_SOURCE[0]}")/restore-cache.sh"

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

install_gems

echo "--- :closed_lock_with_key: Installing Secrets"

bundle exec fastlane run configure_apply

echo "--- ⚙️ Building release variant"

./gradlew assembleRelease -PskipSentryProguardMappingUpload=true
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

"$(dirname "${BASH_SOURCE[0]}")/restore-cache.sh"

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

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

"$(dirname "${BASH_SOURCE[0]}")/restore-cache.sh"

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

Expand Down
4 changes: 4 additions & 0 deletions .buildkite/commands/restore-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash -e

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

"$(dirname "${BASH_SOURCE[0]}")/restore-cache.sh"

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

install_gems

echo "--- :closed_lock_with_key: Installing Secrets"

bundle exec fastlane run configure_apply

echo "--- 🧪 Testing"

bundle exec fastlane build_and_instrumented_test
7 changes: 7 additions & 0 deletions .buildkite/commands/run-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash -eu

"$(dirname "${BASH_SOURCE[0]}")/restore-cache.sh"

echo "--- 🧪 Testing"

./gradlew testDebugUnitTest
35 changes: 35 additions & 0 deletions .buildkite/commands/save-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/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/pipeline.yml -> ./gradlew assembleRelease
# .buildkite/commands/prototype-build.sh -> build_and_upload_prototype_build
# -> prototype_build_type = 'debugProd'
echo "--- 🛠 Download Mobile App Dependencies [Assemble Apps]"
./gradlew assembleDebug
echo ""

# .buildkite/commands/lint.sh -> ./gradlew :app:lintRelease + ./gradlew :automotive:lintRelease :wear:lintRelease
echo "--- 🧹 Download Lint Dependencies [Lint Apps]"
./gradlew :app:lintDebug :automotive:lintDebug :wear:lintDebug
echo ""

# .buildkite/pipeline.yml -> ./gradlew testDebugUnitTest
echo "--- 🧪 Download Unit Test Dependencies [Assemble Unit Tests]"
./gradlew assembleDebugUnitTest
echo ""

# .buildkite/pipeline.yml -> build_and_instrumented_test
# -> gradle(tasks: %w[assembleDebug assembleDebugAndroidTest])
echo "--- 🧪 Download Android Test Dependencies [Assemble Android Tests]"
./gradlew assembleDebugAndroidTest
echo ""

echo "--- 💾 Save Cache"
save_gradle_dependency_cache
20 changes: 3 additions & 17 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ steps:
- "**/build/reports/lint-results*.*"

- label: 'Unit tests'
command: |
echo "--- 🧪 Testing"
./gradlew testDebugUnitTest
command: ".buildkite/commands/run-unit-tests.sh"
plugins: [$CI_TOOLKIT]

- label: 'Dependency diff'
Expand All @@ -51,25 +49,13 @@ steps:
plugins: [$CI_TOOLKIT]

- label: "Instrumented tests"
command: |
echo "--- :rubygems: Setting up Gems"
install_gems
echo "--- :closed_lock_with_key: Installing Secrets"
bundle exec fastlane run configure_apply
echo "--- 🧪 Testing"
bundle exec fastlane build_and_instrumented_test
command: ".buildkite/commands/run-instrumented-tests.sh"
plugins: [$CI_TOOLKIT]
artifact_paths:
- "**/build/instrumented-tests/**/*"

- label: "Assemble release APK"
command: |
echo "--- :rubygems: Setting up Gems"
install_gems
echo "--- :closed_lock_with_key: Installing Secrets"
bundle exec fastlane run configure_apply
echo "--- ⚙️ Building release variant"
./gradlew assembleRelease -PskipSentryProguardMappingUpload=true
command: ".buildkite/commands/assemble-release-apk.sh"
plugins: [ $CI_TOOLKIT ]
artifact_paths:
- "**/build/outputs/apk/**/*"
Expand Down
22 changes: 22 additions & 0 deletions .buildkite/schedules/dependency-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
---

agents:
queue: "android"

steps:
- label: "💾 Download and Cache Dependencies"
command: .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"
2 changes: 1 addition & 1 deletion .buildkite/shared-pipeline-vars
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# 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"

0 comments on commit 6bcb4c8

Please sign in to comment.