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

Conversation

ParaskP7
Copy link
Contributor

@ParaskP7 ParaskP7 commented Jan 20, 2025

Project Thread: paaHJt-7CE-p2 (Stretch Goal)
Related: WCAndroid#133303 + JP/WPAndroid#21584
Depends On: a8c-ci-toolkit#135 -> a8c-ci-toolkit#138
Required By: buildkite-ci#581


Description

This PR enables dependency cache on CI for this project. 💾

The dependency cache mechanism is split between:

  • A weekly scheduled save cache build (see commit and buildkite-ci#581 PR), which targets the below tasks only:
    • Apps (assembleDebug)
    • Lint (:app:lintDebug :automotive:lintDebug :wear:lintDebug)
    • Unit Tests (assembleDebugUnitTest)
    • Android Tests (assembleDebugAndroidTest)
  • A restore cache step that is run on targeted pipeline.yml related jobs, via their corresponding individual scripts:
    • Mobile App (prototype-build.sh)
    • Lint (lint.sh)
    • Unit Tests (run-unit-tests.sh)
    • Android tests (run-instrumented-tests.sh)

PS: Dependency cache isn't enabled on the release-builds.yml pipeline just yet, but just temporarily, and until we become comfortable with running this new process on the main pipeline.yml pipeline.


Future Improvement

Me and @wzieba has been discussing on DMs about some possible future improvement, which are including but are not limited to the below list:

  1. Only execute the assemble android test task, which depends on assemble task anyway, and would most likely resolve most of the dependencies, for all other tasks to benefit from. However, this needs further testing to make sure that running other tasks such us lint and assemble unit test are providing little to no help.
  2. Create a custom Gradle task and utilize Gradle's init scripts (init.d). Using the init script, go through all available modules for a project, and then, using that custom Gradle task, resolve all dependencies for all tasks that are available per module. We could take some inspiration from plugins such as this.
  3. Instead of scheduling the dependency cache build to run weekly (buildkite-ci#581), make it run more often, possibly scheduling it to even run daily. However, since dependencies are not being updated too often, and, even when they do on that specific week, it would only be for a few of them. This will indeed cause some extra network requests, but most of the dependencies cached would still benefit from the existing and weekly refreshed dependency cache.
  4. Enable dependency cache on the release-builds.yml pipeline.

Testing Instructions

Job BT (Without) BT (With) BT (Diff*) NR (Without) NR (With) RC (Without) RC (With) Win
Assemble Release 6m 49s 5m 47s -2m 2s 1m 6s 0s (ish) 0s 16s 50s
Mobile App 7m 5s 5m 0s -2m 5s 1m 6s 0s (ish) 0s 12s 54s
Lint 6m 47s 5m 10s -1m 37s 1m 1s 0s (ish) 0s 14s 47s
Unit Tests 5m 45s 4m 24s -1m 21s 1m 6s 0s 0s 14s 50s
UI Tests 11m 17s 10m 56s -21s 1m 10s 0s 0s 14s 56s

Note

  • Without: Without Dependency Cache
  • With: With Dependency Cache
  • BT: Build Time
  • NR: Network Requests
  • RC: Restore Cache
  • Win: NR (Without) - RC (With)

Warning

(*): The BT (Diff) presented above is relative, so don't read too much into it, it might not match with the WIN, which is a much more solid number. But still, it is nice to have and compare those two number together. To to be clear about that, although I tried to pick the most representative builds, without and with the dependency cache mechanism in place, there are other factors that can make any build faster, or slower for that matter (like build cache, firebase test lab, etc), so again, don't read too much into it.


Checklist N/A

I have tested any UI changes... N/A

Release Notes: https://github.com/Automattic/
a8c-ci-toolkit-buildkite-plugin/releases/tag/3.9.1

FYI: This change points to that version of the 'A8C CI Toolkit' where
both, the #135 and #138 PRs, are merged into 'trunk', and, the new
dependency cache mechanism, per project, without 'GRADLE_RO_DEP_CACHE',
is fully operational.

A8C CI Toolkit #135 PR: [Dependency Cache] Dependency Cache on CI per
Project [without GRADLE_RO_DEP_CACHE] #135
- Automattic/a8c-ci-toolkit-buildkite-plugin#135

A8C CI Toolkit #138 PR: [Dependency Cache] Fix Dependency Cache #138
- Automattic/a8c-ci-toolkit-buildkite-plugin#138
@ParaskP7 ParaskP7 added [Type] Tooling Related to the Gradle build scripts and the setup or maintenance of the project build process. [Type] Core labels Jan 20, 2025
@ParaskP7 ParaskP7 added this to the 7.82 milestone Jan 20, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 20, 2025

📲 You can test the changes from this Pull Request in 📱 Mobile by scanning the QR code below to install the corresponding build.
App Name 📱 Mobile
Build TypedebugProd
Commitafedd3f
Direct Downloadpocketcasts-app-prototype-build-pr3463-afedd3f.apk
📲 You can test the changes from this Pull Request in 🚗 Automotive by scanning the QR code below to install the corresponding build.
App Name 🚗 Automotive
Build TypedebugProd
Commitafedd3f
Direct Downloadpocketcasts-automotive-prototype-build-pr3463-afedd3f.apk
📲 You can test the changes from this Pull Request in ⌚ Wear by scanning the QR code below to install the corresponding build.
App Name ⌚ Wear
Build TypedebugProd
Commitafedd3f
Direct Downloadpocketcasts-wear-prototype-build-pr3463-afedd3f.apk

FYI: This job will be then used by 'buildkite-ci' and configured as a
'buildkite_pipeline_schedule' with a weekly frequency.

PS: The targeted 'pipeline' related jobs are:
- App
- Lint
- Unit Tests
- Android tests
FYI: The targeted 'pipeline' related jobs are:
- App
- Lint
- Unit Tests
- Android Tests
Otherwise, running 'lintDebug', which triggers Lint on all modules will
fail. This is due to the fact that a corresponding 'lint-baseline.xml'
file only exists on these 'app', 'automotive' and 'wear' app related
modules.
Having 'testDebugUnitTest' instead of 'assembleDebugUnitTest' was
actually a copy-pasting oversight. There is no need to run any tests for
the unit tests dependencies to be downloaded.
@ParaskP7 ParaskP7 marked this pull request as ready for review January 21, 2025 15:38
@ParaskP7 ParaskP7 requested a review from a team as a code owner January 21, 2025 15:38
@ParaskP7 ParaskP7 requested review from geekygecko, wzieba and a team and removed request for a team January 21, 2025 15:38
Copy link
Member

@wzieba wzieba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ParaskP7 ParaskP7 merged commit 6bcb4c8 into main Jan 22, 2025
17 checks passed
@ParaskP7 ParaskP7 deleted the ci/enable-dependency-cache-on-ci branch January 22, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Area] Gradle [Type] Core [Type] Tooling Related to the Gradle build scripts and the setup or maintenance of the project build process.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants