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

[ci] Add a legacy Android build-all test #4005

Merged
merged 21 commits into from
May 22, 2023

Conversation

stuartmorgan
Copy link
Contributor

@stuartmorgan stuartmorgan commented May 16, 2023

Adds the ability to replace portions of the flutter created app with saved copies, and adds a second build-all phase for Android that uses a Flutter 2.0.6-created android/ directory (AGP 4.1, Gradle 6.7) to catch issues like flutter/flutter#125621 and flutter/flutter#125482 prior to release.

Includes some incidental cleanup:

  • Extracts a helper method for adjusting files, so that this doesn't add even more copies of basically identical code.
    • (This was motivated by an earlier version of the PR that added modifications to several more files, which I ended up undoing, but the cleanup seemed worth keeping.)
  • Adds missing unit test coverage.
  • Reworks the unit tests to use a mock process manager and dummy files, instead of each test actually calling flutter create, which made each new test add several seconds to the unit test suite.
    • While this reduces the integration-style coverage, in practice the integration tests of the repo tooling is the CI itself, so the unit tests should be true unit tests.
  • Changes the non-legacy test to Kotlin; we were still testing with Java even though Kotlin has been the default for quite a while, so we weren't testing what most new users would actually be running. Since we now have a legacy test, I used Java there to cover both.
  • Removes some dead code for modifying the AndroidManifest.xml; when trying to set up unit tests for it I discovered that it no longer matches anything in an actual project. It dates back to the original command, and seems to have been a camera-related hack, which we clearly no longer need since it wasn't working and camera still works in build-all.

This is captured somewhat in the README in the legacy project directory, but to document the approach here: originally I was going to add flags to change individual items (AGP version, Gradle version), but quickly ran into the fact that selective downgrading is extremely fragile. E.g.,:

  • The Kotlin version set in current projects doesn't work when downgrading AGP and Gradle.
  • The app template can unconditionally use anything (e.g., namespace) that the AGP version it uses supports, so arbitrary future breakage is possible.

It's also less useful as a real test of what a plugin client's project likely looks like. Starting with a complete platform directory, and doing whatever the minimal changes are to keep it working, will likely reflect a common real-world scenario. On the flip side, the reason this doesn't use a complete 2.0.6 project, but instead is based on specific platform directories, is that we don't want to waste time manually maintaining, e.g., old Dart code that is irrelevant to the goal of the test. For now this only uses Android because that's where we've seen problems in practice, but we can alway add other legacy platform tests later if we find a need.

Fixes flutter/flutter#125689

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.


It was originally created with Flutter 2.0.6. In general the guidelines are:
- Pieces here should be self-contained; avoid making a hybrid of old and new
projects except at major cut points (e.g., platform directories). This is
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you expound on this a bit in the review? What is a major cut point? The example of platform directories didn't help me understand how to evaluate if flutter has hit another major cut point or not.

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 rewrote it to hopefully be clearer. What I was describing as "cut points" was meant to be about project structure, not Flutter releases. So for instance "the android directory" is a major cut point, whereas "the Java code from the android directory" would not be, because it can be strongly coupled to resources or configs that are not within that subset.

.ci/legacy_project/README.md Show resolved Hide resolved
.cirrus.yml Show resolved Hide resolved
import 'common/package_command.dart';
import 'common/process_runner.dart';
import 'common/repository_package.dart';

const String _outputDirectoryFlag = 'output-dir';
@visibleForTesting

Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace after visibleForTesting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, I forgot the autoformatter wants it after the declaration comment.


const String _projectName = 'all_packages';
/// The name of the build-all-packages project.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the comment state the intended format? For example The name of the build-all-packages project to be passed into flutter create This helps differentiate it from the name of the app or if this is really just a directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -98,80 +114,152 @@ class CreateAllPackagesAppCommand extends PackageCommand {
}

Future<int> _createApp() async {
final io.ProcessResult result = io.Process.runSync(
return processRunner.runAndStream(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this modifying the current all packages test to use kotlin?

Copy link
Contributor Author

@stuartmorgan stuartmorgan May 22, 2023

Choose a reason for hiding this comment

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

Yes; this is mentioned in the PR description. I'm not sure why it wasn't already, given that it's been the default for Flutter developers for a long time.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I read that in the description and was looking for the place where we made the swap. Where in the cl do we test the legacy version with java?

@stuartmorgan stuartmorgan added the autosubmit Merge PR when tree becomes green via auto submit App label May 22, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 22, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented May 22, 2023

auto label is removed for flutter/packages, pr: 4005, due to - The status or check suite downgraded_analyze has failed. Please fix the issues identified (or deflake) before re-applying this label.

@stuartmorgan stuartmorgan added the autosubmit Merge PR when tree becomes green via auto submit App label May 22, 2023
@auto-submit auto-submit bot merged commit 30ebcf3 into flutter:main May 22, 2023
sybrands-place pushed a commit to sybrands-place/packages that referenced this pull request May 23, 2023
* main: (104 commits)
  [various] Remove unnecessary null checks (flutter#4060)
  [ci] Add a legacy Android build-all test (flutter#4005)
  Roll Flutter from ab57304 to 3437189 (5 revisions) (flutter#4062)
  [go_router] Nested stateful navigation with ShellRoute (flutter#2650)
  [go_router] Nested stateful navigation with ShellRoute (flutter#2650)
  [go_router] Nested stateful navigation with ShellRoute (flutter#2650)
  [in_app_purchases] Fix mismatching method signature strings (flutter#4040)
  [go_router] Nested stateful navigation with ShellRoute (flutter#2650)
  [go_router] Nested stateful navigation with ShellRoute (flutter#2650)
  [go_router] Nested stateful navigation with ShellRoute (flutter#2650)
  Roll Flutter from 077d644 to ab57304 (18 revisions) (flutter#4051)
  Roll Flutter from 5ae6438 to 077d644 (23 revisions) (flutter#4043)
  [local_auth] Migrate iOS to Pigeon (flutter#3974)
  [go_router] fix context extension for replaceNamed (flutter#3927)
  [image_picker] Fix crash due to `SecurityException` (flutter#4004)
  Roll Flutter from d0d1feb to 5ae6438 (42 revisions) (flutter#4038)
  [ci] Lower iOS LUCI timeouts (flutter#4035)
  [ci] Increase Android sharding (flutter#4029)
  [flutter_plugin_android_lifecycle] Fix lints (flutter#4030)
  [rfw] Fix a typo in the API documentation (flutter#4023)
  ...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 23, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 23, 2023
flutter/packages@83959fb...d449a17

2023-05-22 [email protected] [various] Remove unnecessary null checks (flutter/packages#4060)
2023-05-22 [email protected] [ci] Add a legacy Android build-all test (flutter/packages#4005)
2023-05-22 [email protected] Roll Flutter from ab57304 to 3437189 (5 revisions) (flutter/packages#4062)
2023-05-22 [email protected] [go_router] Nested stateful navigation with ShellRoute (flutter/packages#2650)
2023-05-22 [email protected] [go_router] Nested stateful navigation with ShellRoute (flutter/packages#2650)
2023-05-22 [email protected] [go_router] Nested stateful navigation with ShellRoute (flutter/packages#2650)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
CaseyHillers pushed a commit to CaseyHillers/flutter that referenced this pull request May 24, 2023
flutter/packages@83959fb...d449a17

2023-05-22 [email protected] [various] Remove unnecessary null checks (flutter/packages#4060)
2023-05-22 [email protected] [ci] Add a legacy Android build-all test (flutter/packages#4005)
2023-05-22 [email protected] Roll Flutter from ab57304 to 3437189 (5 revisions) (flutter/packages#4062)
2023-05-22 [email protected] [go_router] Nested stateful navigation with ShellRoute (flutter/packages#2650)
2023-05-22 [email protected] [go_router] Nested stateful navigation with ShellRoute (flutter/packages#2650)
2023-05-22 [email protected] [go_router] Nested stateful navigation with ShellRoute (flutter/packages#2650)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[packages] Test with old AGP/Gradle in flutter/packages CI
2 participants