mirror of
https://github.com/flutter/packages.git
synced 2025-08-06 17:28:42 +08:00

Adds the ability to replace portions of the `flutter create`d 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 https://github.com/flutter/flutter/issues/125621 and https://github.com/flutter/flutter/issues/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 https://github.com/flutter/flutter/issues/125689
359 lines
16 KiB
YAML
359 lines
16 KiB
YAML
gcp_credentials: ENCRYPTED[!9c8e92e8da192ce2a51b7d4ed9948c4250d0bae3660193d9b901196c9692abbebe784d4a32e9f38b328571d65f6e7aed!]
|
|
|
|
# Run on PRs and main branch post submit only. Don't run tests when tagging.
|
|
only_if: $CIRRUS_TAG == '' && ($CIRRUS_PR != '' || $CIRRUS_BRANCH == 'main')
|
|
env:
|
|
CHANNEL: "master" # Default to master when not explicitly set by a task.
|
|
PLUGIN_TOOL_COMMAND: "dart ./script/tool/bin/flutter_plugin_tools.dart"
|
|
|
|
install_chrome_linux_template: &INSTALL_CHROME_LINUX
|
|
env:
|
|
CHROME_NO_SANDBOX: true
|
|
CHROME_DOWNLOAD_DIR: /tmp/chromium
|
|
CHROME_EXECUTABLE: $CHROME_DOWNLOAD_DIR/chrome-linux/chrome
|
|
CHROMEDRIVER_EXECUTABLE: $CHROME_DOWNLOAD_DIR/chromedriver/chromedriver
|
|
PATH: $PATH:$CHROME_DOWNLOAD_DIR/chrome-linux
|
|
install_chromium_script:
|
|
# Install a pinned version of Chromium and its corresponding ChromeDriver.
|
|
# Setting CHROME_EXECUTABLE above causes this version to be used for tests.
|
|
- ./script/install_chromium.sh
|
|
|
|
tool_setup_template: &TOOL_SETUP_TEMPLATE
|
|
tool_setup_script:
|
|
- .ci/scripts/prepare_tool.sh
|
|
|
|
macos_template: &MACOS_TEMPLATE
|
|
# Only one macOS task can run in parallel without credits, so use them for
|
|
# PRs on macOS.
|
|
use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true'
|
|
macos_instance:
|
|
image: ghcr.io/cirruslabs/macos-ventura-xcode:14.3
|
|
|
|
flutter_upgrade_template: &FLUTTER_UPGRADE_TEMPLATE
|
|
upgrade_flutter_script:
|
|
# Channels that are part of our normal test matrix use a pinned,
|
|
# auto-rolled version to prevent out-of-band CI failures due to changes in
|
|
# Flutter.
|
|
- TARGET_TREEISH=$CHANNEL
|
|
- if [[ "$CHANNEL" == "master" || "$CHANNEL" == "stable" ]]; then
|
|
- TARGET_TREEISH=$(< .ci/flutter_$CHANNEL.version)
|
|
- fi
|
|
# Ensure that the repository has all the branches.
|
|
- cd $FLUTTER_HOME
|
|
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
|
- git fetch origin
|
|
# Switch to the requested channel.
|
|
- git checkout $TARGET_TREEISH
|
|
# When using a branch rather than a hash or version tag, reset to the
|
|
# upstream branch rather than using pull, since the base image can sometimes
|
|
# be in a state where it has diverged from upstream (!).
|
|
- if [[ "$TARGET_TREEISH" == "$CHANNEL" ]] && [[ "$CHANNEL" != *"."* ]]; then
|
|
- git reset --hard @{u}
|
|
- fi
|
|
# Run doctor to allow auditing of what version of Flutter the run is using.
|
|
- flutter doctor -v
|
|
<< : *TOOL_SETUP_TEMPLATE
|
|
|
|
# Ensures that the latest versions of all of the 1P packages can be used
|
|
# together. See script/configs/exclude_all_packages_app.yaml for exceptions.
|
|
build_all_packages_app_template: &BUILD_ALL_PACKAGES_APP_TEMPLATE
|
|
create_all_packages_app_script:
|
|
- $PLUGIN_TOOL_COMMAND create-all-packages-app --output-dir=. --exclude script/configs/exclude_all_packages_app.yaml
|
|
build_all_packages_debug_script:
|
|
- cd all_packages
|
|
- if [[ "$BUILD_ALL_ARGS" == "web" ]]; then
|
|
- echo "Skipping; web does not support debug builds"
|
|
- else
|
|
- flutter build $BUILD_ALL_ARGS --debug
|
|
- fi
|
|
build_all_packages_release_script:
|
|
- cd all_packages
|
|
- flutter build $BUILD_ALL_ARGS --release
|
|
|
|
# Light-workload Linux tasks.
|
|
# These use default machines, with fewer CPUs, to reduce pressure on the
|
|
# concurrency limits.
|
|
task:
|
|
<< : *FLUTTER_UPGRADE_TEMPLATE
|
|
gke_container:
|
|
dockerfile: .ci/Dockerfile
|
|
builder_image_name: docker-builder-linux # gce vm image
|
|
builder_image_project: flutter-cirrus
|
|
cluster_name: test-cluster
|
|
zone: us-central1-a
|
|
namespace: default
|
|
matrix:
|
|
# Repository rules and best-practice enforcement.
|
|
# Only channel-agnostic tests should go here since it is only run once
|
|
# (on Flutter master).
|
|
- name: repo_checks
|
|
always:
|
|
format_script: ./script/tool_runner.sh format --fail-on-change
|
|
license_script: $PLUGIN_TOOL_COMMAND license-check
|
|
# The major and minor version here should match the lowest version
|
|
# analyzed in legacy_version_analyze.
|
|
pubspec_script: ./script/tool_runner.sh pubspec-check --min-min-flutter-version=3.3.0 --allow-dependencies=script/configs/allowed_unpinned_deps.yaml --allow-pinned-dependencies=script/configs/allowed_pinned_deps.yaml
|
|
readme_script:
|
|
- ./script/tool_runner.sh readme-check
|
|
# Re-run with --require-excerpts, skipping packages that still need
|
|
# to be converted. Once https://github.com/flutter/flutter/issues/102679
|
|
# has been fixed, this can be removed and there can just be a single
|
|
# run with --require-excerpts and no exclusions.
|
|
- ./script/tool_runner.sh readme-check --require-excerpts --exclude=script/configs/temp_exclude_excerpt.yaml
|
|
dependabot_script: $PLUGIN_TOOL_COMMAND dependabot-check
|
|
gradle_script: $PLUGIN_TOOL_COMMAND gradle-check
|
|
version_script:
|
|
# For pre-submit, pass the PR labels to the script to allow for
|
|
# check overrides.
|
|
# For post-submit, ignore platform version breaking version changes
|
|
# and missing version/CHANGELOG detection since the labels aren't
|
|
# available outside of the context of the PR.
|
|
- if [[ $CIRRUS_PR == "" ]]; then
|
|
- ./script/tool_runner.sh version-check --ignore-platform-interface-breaks
|
|
- else
|
|
- ./script/tool_runner.sh version-check --check-for-missing-changes --pr-labels="$CIRRUS_PR_LABELS"
|
|
- fi
|
|
publishable_script: ./script/tool_runner.sh publish-check --allow-pre-release
|
|
federated_safety_script:
|
|
# This check is only meaningful for PRs, as it validates changes
|
|
# rather than state.
|
|
- if [[ $CIRRUS_PR == "" ]]; then
|
|
- echo "Only run in presubmit"
|
|
- else
|
|
- ./script/tool_runner.sh federation-safety-check
|
|
- fi
|
|
- name: analyze
|
|
env:
|
|
matrix:
|
|
CHANNEL: "master"
|
|
CHANNEL: "stable"
|
|
analyze_tool_script:
|
|
- cd script/tool
|
|
- dart analyze --fatal-infos
|
|
analyze_script:
|
|
# DO NOT change the custom-analysis argument here without changing the Dart repo.
|
|
# See the comment in script/configs/custom_analysis.yaml for details.
|
|
- ./script/tool_runner.sh analyze --custom-analysis=script/configs/custom_analysis.yaml
|
|
pathified_analyze_script:
|
|
# Re-run analysis with path-based dependencies to ensure that publishing
|
|
# the changes won't break analysis of other packages in the respository
|
|
# that depend on it.
|
|
- ./script/tool_runner.sh make-deps-path-based --target-dependencies-with-non-breaking-updates
|
|
# This uses --run-on-dirty-packages rather than --packages-for-branch
|
|
# since only the packages changed by 'make-deps-path-based' need to be
|
|
# checked.
|
|
- $PLUGIN_TOOL_COMMAND analyze --run-on-dirty-packages --log-timing --custom-analysis=script/configs/custom_analysis.yaml
|
|
# Restore the tree to a clean state, to avoid accidental issues if
|
|
# other script steps are added to this task.
|
|
- git checkout .
|
|
# Does a sanity check that packages at least pass analysis on the N-1 and N-2
|
|
# versions of Flutter stable if the package claims to support that version.
|
|
# This is to minimize accidentally making changes that break old versions
|
|
# (which we don't commit to supporting, but don't want to actively break)
|
|
# without updating the constraints.
|
|
# Note: The versions below should be manually updated after a new stable
|
|
# version comes out.
|
|
- name: legacy_version_analyze
|
|
depends_on: analyze
|
|
matrix:
|
|
# Change the arguments to pubspec-check when changing these values.
|
|
env:
|
|
CHANNEL: "3.7.12"
|
|
DART_VERSION: "2.17.6"
|
|
env:
|
|
CHANNEL: "3.3.10"
|
|
DART_VERSION: "2.18.6"
|
|
package_prep_script:
|
|
# Allow analyzing packages that use a dev dependency with a higher
|
|
# minimum Flutter/Dart version than the package itself.
|
|
- ./script/tool_runner.sh remove-dev-dependencies
|
|
analyze_script:
|
|
# Only analyze lib/; non-client code doesn't need to work on
|
|
# all supported legacy version.
|
|
- ./script/tool_runner.sh analyze --lib-only --skip-if-not-supporting-flutter-version="$CHANNEL" --skip-if-not-supporting-dart-version="$DART_VERSION" --custom-analysis=script/configs/custom_analysis.yaml
|
|
# Does a sanity check that packages pass analysis with the lowest possible
|
|
# versions of all dependencies. This is to catch cases where we add use of
|
|
# new APIs but forget to update minimum versions of dependencies to where
|
|
# those APIs are introduced.
|
|
- name: downgraded_analyze
|
|
depends_on: analyze
|
|
analyze_script:
|
|
- ./script/tool_runner.sh analyze --downgrade --custom-analysis=script/configs/custom_analysis.yaml
|
|
- name: readme_excerpts
|
|
env:
|
|
CIRRUS_CLONE_SUBMODULES: true
|
|
script: ./script/tool_runner.sh update-excerpts --fail-on-change
|
|
### Web tasks ###
|
|
- name: web-build_all_packages
|
|
env:
|
|
BUILD_ALL_ARGS: "web"
|
|
matrix:
|
|
CHANNEL: "master"
|
|
CHANNEL: "stable"
|
|
<< : *BUILD_ALL_PACKAGES_APP_TEMPLATE
|
|
### Linux desktop tasks ###
|
|
- name: linux-build_all_packages
|
|
env:
|
|
BUILD_ALL_ARGS: "linux"
|
|
matrix:
|
|
CHANNEL: "master"
|
|
CHANNEL: "stable"
|
|
<< : *BUILD_ALL_PACKAGES_APP_TEMPLATE
|
|
- name: linux-platform_tests
|
|
# Don't run full platform tests on both channels in pre-submit.
|
|
skip: $CIRRUS_PR != '' && $CHANNEL == 'stable'
|
|
env:
|
|
matrix:
|
|
CHANNEL: "master"
|
|
CHANNEL: "stable"
|
|
build_script:
|
|
- ./script/tool_runner.sh build-examples --linux
|
|
native_test_script:
|
|
- xvfb-run ./script/tool_runner.sh native-test --linux --no-integration
|
|
drive_script:
|
|
- xvfb-run ./script/tool_runner.sh drive-examples --linux --exclude=script/configs/exclude_integration_linux.yaml
|
|
|
|
# Heavy-workload Linux tasks.
|
|
# These use machines with more CPUs and memory, so will reduce parallelization
|
|
# for non-credit runs.
|
|
task:
|
|
<< : *FLUTTER_UPGRADE_TEMPLATE
|
|
gke_container:
|
|
dockerfile: .ci/Dockerfile
|
|
builder_image_name: docker-builder-linux # gce vm image
|
|
builder_image_project: flutter-cirrus
|
|
cluster_name: test-cluster
|
|
zone: us-central1-a
|
|
namespace: default
|
|
cpu: 4
|
|
memory: 16G
|
|
matrix:
|
|
### Platform-agnostic tasks ###
|
|
- name: dart_unit_tests
|
|
env:
|
|
matrix:
|
|
PACKAGE_SHARDING: "--shardIndex 0 --shardCount 2"
|
|
PACKAGE_SHARDING: "--shardIndex 1 --shardCount 2"
|
|
matrix:
|
|
CHANNEL: "master"
|
|
CHANNEL: "stable"
|
|
unit_test_script:
|
|
- ./script/tool_runner.sh test --exclude=script/configs/dart_unit_tests_exceptions.yaml
|
|
pathified_unit_test_script:
|
|
# Run tests with path-based dependencies to ensure that publishing
|
|
# the changes won't break tests of other packages in the repository
|
|
# that depend on it.
|
|
- ./script/tool_runner.sh make-deps-path-based --target-dependencies-with-non-breaking-updates
|
|
- $PLUGIN_TOOL_COMMAND test --run-on-dirty-packages --exclude=script/configs/dart_unit_tests_exceptions.yaml
|
|
- name: linux-custom_package_tests
|
|
env:
|
|
PATH: $PATH:/usr/local/bin
|
|
matrix:
|
|
CHANNEL: "master"
|
|
CHANNEL: "stable"
|
|
<< : *INSTALL_CHROME_LINUX
|
|
local_tests_script:
|
|
- ./script/tool_runner.sh custom-test
|
|
### Android tasks ###
|
|
- name: android-platform_tests
|
|
# Don't run full platform tests on both channels in pre-submit.
|
|
skip: $CIRRUS_PR != '' && $CHANNEL == 'stable'
|
|
env:
|
|
matrix:
|
|
PACKAGE_SHARDING: "--shardIndex 0 --shardCount 8"
|
|
PACKAGE_SHARDING: "--shardIndex 1 --shardCount 8"
|
|
PACKAGE_SHARDING: "--shardIndex 2 --shardCount 8"
|
|
PACKAGE_SHARDING: "--shardIndex 3 --shardCount 8"
|
|
PACKAGE_SHARDING: "--shardIndex 4 --shardCount 8"
|
|
PACKAGE_SHARDING: "--shardIndex 5 --shardCount 8"
|
|
PACKAGE_SHARDING: "--shardIndex 6 --shardCount 8"
|
|
PACKAGE_SHARDING: "--shardIndex 7 --shardCount 8"
|
|
matrix:
|
|
CHANNEL: "master"
|
|
CHANNEL: "stable"
|
|
MAPS_API_KEY: ENCRYPTED[d6583b08f79f91ea4844c77460f04539965e46ad2fd97fb7c062b4dfe88016228b86ebe8c220ab4187e0c4bd773dc1e7]
|
|
GCLOUD_FIREBASE_TESTLAB_KEY: ENCRYPTED[1a2eebf9367197bbe812d9a0ea83a53a05aeba4bb5e4964fe6a69727883cd87e51238d39237b1f80b0894c48419ac268]
|
|
build_script:
|
|
- ./script/tool_runner.sh build-examples --apk
|
|
lint_script:
|
|
- ./script/tool_runner.sh lint-android # must come after build-examples
|
|
native_unit_test_script:
|
|
# Native integration tests are handled by Firebase Test Lab below, so
|
|
# only run unit tests.
|
|
# Must come after build-examples.
|
|
- ./script/tool_runner.sh native-test --android --no-integration --exclude script/configs/exclude_native_unit_android.yaml
|
|
firebase_test_lab_script:
|
|
- if [[ -n "$GCLOUD_FIREBASE_TESTLAB_KEY" ]]; then
|
|
- echo $GCLOUD_FIREBASE_TESTLAB_KEY > ${HOME}/gcloud-service-key.json
|
|
- ./script/tool_runner.sh firebase-test-lab --device model=redfin,version=30 --device model=starqlteue,version=26 --exclude=script/configs/exclude_integration_android.yaml
|
|
- else
|
|
- echo "This user does not have permission to run Firebase Test Lab tests."
|
|
- fi
|
|
# Upload the full lint results to Cirrus to display in the results UI.
|
|
always:
|
|
android-lint_artifacts:
|
|
path: "**/reports/lint-results-debug.xml"
|
|
type: text/xml
|
|
format: android-lint
|
|
- name: android-build_all_packages
|
|
env:
|
|
BUILD_ALL_ARGS: "apk"
|
|
matrix:
|
|
CHANNEL: "master"
|
|
CHANNEL: "stable"
|
|
<< : *BUILD_ALL_PACKAGES_APP_TEMPLATE
|
|
create_all_packages_app_legacy_script:
|
|
- $PLUGIN_TOOL_COMMAND create-all-packages-app --legacy-source=.ci/legacy_project/all_packages --output-dir=legacy/ --exclude script/configs/exclude_all_packages_app.yaml
|
|
build_all_packages_legacy_script:
|
|
- cd legacy/all_packages
|
|
- flutter build $BUILD_ALL_ARGS --debug
|
|
### Web tasks ###
|
|
- name: web-platform_tests
|
|
env:
|
|
matrix:
|
|
PACKAGE_SHARDING: "--shardIndex 0 --shardCount 2"
|
|
PACKAGE_SHARDING: "--shardIndex 1 --shardCount 2"
|
|
matrix:
|
|
CHANNEL: "master"
|
|
CHANNEL: "stable"
|
|
<< : *INSTALL_CHROME_LINUX
|
|
chromedriver_background_script:
|
|
- $CHROMEDRIVER_EXECUTABLE --port=4444
|
|
build_script:
|
|
- ./script/tool_runner.sh build-examples --web
|
|
drive_script:
|
|
- ./script/tool_runner.sh drive-examples --web --exclude=script/configs/exclude_integration_web.yaml
|
|
- name: web_benchmarks_test
|
|
env:
|
|
matrix:
|
|
CHROMIUM_BUILD: "950363" # Chromium 98.0.4758.0
|
|
CHROMIUM_BUILD: "1097615" # Chromium 111
|
|
<< : *INSTALL_CHROME_LINUX
|
|
script:
|
|
- cd packages/web_benchmarks/testing/test_app
|
|
- flutter packages get
|
|
- cd ../..
|
|
- flutter packages get
|
|
- dart testing/web_benchmarks_test.dart
|
|
|
|
# macOS tasks.
|
|
task:
|
|
<< : *FLUTTER_UPGRADE_TEMPLATE
|
|
<< : *MACOS_TEMPLATE
|
|
matrix:
|
|
- name: macos-custom_package_tests
|
|
env:
|
|
PATH: $PATH:/usr/local/bin
|
|
matrix:
|
|
CHANNEL: "master"
|
|
CHANNEL: "stable"
|
|
# Create an iPhone 13, to match what is available on LUCI, since Pigeon tests
|
|
# currently have a hard-coded device.
|
|
create_simulator_script:
|
|
- xcrun simctl list
|
|
- xcrun simctl create "iPhone 13" com.apple.CoreSimulator.SimDeviceType.iPhone-13 com.apple.CoreSimulator.SimRuntime.iOS-16-4
|
|
local_tests_script:
|
|
# script/configs/linux_only_custom_test.yaml
|
|
# Custom tests need Chrome for these packages. (They run in linux-custom_package_tests)
|
|
- ./script/tool_runner.sh custom-test --exclude=script/configs/linux_only_custom_test.yaml
|