.cirrus.yml 30 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633
# CIRRUS CONFIGURATION FILE
# https://cirrus-ci.org/guide/writing-tasks/

web_shard_template: &WEB_SHARD_TEMPLATE
  only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'packages/flutter_web_plugins/**', 'bin/internal/**') || $CIRRUS_PR == ''"
  environment:
    # As of October 2019, the Web shards needed more than 6G of RAM.
    CPU: 2
    MEMORY: 8G
    CHROME_NO_SANDBOX: true
    GOLD_SERVICE_ACCOUNT: ENCRYPTED[3afeea5ac7201151c3d0dc9648862f0462b5e4f55dc600ca8b692319622f7c3eda3d577b1b16cc2ef0311b7314c1c095]
  script:
    - dart --enable-asserts ./dev/bots/test.dart

linux_shard_template: &LINUX_SHARD_TEMPLATE
  environment:
    # Some of the host-only devicelab tests are pretty involved and need a lot of RAM.
    CPU: 2
    MEMORY: 8G
  script:
    - dart --enable-asserts ./dev/bots/test.dart

windows_shard_template: &WINDOWS_SHARD_TEMPLATE
  only_if: "changesInclude('.cirrus.yml', 'dev/**', 'bin/internal/**') || $CIRRUS_PR == ''" # https://github.com/flutter/flutter/issues/41941
  script:
    - dart --enable-asserts ./dev/bots/test.dart

macos_shard_template: &MACOS_SHARD_TEMPLATE
  only_if: "changesInclude('.cirrus.yml', 'dev/**', 'bin/internal/**') || $CIRRUS_PR == ''" # https://github.com/flutter/flutter/issues/41941
  script:
    - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
    - dart --enable-asserts ./dev/bots/test.dart

use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true'

environment:
  # For details about environment variables used in Cirrus, including how encrypted variables work,
  # see https://cirrus-ci.org/guide/writing-tasks/#environment-variables
  GCLOUD_SERVICE_ACCOUNT_KEY: ENCRYPTED[f12abe60f5045d619ef4c79b83dd1e0722a0b0b13dbea95fbe334e2db7fffbcd841a5a92da8824848b539a19afe0c9fb]
  # We change Flutter's directory to include a space in its name (see $CIRRUS_WORKING_DIR) so that
  # we constantly test path names with spaces in them. The FLUTTER_SDK_PATH_WITH_SPACE variable must
  # therefore have a space in it.
  FLUTTER_SDK_PATH_WITH_SPACE: "flutter sdk"
  # We force BOT to true so that all our tools know we're in a CI environment. This avoids any
  # dependency on precisely how Cirrus is detected by our tools.
  BOT: "true"
  # Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they might include non-ASCII
  # characters which makes Gradle crash. See: https://github.com/flutter/flutter/issues/24935
  # TODO(amirha): remove once we've migrated to newer Gradle
  CIRRUS_CHANGE_MESSAGE: ""
  CIRRUS_COMMIT_MESSAGE: ""

# LINUX SHARDS
task:
  container:
    # https://cirrus-ci.org/guide/docker-builder-vm/#dockerfile-as-a-ci-environment
    dockerfile: "dev/ci/docker_linux/Dockerfile"
    cpu: $CPU
    memory: $MEMORY
  environment:
    # We shrink our default resource requirement as much as possible because that way we are more
    # likely to get scheduled. We require 4G of RAM because most of the shards (all but one as of
    # October 2019) just get OOM-killed with less. Some shards may need more. When increasing the
    # requirements for select shards, please leave a comment on those shards saying when you
    # increased the requirements, what numbers you tried, and what the results were.
    CPU: 1 # 0.1-8 without compute credits, 0.1-30 with (yes, you can go fractional)
    MEMORY: 4G # 256M-24G without compute credits, 256M-90G with
    CIRRUS_WORKING_DIR: "/tmp/$FLUTTER_SDK_PATH_WITH_SPACE"
    CIRRUS_DOCKER_CONTEXT: "dev/"
    PATH: "$CIRRUS_WORKING_DIR/bin:$CIRRUS_WORKING_DIR/bin/cache/dart-sdk/bin:$PATH"
    ANDROID_SDK_ROOT: "/opt/android_sdk"
  pub_cache:
    folder: $HOME/.pub-cache
    fingerprint_script: echo $OS; grep -r --include=pubspec.yaml 'PUBSPEC CHECKSUM' "$CIRRUS_WORKING_DIR"
    reupload_on_changes: false
  flutter_pkg_cache:
    folder: bin/cache/pkg
    fingerprint_script: echo $OS; cat bin/internal/*.version
    reupload_on_changes: false
  artifacts_cache:
    folder: bin/cache/artifacts
    fingerprint_script: echo $OS; cat bin/internal/*.version
    reupload_on_changes: false
  setup_script:
    - date
    - git clean -xffd --exclude=bin/cache/
    - git fetch origin
    - git fetch origin master # To set FETCH_HEAD, so that "git merge-base" works.
    - flutter config --no-analytics
    - flutter doctor -v
    - flutter update-packages
    - ./dev/bots/accept_android_sdk_licenses.sh
    - date
  on_failure:
    failure_script:
      - date
      - which flutter
  matrix:
    - name: analyze-linux # linux-only
      # environment:
        # Empirically, the analyze-linux shard runs surprisingly fast (under 15 minutes) with just 1
        # CPU and 4G RAM as of October 2019. It fails with less than 4G though.
      script:
        - dart --enable-asserts ./dev/bots/analyze.dart

    - name: fuchsia_precache-linux # linux-only
      only_if: "changesInclude('.cirrus.yml', 'bin/internal/engine.version')"
      script:
        - flutter precache --fuchsia --no-android --no-ios
        - flutter precache --flutter_runner --no-android --no-ios

    - name: framework_tests-widgets-linux
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # We use 3 CPUs because that's the minimum required to get framework_tests-widgets-linux
        # running fast enough that it is not the long pole, as of OCtober 2019.
        CPU: 3
        GOLD_SERVICE_ACCOUNT: ENCRYPTED[3afeea5ac7201151c3d0dc9648862f0462b5e4f55dc600ca8b692319622f7c3eda3d577b1b16cc2ef0311b7314c1c095]
      script:
        - dart --enable-asserts ./dev/bots/test.dart

    - name: framework_tests-libraries-linux
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # We use 3 CPUs because that's the minimum required to get the
        # framework_tests-libraries-linux shard running fast enough that it is not the long pole, as
        # of October 2019.
        CPU: 3
        GOLD_SERVICE_ACCOUNT: ENCRYPTED[3afeea5ac7201151c3d0dc9648862f0462b5e4f55dc600ca8b692319622f7c3eda3d577b1b16cc2ef0311b7314c1c095]
      script:
        - dart --enable-asserts ./dev/bots/test.dart

    - name: framework_tests-misc-linux
      # this includes the tests for directories in dev/
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_goldens/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # We use 3 CPUs because that's the minimum required to get framework_tests-misc-linux
        # running fast enough that it is not the long pole, as of October 2019.
        CPU: 3
      script:
        - dart --enable-asserts ./dev/bots/test.dart

    - name: tool_tests-general-linux
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter_tools/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # As of November 2019, the tool_tests-general-linux shard got faster with more CPUs up to 4
        # CPUs, and needed at least 10G of RAM to not run out of memory.
        CPU: 4
        MEMORY: 10G
      script:
        - dart --enable-asserts ./dev/bots/test.dart

    - name: tool_tests-commands-linux
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter_tools/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # As of October 2019, the tool_tests-commands-linux shard got faster with more CPUs up to 6
        # CPUs, and needed at least 8G of RAM to not run out of memory.
        # Increased to 10GB on 19th Nov 2019 due to significant number of OOMKilled failures on PR builds.
        CPU: 6
        MEMORY: 10G
      script:
        - dart --enable-asserts ./dev/bots/test.dart

    - name: tool_tests-integration-linux
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter_tools/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # As of October 2019, the tool_tests-integration-linux shard got faster with more CPUs up to
        # 6 CPUs, and needed at least 8G of RAM to not run out of memory.
        CPU: 6
        MEMORY: 8G
      script:
        - dart --enable-asserts ./dev/bots/test.dart

    - name: tool_coverage-linux # linux-only
      only_if: "$CIRRUS_BRANCH == 'master'"
      environment:
        # As of February 2020, the tool_coverage-linux shard needed at least 24G of RAM to run without
        # getting OOM-killed, and even 8 CPUs took 25 minutes.
        CPU: 8
        MEMORY: 24G
        CODECOV_TOKEN: ENCRYPTED[7c76a7f8c9264f3b7f3fd63fcf186f93c62c4dfe43ec288861c2f506d456681032b89efe7b7a139c82156350ca2c752c]
      script:
        - dart --enable-asserts ./dev/bots/test.dart
        - bash <(curl -s https://codecov.io/bash) -c -f packages/flutter_tools/coverage/lcov.info -F flutter_tool

    - name: web_integration_tests
      << : *WEB_SHARD_TEMPLATE

    - name: web_tests-0-linux
      << : *WEB_SHARD_TEMPLATE

    - name: web_tests-1-linux
      << : *WEB_SHARD_TEMPLATE

    - name: web_tests-2-linux
      << : *WEB_SHARD_TEMPLATE

    - name: web_tests-3-linux
      << : *WEB_SHARD_TEMPLATE

    - name: web_tests-4-linux
      << : *WEB_SHARD_TEMPLATE

    - name: web_tests-5-linux
      << : *WEB_SHARD_TEMPLATE

    - name: web_tests-6-linux
      << : *WEB_SHARD_TEMPLATE

    - name: web_tests-7_last-linux # last Web shard must end with _last
      << : *WEB_SHARD_TEMPLATE

    - name: build_tests-linux
      environment:
        # With 1 CPU and 4G of RAM, as of October 2019, build_tests-linux would get OOM-killed.
        # Increasing the RAM to 12G allowed it to finish in about 30 minutes, any extra CPU (tried 2
        # and 4) reduced that to just over 20 minutes. 6G was enough not to get OOM-killed.
        CPU: 2
        MEMORY: 6G
      script:
        - dart --enable-asserts ./dev/bots/test.dart

    - name: hostonly_devicelab_tests-0-linux
      << : *LINUX_SHARD_TEMPLATE

    - name: hostonly_devicelab_tests-1-linux
      << : *LINUX_SHARD_TEMPLATE

    - name: hostonly_devicelab_tests-2-linux
      << : *LINUX_SHARD_TEMPLATE

    - name: hostonly_devicelab_tests-3_last-linux
      << : *LINUX_SHARD_TEMPLATE

    # TODO(ianh): name: add_to_app_tests-linux

    - name: docs-linux # linux-only
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_drive/**', 'packages/flutter_localizations/**', 'packages/flutter_goldens/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # Empirically, as of October 2019, the docs-linux shard took about 30 minutes when run with
        # 1 CPU and 4G of RAM. 2 CPUs reduced that to 20 minutes, more CPUs did not improve matters.
        CPU: 2
        # For uploading master docs to Firebase master branch staging site
        FIREBASE_MASTER_TOKEN: ENCRYPTED[eb768d18798fdc5abfe09b224e1724c4d82831d715ccf90df2c79d618c317216cbd99493278361f6fe7948b409b603f0]
        # For uploading beta docs to Firebase public live site
        FIREBASE_PUBLIC_TOKEN: ENCRYPTED[37e8b82f167864cae9a3f4d2cf3f37dea331d9375c295327c45de524f6c588fa6f6d63e5784f10f6d43ce29689f36c92]
      script:
        - ./dev/bots/docs.sh

    - name: customer_testing-linux
      # environment:
        # Empirically, this shard runs fine at 1 CPU and 4G RAM as of October 2019. We will probably
        # want to grow this container when we invite people to add their tests in large numbers.
      script:
        - rm -rf bin/cache/pkg/tests
        - git clone https://github.com/flutter/tests.git bin/cache/pkg/tests
        - dart --enable-asserts dev/customer_testing/run_tests.dart --skip-on-fetch-failure --skip-template bin/cache/pkg/tests/registry/*.test

    - name: firebase_test_lab_tests-linux # linux-only
      environment:
        # Empirically, this shard runs in 20-25 minutes with just one CPU and 4G of RAM, as of
        # October 2019. It does not seem to be sensitive to the number of CPUs or amount of RAM;
        # doubling CPUs had no effect (mere seconds under 20 minutes), increasing RAM to 24G left it
        # on the high end of the 20-25 minute range. (This makes sense, as it's just driving the
        # Firebase test lab remotely.) Less than 4G of RAM made it go OOM.
        CLOUDSDK_CORE_DISABLE_PROMPTS: 1
        GCLOUD_FIREBASE_TESTLAB_KEY: ENCRYPTED[1c140257edc48f5578fa5a0e5038b84c8e53270c405efa5a8e35ea303a4e0d135853989f448f72136206de854d17fbec]
      script:
        - ./dev/bots/firebase_testlab.sh

    - name: web_smoke_test
      only_if: "changesInclude('.cirrus.yml', 'examples/hello_world/**' ,'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'packages/flutter_web_plugins/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # Tests Hello World with Flutter Web Engine using Flutter Driver. Should not need more resources.
        CPU: 2
        MEMORY: 2G
        CHROME_NO_SANDBOX: true
      script:
        - flutter config --enable-web
        - git clone https://github.com/flutter/web_installers.git
        - cd web_installers/packages/web_drivers/
        - pub get
        - dart lib/web_driver_installer.dart &
        - sleep 20
        - chromedriver/chromedriver --port=4444 &
        - sleep 5
        - cd ../../../examples/hello_world/
        - flutter drive --target=test_driver/smoke_web_engine.dart -d web-server --profile --browser-name=chrome

    - name: deploy_gallery-linux # linux- and macos- only
      # Do not add more tasks here. Nothing is currently deployed from master branch, so it is safe to run
      # even if a test has failed. The behavior of failing dependencies is non-ideal for infra health.
      # See also: https://github.com/flutter/flutter/pull/49454
      depends_on:
        - analyze-linux
      environment:
        # As of October 2019, 1 CPU and 4G of RAM let deploy_gallery-linux finish in about 15
        # minutes, once it got started.
        GOOGLE_DEVELOPER_SERVICE_ACCOUNT_ACTOR_FASTLANE: ENCRYPTED[d9ac1462c3c556fc2f8165c9d5566a16497d8ebc38a50357f7f3abf136b7f83e1d1d76dde36fee356cb0f9ebf7a89346]
        ANDROID_GALLERY_UPLOAD_KEY: ENCRYPTED[0f2aca35f05b26add5d9edea2a7449341269a2b7e22d5c667f876996e2e8bc44ff1369431ebf73b7c5581fd95d0e5902]
      script:
        - ./dev/bots/deploy_gallery.sh

# WINDOWS SHARDS
task:
  windows_container:
    image: cirrusci/android-sdk:28-windowsservercore-2019
    os_version: 2019
    cpu: $CPU
    memory: $MEMORY
  environment:
    CPU: 1 # 1-8 without compute credits, 1-30 with
    MEMORY: 2G # 256M-24G without compute credits, 256M-90G with
    CIRRUS_WORKING_DIR: "C:\\Windows\\Temp\\$FLUTTER_SDK_PATH_WITH_SPACE"
    PATH: "$CIRRUS_WORKING_DIR/bin;$CIRRUS_WORKING_DIR/bin/cache/dart-sdk/bin;$PATH"
  pub_cache:
    folder: $APPDATA\Pub\Cache
    fingerprint_script:
      - ps: $Environment:OS; Get-ChildItem -Path "$Environment:CIRRUS_WORKING_DIR" pubspec.yaml -Recurse | Select-String -Pattern "PUBSPEC CHECKSUM" -SimpleMatch
    reupload_on_changes: false
  flutter_pkg_cache:
    folder: bin\cache\pkg
    fingerprint_script: echo %OS% & type bin\internal\*.version
    reupload_on_changes: false
  artifacts_cache:
    folder: bin\cache\artifacts
    fingerprint_script: echo %OS% & type bin\internal\*.version
    reupload_on_changes: false
  setup_script:
    - git clean -xffd --exclude=bin/cache/ # git wants forward slash path separators, even on Windows.
    - git fetch origin
    - git fetch origin master # To set FETCH_HEAD, so that "git merge-base" works.
    - flutter config --no-analytics
    - flutter doctor -v
    - flutter update-packages
    - git fetch origin master
  matrix:
    - name: framework_tests-widgets-windows
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # As of December 2019, framework_tests-widgets-windows needs 4 CPUs to pass reliably.
        # With a min of 4 CPUs and 4 GB of RAM, it ran in about 50 minutes. Increasing to 8 CPUs and
        # 8 GB RAM sped that up to ~25 minutes, and increasing either beyond that yielded no
        # further speed increase. Cirrus requires >= 8GM RAM for 8 CPUs.
        CPU: 8
        MEMORY: 8G
        GOLDCTL: "C:\\Windows\\Temp\\depot_tools\\goldctl.exe"
        GOLD_SERVICE_ACCOUNT: ENCRYPTED[3afeea5ac7201151c3d0dc9648862f0462b5e4f55dc600ca8b692319622f7c3eda3d577b1b16cc2ef0311b7314c1c095]
      script:
        - powershell dev\bots\download_goldctl.ps1
        - dart --enable-asserts dev\bots\test.dart

    - name: framework_tests-libraries-windows
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # As of December 2019, the framework_tests-libraries-windows shard needed 2 CPUs to pass.
        # With a min of 2 CPUs and 2 GB RAM, it ran in about 60 minutes. Increasing to 8 CPUs made
        # it run in ~20 minutes, and Cirrus requires 8 CPUs to have at least 8 GB RAM. Increasing
        # beyond this yielded no gains.
        CPU: 8
        MEMORY: 8G
        GOLDCTL: "C:\\Windows\\Temp\\depot_tools\\goldctl.exe"
        GOLD_SERVICE_ACCOUNT: ENCRYPTED[3afeea5ac7201151c3d0dc9648862f0462b5e4f55dc600ca8b692319622f7c3eda3d577b1b16cc2ef0311b7314c1c095]
      script:
        - powershell dev\bots\download_goldctl.ps1
        - dart --enable-asserts dev\bots\test.dart

    - name: framework_tests-misc-windows
      # this includes the tests for directories in dev/
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_goldens/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # As of December 2019, the framework_tests-misc-windows shard needed 2 CPUs and 3 GB RAM
        # to pass (taking ~40 minutes). Increasing to 4 CPUs (necessitating 4 GB RAM per Cirrus)
        # sped that up to ~30 minutes, with further overprovisioning yielding no further gain.
        CPU: 4
        MEMORY: 4G
      script:
        - dart --enable-asserts dev\bots\test.dart

    - name: tool_tests-general-windows
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter_tools/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # As of December 2019, the tool_tests-general-windows shard required 2 CPUs and 8 GB RAM to
        # pass. Raising that to 4 CPUs sped it up to ~30 minutes, with further provisioning yielding
        # no gain.
        CPU: 4
        MEMORY: 8G
      script:
        - dart --enable-asserts ./dev/bots/test.dart

    - name: tool_tests-commands-windows
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter_tools/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # As of December 2019, the tool_tests-commands-windows shard needed 4 CPUs and 8 GB RAM to
        # reliably pass and not be the long pole, running in about 25 minutes. Bumping beyond these
        # numbers yielded no extra gain.
        CPU: 4
        MEMORY: 8G
      script:
        - dart --enable-asserts ./dev/bots/test.dart

    - name: tool_tests-integration-windows
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter_tools/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        # As of December 2019, the tool_tests-integration-windows shard required 6 GB RAM to pass.
        # Emperically, 4 CPUs and 10 GB RAM yielded optimal results (~22 minutes); bumping beyond
        # these amounts yielded no extra gain.
        CPU: 4
        MEMORY: 10G
      script:
        - dart --enable-asserts ./dev/bots/test.dart

    # TODO(ianh): Enable Web tests on Windows

    - name: build_tests-windows
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'bin/internal/**') || $CIRRUS_PR == ''" # https://github.com/flutter/flutter/issues/41941
      environment:
        # As of December 2019, the build_tests-windows shard requires 6 GB RAM to pass.
        # Emperically, using 6 CPUs and 10 GB RAM yielded optimal results (~33 minutes);
        # bumping beyond these limits yielded no extra gain.
        CPU: 6
        MEMORY: 10G
      script:
        - dart --enable-asserts dev\bots\test.dart

    - name: hostonly_devicelab_tests-0-windows
      << : *WINDOWS_SHARD_TEMPLATE
      environment:
        # As of December 2019, the hostonly_devicelab_tests-0-windows shard needs at least 6G RAM to
        # succeed. The shard got faster with more CPUs up to 6 CPUs and more RAM up to 8 GB
        # (running in about 30 minutes).
        CPU: 6
        MEMORY: 8G

    - name: hostonly_devicelab_tests-1-windows
      << : *WINDOWS_SHARD_TEMPLATE
      environment:
        # As of December 2019, the hostonly_devicelab_tests-1-windows shard requires 4 GB RAM to
        # succeed. The optimal configuration was 4 CPUs and 6 GB RAM, running in ~26 minutes.
        # Less CPU or RAM ran slower, and more CPU or RAM yielded no extra gain.
        CPU: 4
        MEMORY: 6G

    - name: hostonly_devicelab_tests-2-windows
      << : *WINDOWS_SHARD_TEMPLATE
      environment:
        # As of December 2019, the hostonly_devicelab_tests-2-windows shard required 2 GB RAM to
        # succeed. The optimal configuration was 4 CPUs and 8 GB RAM, running in ~33 minutes.
        # Less CPU or RAM ran slower, and more CPU or RAM yielded no extra gain.
        CPU: 4
        MEMORY: 8G

    - name: hostonly_devicelab_tests-3_last-windows
      << : *WINDOWS_SHARD_TEMPLATE
      environment:
        # As of December 2019, the hostonly_devicelab_tests-3_last-windows shard required 6 GB RAM
        # to succeed. The optimal configuration was 4 CPUs and 6 GB RAM, running in ~43 minutes.
        # Less CPU or RAM ran slower, and more CPU or RAM yielded no extra gain.
        CPU: 4
        MEMORY: 6G

    # TODO(ianh): name: add_to_app_tests-windows

    - name: customer_testing-windows
      environment:
        # As of December 2019, the customer_testing-windows shard got faster with more CPUs up to 4
        # CPUs (which requires >=4G RAM), and needed at least 2G of RAM to not run out of memory.
        CPU: 4
        MEMORY: 4G
      script:
        - CMD /S /C "IF EXIST "bin\cache\pkg\tests\" RMDIR /S /Q bin\cache\pkg\tests"
        - git clone https://github.com/flutter/tests.git bin\cache\pkg\tests
        - dart --enable-asserts dev\customer_testing\run_tests.dart --skip-on-fetch-failure --skip-template bin/cache/pkg/tests/registry/*.test

# MACOS SHARDS
# Mac doesn't use caches because they apparently take longer to populate and save
# than just fetching the data in the first place.
task:
  osx_instance:
    image: catalina-flutter # see https://cirrus-ci.org/guide/macOS/ for list of images (we should update regularly)
    # cpu is always 2
    # memory is always 8G
  environment:
    CIRRUS_WORKING_DIR: "/tmp/$FLUTTER_SDK_PATH_WITH_SPACE"
    FLUTTER_FRAMEWORK_DIR: "$CIRRUS_WORKING_DIR/bin/cache/artifacts/engine/ios/"
    PATH: "$CIRRUS_WORKING_DIR/bin:$CIRRUS_WORKING_DIR/bin/cache/dart-sdk/bin:$PATH"
    COCOAPODS_DISABLE_STATS: true
    CPU: 2
    MEMORY: 8G
  setup_script:
    - date
    - which flutter
    - bundle --version
    - bundle config set system 'true'
    - sudo bundle install --gemfile=dev/ci/mac/Gemfile
    - git clean -xffd --exclude=bin/cache/
    - git fetch origin
    - git fetch origin master # To set FETCH_HEAD, so that "git merge-base" works.
    - flutter config --no-analytics
    - flutter doctor -v
    - flutter update-packages
    - date
    - which flutter
  on_failure:
    failure_script:
      - date
      - which flutter
  matrix:
    - name: framework_tests-widgets-macos
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        GOLDCTL: "$CIRRUS_WORKING_DIR/depot_tools/goldctl"
        GOLD_SERVICE_ACCOUNT: ENCRYPTED[3afeea5ac7201151c3d0dc9648862f0462b5e4f55dc600ca8b692319622f7c3eda3d577b1b16cc2ef0311b7314c1c095]
      script:
        - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
        - ./dev/bots/download_goldctl.sh
        - dart --enable-asserts dev/bots/test.dart

    - name: framework_tests-libraries-macos
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      environment:
        GOLDCTL: "$CIRRUS_WORKING_DIR/depot_tools/goldctl"
        GOLD_SERVICE_ACCOUNT: ENCRYPTED[3afeea5ac7201151c3d0dc9648862f0462b5e4f55dc600ca8b692319622f7c3eda3d577b1b16cc2ef0311b7314c1c095]
      script:
        - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
        - ./dev/bots/download_goldctl.sh
        - dart --enable-asserts dev/bots/test.dart

    - name: framework_tests-misc-macos
      # this includes the tests for directories in dev/
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_goldens/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      script:
        - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
        - dart --enable-asserts dev/bots/test.dart

    - name: tool_tests-general-macos
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter_tools/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      script:
        - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
        - dart --enable-asserts ./dev/bots/test.dart

    - name: tool_tests-commands-macos
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter_tools/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      script:
        - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
        - dart --enable-asserts ./dev/bots/test.dart

    - name: tool_tests-integration-macos
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter_tools/**', 'bin/internal/**') || $CIRRUS_PR == ''"
      script:
        - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
        - dart --enable-asserts ./dev/bots/test.dart

    # TODO(ianh): Enable Web tests on macOS.

    - name: build_tests-macos
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'bin/internal/**') || $CIRRUS_PR == ''" # https://github.com/flutter/flutter/issues/41940
      script:
        - dart --enable-asserts ./dev/bots/test.dart

    - name: hostonly_devicelab_tests-0-macos
      << : *MACOS_SHARD_TEMPLATE

    - name: hostonly_devicelab_tests-1-macos
      << : *MACOS_SHARD_TEMPLATE

    - name: hostonly_devicelab_tests-2-macos
      << : *MACOS_SHARD_TEMPLATE

    - name: hostonly_devicelab_tests-3_last-macos
      << : *MACOS_SHARD_TEMPLATE

    - name: add_to_app_tests-macos
      only_if: "changesInclude('.cirrus.yml', 'dev/**', 'bin/internal/**') || $CIRRUS_PR == ''" # https://github.com/flutter/flutter/issues/41940
      skip: true # https://github.com/flutter/flutter/pull/42444
      script:
        - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
        - dart --enable-asserts dev/bots/test.dart

    - name: customer_testing-macos
      script:
        - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
        - rm -rf bin/cache/pkg/tests
        - git clone https://github.com/flutter/tests.git bin/cache/pkg/tests
        - dart --enable-asserts dev/customer_testing/run_tests.dart --skip-on-fetch-failure --skip-template bin/cache/pkg/tests/registry/*.test

    - name: deploy_gallery-macos # linux- and macos- only
      # Do not add more tasks here. Nothing is currently deployed from master branch, so it is safe to run
      # even if a test has failed. The behavior of failing dependencies is non-ideal for infra health.
      # See also: https://github.com/flutter/flutter/pull/49454
      depends_on:
        - analyze-linux
      environment:
        # Apple Fastlane password.
        FASTLANE_PASSWORD: ENCRYPTED[4b1f0b8d52874e9de965acd46c79743f3b81f3a513614179b9be7cf53dc8258753e257bdadb11a298ee455259df21865]
        # Private repo for publishing certificates.
        PUBLISHING_MATCH_CERTIFICATE_REPO: ENCRYPTED[3c0e78877d933fc80107aa6f3790fd1cf927250b852d6cb53202be696b4903ed8ca839b809626aaf18050bf7e436fab7]
        PUBLISHING_MATCH_REPO_TOKEN: ENCRYPTED[3d1230b744c6ed6c788a91bec741b769401dbcd426b18f9af8080bfeefdfc21913ca4047980c5b5b7ce823f12e7b6b19]
        # Apple Certificates Match Passphrase
        MATCH_PASSWORD: ENCRYPTED[db07f252234397090e3ec59152d9ec1831f5ecd0ef97d247b1dca757bbb9ef9b7c832a39bce2caf1949ccdf097e59a73]
      script:
        - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
        - ./dev/bots/deploy_gallery.sh

    - name: verify_binaries_codesigned-macos # macos-only
      # TODO(fujino): remove this `only_if` after https://github.com/flutter/flutter/issues/44372
      # Do not run on master pre/post submit
      only_if: "$CIRRUS_BASE_BRANCH != 'master' && $CIRRUS_BRANCH != 'master'"
      depends_on:
        - analyze-linux
      script:
        - ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
        - dart --enable-asserts ./dev/bots/codesign.dart

docker_builder:
  # Only build a new docker image when we tag a release (for dev, beta, or
  # stable). Note: tagging a commit and pushing to a release branch are
  # different cirrus triggers. See a tag CI run at e.g.
  # https://cirrus-ci.com/github/flutter/flutter/v1.2.3
  name: docker_build
  only_if: $CIRRUS_TAG != ''
  environment:
    GCLOUD_CREDENTIALS: ENCRYPTED[f7c098d4dd7f5ee1bfee0bb7e944cce72efbe10e97ad6440ae72de4de6a1c24d23f421a2619c668e94377fb64b0bb3e6]
  # Do not add more tasks here. The behavior of failing dependencies is non-ideal for infra health.
  # See also: https://github.com/flutter/flutter/pull/49454
  depends_on:
    - docs-linux
    - analyze-linux
  build_script:
    - cd "$CIRRUS_WORKING_DIR/dev/ci/docker_linux"
    - ./docker_build.sh
    - ./docker_login.sh
    - ./docker_push.sh