Skip to content

[Tooling] Add google owned cache for dependencies as an option in ci - #4567

Merged
auto-submit[bot] merged 18 commits into
flutter:mainfrom
reidbaker:i120119-artifact-hub-poc
Aug 2, 2023
Merged

auto-submit[bot] merged 18 commits into
flutter:mainfrom
reidbaker:i120119-artifact-hub-poc

Conversation

@reidbaker

@reidbaker reidbaker commented Jul 26, 2023 •

Copy link
Copy Markdown
Contributor

Proof of concept of a package using artifact hub.
Artifact hub is a google owned and managed cache of google/maven dependencies.
Using this cache should decrease the number of flakes related to downloading dependencies along with future benefits of licence analysis and security alerts.

Read more at go/artifact-hub#maven
flutter/flutter/issues/120119

Next steps:
Enable a new env variable on CI servers. https://flutter-review.googlesource.com/c/recipes/+/48260 cl/551888350
Merge this PR.
Apply this change to all packages
Add enforcement as part of the gradle check.

Developers have a new dependency for buildscript but it is publicly available, so I added a next changelog.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes].
  • I updated CHANGELOG.md to add a description of the change, [following repository CHANGELOG style].
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

Requried to be an authenticated googler
`gcloud auth application-default login`

Useful links
https://g3doc.corp.google.com/company/teams/artifact-hub/index.md?cl=head#maven
https://github.com/GoogleCloudPlatform/artifact-registry-maven-tools/blob/master/README.md

Useful command
```
gcloud artifacts print-settings mvn \
    --project=artifact-foundry-prod \
    --repository=maven-3p \
    --location=us
```
@reidbaker
reidbaker requested a review from camsim99 as a code owner July 26, 2023 15:49
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@reidbaker reidbaker changed the title y [Tooling] Add google owned cache for dependencies as an option in ci Jul 26, 2023
Comment thread packages/camera/camera_android_camerax/example/android/build.gradle Outdated
Comment thread GRADLE_STRUCTURE.md Outdated
Comment thread GRADLE_STRUCTURE.md Outdated
Comment thread packages/camera/camera_android_camerax/example/android/build.gradle Outdated

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Comment thread GRADLE_STRUCTURE.md Outdated
Comment thread GRADLE_STRUCTURE.md Outdated
@@ -0,0 +1,16 @@
# Gradle Structure

ghost Jul 28, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Having seen the details here, I think a wiki page referenced from https://github.com/flutter/flutter/wiki/Understanding-Packages-tests#external-build-dependencies and maybe https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure would probably be better than an md file.

ghost Jul 28, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok in that case consider the md files content for review and I will remove and update the wiki before merging.

Comment thread GRADLE_STRUCTURE.md Outdated
@@ -0,0 +1,16 @@
# Gradle Structure

`package/example/android/settings.gradle` imports the flutter tooling, includes the app directory, and configures GoogleCloudPlatform/artifact-registry-maven-tools for use in ci.

ghost Jul 28, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: CI

ghost Jul 28, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread GRADLE_STRUCTURE.md Outdated

`package/example/android/settings.gradle` imports the flutter tooling, includes the app directory, and configures GoogleCloudPlatform/artifact-registry-maven-tools for use in ci.

This repo has a GCP instance that mirrors dependencies available from `google()` and `mavenCentral()` used by ci (or googlers). This gives us redundant uptime for dependency availability.

ghost Jul 28, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nits: CI, Googlers

ghost Jul 28, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread GRADLE_STRUCTURE.md Outdated

Using this cache is not intended or avaiable for contributors outside of CI. We protect that execution with an environment variable `ARTIFACT_HUB_REPOSITORY` to ensure that by default users do not see rejected cloud credentials or errors in builds.

Googlers can debug locally by setting `ARTIFACT_HUB_REPOSITORY` to the valid artifact hub value and authenticating with GCP. To authenticate run `gcloud auth application-default login`. To find artifact hub url use `<url>` section of go/artifact-hub#maven or inspect the value on CI servers. CI uses a service account for billing. That is defined in go/artifact-hub-service-account (googler access only).

ghost Jul 28, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: Googler access

@@ -1,3 +1,7 @@
## NEXT

* Updates android example to be able to use custom use artifactregistery.

ghost Jul 28, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since nobody outside the Flutter team can use this, let's not put it in the CHANGELOG.

ghost Jul 28, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They can if they setup a artifactrepository then setup the env variables on their local machine (I just updated the file to reflect this). I removed the google specific access parts to configuration. Also mechanically there is a new dependency and the changelog thing scolded me.

I can remove this if you want even though there is technically a developer facing change that should not impact the.

ghost Jul 28, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@stuartmorgan-g stuartmorgan-g added the override: no changelog needed Override the check requiring CHANGELOG updates for most changes label Jul 28, 2023
@stuartmorgan-g

ghost commented Jul 28, 2023

Copy link
Copy Markdown
Collaborator

Overriding changelog check: see #4567 (comment)

@reidbaker

ghost commented Jul 28, 2023

Copy link
Copy Markdown
Contributor Author

Approved by artifact hub team via email by sfelix@

@reidbaker

ghost commented Aug 1, 2023

Copy link
Copy Markdown
Contributor Author

@reidbaker reidbaker added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 1, 2023
@reidbaker

ghost commented Aug 1, 2023

Copy link
Copy Markdown
Contributor Author

Confirmed the environment variable was set correctly https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8773957271362564241/+/u/Run_package_tests/download_Dart_and_Android_deps/execution_details and confirmed the artifact hub variable was used Using artifact hub https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8773957271362564241/+/u/Run_package_tests/download_Dart_and_Android_deps/stdout

https://critique.corp.google.com/cl/552818879 had not landed. Links above show our configuration is correct and that if we lose access to artifact hub our builds will not go red. I do not know of a way to verify we are getting the dependencies from the artifact hub server without ssh access to the machine while they are being downloaded.

In a future pr I could make ci only use the artifact hub instance but I am not confident enough yet to make that call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App override: no changelog needed Override the check requiring CHANGELOG updates for most changes p: camera platform-android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants