Always use user-level pub cache#121802
Conversation
|
@godofredoc you might want to look at the changes to the release packaging script |
dev/bots/prepare_package.dart
Outdated
| /// These archives will be installed in the user-level cache on first | ||
| /// following flutter command that accesses the cache. | ||
| /// | ||
| /// This assumes that all packages currently in the cache are installed from |
There was a problem hiding this comment.
Is this a safe assumption? What about users overriding PUB_HOSTED_URL? https://docs.flutter.dev/community/china#configuring-flutter-to-use-a-mirror-site
There was a problem hiding this comment.
Yes, this assumption is only as a precondition to the function, inside the prepare_package script.
Edited the comment to clarify.
There was a problem hiding this comment.
oh, I missed what library we were in :)
| Future<void> _downloadPubPackageArchives() async { | ||
| final Pool pool = Pool(10); // Number of simultaneous downloads. | ||
| final http.Client client = http.Client(); | ||
| final Directory preloadCache = Directory(path.join(flutterRoot.path, '.pub-preload-cache')); |
There was a problem hiding this comment.
Do we need to add this to the top-level repo .gitignore?
There was a problem hiding this comment.
Yes! good point.
Done
|
merged in upstream to fix linux build tests |
christopherfujino
left a comment
There was a problem hiding this comment.
@Jasguerrero can you give final approval?
zanderso
left a comment
There was a problem hiding this comment.
DBC
Did we manually inspect the results of prepare_package.dart to ensure that it has the same size and rough contents?
There are also many style issues in this PR. In particular, the style guide asks us to avoid breaking a line on an assignment operator. See: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#prefer-a-maximum-line-length-of-80-characters
| final String name = package.key; | ||
| final Map<String, dynamic> versions = package.value as Map<String, dynamic>; | ||
| for (final String version in versions.keys) { | ||
| downloads.add(fetchPackageArchive(name, version)); |
There was a problem hiding this comment.
If the pub cache on CI has multiple versions of the same package, will they all be included in the flutter.zip?
There was a problem hiding this comment.
They should, as we iterate all versions for each package, and we store them as $name-$version.tar.gz.
There was a problem hiding this comment.
Is that the same as the old behavior, or will the release .zip now contain many versions of the same package that aren't needed. Remember that the flutter/flutter pubspec.yaml files pin all packages to a single version.
There was a problem hiding this comment.
We should have exactly the same set of package-versions as before.
The difference is that they are distributed as tar.gz files instead of inside a prepared cache.
We do the same steps to "warm up" a cache (by running pub get for some set of packages) and then, instead of folding that cache inside the zip, we iterate it and download the archive for each package.
There was a problem hiding this comment.
DBC
Did we manually inspect the results of
prepare_package.dartto ensure that it has the same size and rough contents?
I'm working on this currently, will update.
There was a problem hiding this comment.
I ran prepare_package.dart before and after this change on the same beta commit:
dart prepare_package.dart --branch=beta --no-publish --revision=1a0a03a41d6613c10bab23508dee456f184b181b --temp_dir=$HOME/git/tmp/prepare_package
And verified that the set of packages are the same, as well as the versions. The only difference is that after this change the individual packages are stored as tarballs.
If this sticks I can do a follow-up to clean up. |
Follow-up to #121802 resolving some style issues.
Follow-up to flutter#121802 resolving some style issues.
Current flutter has a .pub_cache inside the flutter_root and merges that with ~/.pub_cache if that exists,
With this PR we will always use pubs own resolution for finding the pub cache.
To add packages to the flutter.zip download they are packaged as tar.gz and added to the pub-cache on first run by using the new
pub cache preloadfunctionality.Fixes #37481
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.