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 Analysis] Add Android Gradle Plugin #148

Merged
merged 5 commits into from
Jul 5, 2024

Conversation

ParaskP7
Copy link
Contributor

@ParaskP7 ParaskP7 commented Jul 5, 2024

Project Thread: paaHJt-6yU-p2
Required By: BuildkiteCI#473
Depends On:

This PR adds the dependency analysis Android Gradle plugin to this project, for dependency analysis purposes.

Description

For now, only the main buildHealth task is going to be utilized and produce data once every week on CI (see this commit and this PR). Amongst other, this data will include the following:

  • Number of modules (projectCount)
  • Unused dependencies which should be removed (unusedCount)
  • Transitive dependencies which should be declared directly (undeclaredCount)
  • Existing dependencies which should be modified to be as indicated (misDeclaredCount)
  • Dependencies which could be compile-only (compileOnlyCount)
  • Dependencies which should be removed or changed to runtime-only (runtimeOnlyCount)

Afterward, this data will get collected from CI and uploaded to our Apps Metrics infrastructure, for visualization and alerting purposes.

Testing Steps

  1. Local: Run the ./gradlew buildHealth task and verify that under the root level build/reports/dependency-analysis folder you get the below 2 reports both, in JSON and text format:
    • build-health-report.json
    • build-health-report.txt
  2. CI: Using the New Build 🟢 CI button for UtilsAndroid, test this standalone dependency analysis job (see form below). Then:
    • When CI starts, make sure that adding /meta-data to that CI build's URL (example) will give you one extra meta-data, the pipeline_file one, with a value of schedules/dependency-analysis.yml (see screenshot below):
    • When CI completes, make sure that the below 2 CI artifacts are available both, in JSON and text format:
      • build/reports/dependency-analysis/build-health-report.json
      • build/reports/dependency-analysis/build-health-report.txt
  3. REST: Using the Buildkite's REST API you could query for this type of builds, using the meta-data query parameter, and see that the result is the expect one. Use this query: https://api.buildkite.com/v2/organizations/automattic/pipelines/wordpress-utils-android/builds?meta_data[pipeline_file]=schedules/dependency-analysis.yml

image

image

FYI: This commit adds a previous version of the plugin (1.28.0) and not
the latest version (1.32.0). This is because the latest version gets
stuck during the 'computeActualUsage' phase and increases the build time
of the 'buildHealth' task by as much as five times (5x).

For more info see: Stuck in computeActualUsageDebug for many minutes
#1186 (https://github.com/autonomousapps/
dependency-analysis-gradle-plugin/issues/1186)
FYI: With this configuration only the 'debug' variant (build type) for
for all modules is going to be included, with the rest of the variants
ignored.
FYI:
1. This job will be then used by 'buildkite-ci' and configured as a
'buildkite_pipeline_schedule' with a weekly frequently.
2. This job will also notify on the android-core-notifs slack channel
on a build failure.
…ndroid into build/dependency-analysis-android-gradle-plugin
@ParaskP7 ParaskP7 marked this pull request as ready for review July 5, 2024 10:53
@ParaskP7 ParaskP7 requested a review from wzieba July 5, 2024 10:53
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.15.0
Copy link

Choose a reason for hiding this comment

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

Can we use the newest version?

Suggested change
- automattic/a8c-ci-toolkit#2.15.0
- automattic/a8c-ci-toolkit#3.4.2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would love to do that @wzieba but I really don't want to make a change that can potentially block this PR (ie. failing CI, etc), me not knowing exactly what the diff between the 2 version are. 🤷

Can I maybe do that on a separate PR next week, and do that for all these 6 libraries I have been (Login, Media Picker) and will be touching next week (Aztec, About, Tracks)? 🙏

Copy link

Choose a reason for hiding this comment

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

What works best for you - the only breaking difference is related nvm installation, but if you prefer to do this in a separate PR, it's ok to me too 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, great, I've noted this down and will create separate PRs for each library I have been or will be touching next week. 🗒️

the only breaking difference is related nvm installation

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI @wzieba that this is now done: #150

@ParaskP7 ParaskP7 merged commit 5063601 into trunk Jul 5, 2024
8 checks passed
@ParaskP7 ParaskP7 deleted the build/dependency-analysis-android-gradle-plugin branch July 5, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants