-
Notifications
You must be signed in to change notification settings - Fork 5
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] Dependency Cache on CI per Project [without GRADLE_RO_DEP_CACHE] #135
Merged
ParaskP7
merged 7 commits into
trunk
from
gradle/isolate-dependency-cache-per-project-v2
Jan 15, 2025
Merged
[Dependency Cache] Dependency Cache on CI per Project [without GRADLE_RO_DEP_CACHE] #135
ParaskP7
merged 7 commits into
trunk
from
gradle/isolate-dependency-cache-per-project-v2
Jan 15, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 task
Generated by 🚫 Danger |
ParaskP7
force-pushed
the
gradle/isolate-dependency-cache-per-project-v2
branch
9 times, most recently
from
December 20, 2024 15:20
5fef742
to
84a1cb6
Compare
This is done in order to avoid having each client project adding its own project prefix to distinguish the Gradle dependency cache key. Test Only PRs: - WCAndroid: https://github.com/woocommerce/woocommerce-android/ pull/13122 - JP/WPAndroid: https://github.com/wordpress-mobile/WordPress-Android/ pull/21540 For example, for WCAndroid, this would mean that instead of using this 'WOOCOMMERCE' value via this 'GRADLE_DEPENDENCY_CACHE_PROJECT_PREFIX' environment variable, which ultimately is creating the below 'WOOCOMMERCE_GRADLE_DEPENDENCY_CACHE' key, instead, with this change the 'woocommerce-android_GRADLE_DEPENDENCY_CACHE' key will be automatically created, taking the 'woocommerce-android' value from the standard 'BUILDKITE_PIPELINE_SLUG' environment variable. For more info see: p1734350857095859-slack-C020Q0Z579V
This is done in order for us to be able to output the uncompressed cache size during cache restoration, just as it is being done during the cache saving process, for consistency purposes. But, given the fact that are also other clients of this 'restore_cache' script, keeping this parameter optional was the preferred approach in order to not affect, or need to update, any of those other clients of this specific script.
1. On saving, the script will create a new folder, within the 'GRADLE_HOME' space, named 'dependency-cache', where all the contents from 'caches/modules-2' will be copied after the build finishes (minus '*.lock' and 'gc.properties' files, as per the documentation). 2. On restoring, the script will create the 'caches/modules-2' folder, within the 'GRADLE_HOME' space, and extract the saved contents into it and before the build starts. 3. On restoring, the script will also check if 'modules-2' directory exists prior to placing cache. This check is necessary because during 'restore_cache' it might happen that the dependency cache based on this key is not available for download. Thus, no 'dependency-cache/module-2' folder will exist to be copied into the 'caches/modules-2' folder, which will break the script.
This is done in order to differentiate between the 'GRADLE_RO_DEP_CACHE' and the 'GRADLE_DEP_CACHE' caches, and thus be able to test both caching strategies in-parallel, without one overwriting the other during save, or one reusing the other's cache during restore. Test Only PRs: - WCAndroid: https://github.com/woocommerce/woocommerce-android/ pull/13170 - JP/WPAndroid: https://github.com/wordpress-mobile/WordPress-Android/ pull/21550
ParaskP7
force-pushed
the
gradle/isolate-dependency-cache-per-project-v2
branch
from
January 10, 2025 12:02
1d7a5b2
to
94d9f7a
Compare
This was referenced Jan 10, 2025
Merged
wzieba
approved these changes
Jan 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 🎉
ParaskP7
added a commit
to woocommerce/woocommerce-android
that referenced
this pull request
Jan 14, 2025
FYI: This change is done for testing purposes and until the below 'A8C CI Toolkit' #135 PR gets merged to 'trunk'. When that's done, the 'a8c-ci-toolkit' will be updated to '3.9.0' instead. A8C CI Toolkit PR: [Dependency Updates] [Dependency Cache] Dependency Cache on CI per Project [without GRADLE_RO_DEP_CACHE] #135 - Automattic/a8c-ci-toolkit-buildkite-plugin#135
iangmaia
reviewed
Jan 14, 2025
10 tasks
iangmaia
reviewed
Jan 14, 2025
With this change only the compressed cache size is being measured and echoed simply as 'cache size'. There is no real need to overcomplicate things by echoing both, the compresses and uncompressed cache size.
ParaskP7
added a commit
to woocommerce/woocommerce-android
that referenced
this pull request
Jan 14, 2025
FYI: This change is done for testing purposes and until the below 'A8C CI Toolkit' #135 PR gets merged to 'trunk'. When that's done, the 'a8c-ci-toolkit' will be updated to '3.9.0' instead. A8C CI Toolkit PR: [Dependency Updates] [Dependency Cache] Dependency Cache on CI per Project [without GRADLE_RO_DEP_CACHE] #135 - Automattic/a8c-ci-toolkit-buildkite-plugin#135
iangmaia
reviewed
Jan 14, 2025
iangmaia
approved these changes
Jan 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good 👍
ParaskP7
added a commit
to woocommerce/woocommerce-android
that referenced
this pull request
Jan 15, 2025
FYI: This change is done for testing purposes and until the below 'A8C CI Toolkit' #135 PR gets merged to 'trunk'. When that's done, the 'a8c-ci-toolkit' will be updated to '3.9.0' instead. A8C CI Toolkit PR: [Dependency Updates] [Dependency Cache] Dependency Cache on CI per Project [without GRADLE_RO_DEP_CACHE] #135 - Automattic/a8c-ci-toolkit-buildkite-plugin#135
ParaskP7
added a commit
that referenced
this pull request
Jan 15, 2025
As part of #135 and this last 1dda7bd commit I incorrectly removed the 'DEP_CACHE_FOLDER_NAME' variable. Without this variable set, placing Gradle dependency cache is not working as expected due to the fact that this 'DEP_CACHE_FOLDER_NAME' variable is now unbound. And this makes this whole dependency cache solution not working at all.
1 task
ParaskP7
added a commit
that referenced
this pull request
Jan 15, 2025
FYI: Lint is now failing otherwise: https://buildkite.com/automattic/ ci-toolkit-buildkite-plugin/builds/ 894#01946971-8ca9-4e6b-8024-da9e25f85121 PS: I wasn't aware about this process and thus missed updating both, the 'README' and 'CHANGELOG' with 3.9.0 release info after merging #135 by creating a separate 'release/3.9.0' branch and PR for release purposes. Instead, I just went and drafted a new release directly from GitHub and the project's releases' page. Example Release Process Related PR: https://github.com/Automattic/ a8c-ci-toolkit-buildkite-plugin/pull/137
1 task
ParaskP7
added a commit
that referenced
this pull request
Jan 15, 2025
* Gradle: Fix dependency cache As part of #135 and this last 1dda7bd commit I incorrectly removed the 'DEP_CACHE_FOLDER_NAME' variable. Without this variable set, placing Gradle dependency cache is not working as expected due to the fact that this 'DEP_CACHE_FOLDER_NAME' variable is now unbound. And this makes this whole dependency cache solution not working at all. * Release: Update `README` and `CHANGELOG` with 3.9.0 release info (#135) FYI: Lint is now failing otherwise: https://buildkite.com/automattic/ ci-toolkit-buildkite-plugin/builds/ 894#01946971-8ca9-4e6b-8024-da9e25f85121 PS: I wasn't aware about this process and thus missed updating both, the 'README' and 'CHANGELOG' with 3.9.0 release info after merging #135 by creating a separate 'release/3.9.0' branch and PR for release purposes. Instead, I just went and drafted a new release directly from GitHub and the project's releases' page. Example Release Process Related PR: https://github.com/Automattic/ a8c-ci-toolkit-buildkite-plugin/pull/137 * Release: Add 'CHANGELOG' entry
ParaskP7
added a commit
to wordpress-mobile/WordPress-Android
that referenced
this pull request
Jan 15, 2025
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
5 tasks
ParaskP7
added a commit
to wordpress-mobile/WordPress-Android
that referenced
this pull request
Jan 17, 2025
* CI: Update a8c-ci-toolkit to 3.9.1 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 * CI: Add a scheduled dependency cache job (save cache) FYI: This job will be then used by 'buildkite-ci' and configured as a 'buildkite_pipeline_schedule' with a weekly frequency. PS.1: The targeted 'pipeline' related jobs are: - Mobile App - Lint - Unit Tests - Android tests PS.2: Since the 'WordPress' app is being build from the very same codebase as the 'Jetpack' app, targeting only the 'Jetpack' related 'pipeline' jobs are enough to download and cache all the dependencies required for both apps. * CI: Fix wrongly defined command related double quotes on pipeline jobs Otherwise, using 'multi-cmd' will produce 'no such file or directory' type of errors. * CI: Add restore cache and run on targeted pipeline related jobs only FYI: The targeted 'pipeline' related jobs are: - Mobile App - Lint - Unit Tests - Android Tests (Commented Out) PS.1: The 'detekt' and 'checkstyle' jobs aren't targeted because they only take about 30+ seconds of network request to download all the dependencies needed for those specific jobs, which is about the same time it takes for the dependency cache to actually be restored (20+ seconds). Thus, this optimization is not really worth it for these specific jobs. For all those other jobs targeted, it take more than a minute of network requests to download all the dependencies needed, and as such worth the diff is worth it. PS.2: Although the 'Android Tests' are commented-out, I chose to include cache restoration into those as well, just in case they will be reactivated at some point in the future. * CI: Move restore cache call to individual .sh script files WCAndroid PR Comment: https://github.com/woocommerce/ woocommerce-android/pull/13303#discussion_r1916752265 * CI: Fix wrongly defined command related double quotes on pipeline jobs When using 'single-cmd' and not using this double quotes structure it is is producing 'did not find expected key' type of errors. * Docs: Add gradlew test suite to comment on save cache for unit tests
ParaskP7
added a commit
to Automattic/pocket-casts-android
that referenced
this pull request
Jan 20, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Project Thread: paaHJt-7CE-p2
Related: #134 + buildkite-ci#570
(Softly) Depends On:
Description
This change:
BUILDKITE_PIPELINE_SLUG
) to the existing gradle dependency cache key to enable dependency cache per project. (3b051ba)$GRADLE_HOME/read-only-dependency-cache
directory), with the more basic GRADLE_DEP_CACHE dependency cache mechanism (using$GRADLE_HOME/dependency-cache
directory), for save/restore. (61b1d9d)V2
) to the existing gradle dependency cache key to differentiate between the two, the previousGRADLE_RO_DEP_CACHE
and the newGRADLE_DEP_CACHE
dependency cache mechanisms. This was purely done for testing purposes, but I think it might be wise for us to keep this versioning system in place, just in case we update the mechanism again in the future and want to effectively test, then utilize that new change. PS: I am very open to feedback on that. (94d9f7a)Note
Enhancing the save_cache and restore_cache scripts (2.) will positively affect all clients of these scripts, mainly improve things by logging some more information. But, do think if there is going to be a case when these changes might negatively effect some or all those other clients (`I couldn't).
Testing Instructions
This
GRADLE_DEP_CACHE
version ofa8c-ci-toolkit
was thoroughly tested via the below test-only PRs, via the help of theandroid-staging
agents (see buildkite-ci#570):To help you assessing that this change is safe use to use and will not cause any trouble for any project, try and follow the below:
local pre-command hook
has run).assemble
task starting, restore cache gets triggered:assemble
tasks starts, verify that there is NO mention of aread-only dependency cache
cache.local pre-command hook
has run).assemble
task starting, restore cache gets triggered:assemble
tasks starts, verify that there is NO mention of aread-only dependency cache
cache.Note
The
GRADLE_RO_DEP_CACHE
version ofa8c-ci-toolkit
was also tested via the below test-only PRs:Merge Instructions
restore cache hook removed
)restore cache hook removed
)save cache trigger removed
)do not merge
label.Note
These WCAndroid#13288 + FluxC#3125 + ADC#39 PRs are not necessarily needed prior to merging this change, but it is better to clean things up and avoid any confusion with relation to having save/restore working on client/libraries projects, while it is actually not (and shouldn't be as of yet).
CHANGELOG.md
if necessary.